Returns a case from a version 30 PSS/E raw file.

        @param file_or_filename: File name or file like object with PSS/E data
        @return: Case object
969836
def read(self, file_or_filename):
        
        t0 = time.time()
        self.init()
        if isinstance(file_or_filename, basestring):
            fname = os.path.basename(file_or_filename)
            logger.info("Loading PSS/E Raw file [%s]." % fname)

            file = None
            try:
                file = open(file_or_filename, "rb")
            except:
                logger.error("Error opening %s." % fname)
                return None
            finally:
                if file is not None:
                    case = self._parse_file(file)
                    file.close()
        else:
            file = file_or_filename
            case = self._parse_file(file)

        logger.info("PSS/E Raw file parsed in %.2fs." % (time.time() - t0))

        return case
75155
def canProcessFilename(cls, filename):
        
        supported_patterns = cls._extpattern_to_mime.keys()
        for pattern in supported_patterns:
            if fnmatch.fnmatch(filename, pattern):
                return True
        return False
282529
def get_file_head(file_name):
    """"""

    text = None
    try:
        with open(file_name, 'r', encoding='utf-8') as fh:
            text = fh.read(512000)
    except:
        try:
            with open(file_name, 'r', encoding=sys.getfilesystemencoding()) as fh:
                text = fh.read(512000)  # pragma: nocover
        except:
            log.traceback(logging.DEBUG)
    return text
645859
def which(filename, env=None):
    ''''''

    # Special case where filename contains an explicit path.
    if os.path.dirname(filename) != '' and is_executable_file(filename):
        return filename
    if env is None:
        env = os.environ
    p = env.get('PATH')
    if not p:
        p = os.defpath
    pathlist = p.split(os.pathsep)
    for path in pathlist:
        ff = os.path.join(path, filename)
        if is_executable_file(ff):
            return ff
    return None
1235084
def from_file(cls, filename, sr=22050):
        
        y, sr = librosa.load(filename, sr=sr)
        return cls(y, sr)
489117
def valid_file(cls, filename):
        
        file_ex = os.path.splitext(filename)[1].replace('.', '', 1)
        return file_ex in SUPPORTED_FILES and is_excel_file(filename)
1315055
def build_filename(filename, filetype='png', resolution=300):
    
    filevals = os.path.splitext(filename)
    if filevals[1]:
        filetype = filevals[1][1:]
    if not filetype:
        filetype = 'png'
    filename = filevals[0] + '.' + filetype

    if not resolution:
        resolution = 300
    return filename, filetype, resolution
494953
public static function getSafe(string $fileName = '', bool $allowMixedCase = true): string
    {
        $fileName = \iconv('UTF-8', 'ASCII//TRANSLIT', \trim($fileName));
        if (!$allowMixedCase) {
            $fileName = \strtolower($fileName);
        }
        $fileName = \preg_replace('/[^a-z0-9\-\ \.]/i', '', $fileName);
        $fileName = \preg_replace('/[\s\-]+/', '-', $fileName);

        return $fileName;
    }
1204979
def file_match(file)
      raise ArgumentError, "Filename cannot be nil" if file.nil?
      { filename: file, matched: file, line: 1, column: 1 }
    end
155662
def case_insensitive_file_search(directory, pattern):
    
    try:
        return os.path.join(
            directory,
            [filename for filename in os.listdir(directory)
             if re.search(pattern, filename, re.IGNORECASE)][0])
    except IndexError:
        print("{0} not found".format(pattern))
        raise
571556
def __get_filedate(self):
        

        if os.access(self.__filename, os.R_OK):

            # Read first line of the file
            try:
                sar_file = open(self.__filename, "r")

            except OSError:
                ### DEBUG
                traceback.print_exc()
                return False

            except:
                ### DEBUG
                traceback.print_exc()
                return False

            firstline = sar_file.readline()
            info = firstline.split()
            sar_file.close()

            try:
                self.__file_date = info[3]

            except KeyError:
                self.__file_date = ''
                return False

            except:
                ### DEBUG
                traceback.print_exc()
                return False

            return True

        return False
45191
def load(name_or_file):
    
    f = name_or_file
    opened = False

    if isinstance(name_or_file, basestring):
        f = open(name_or_file, 'rb')
        opened = True
    elif not hasattr(f, 'read'):
        raise ValueError('Readable stream expected')

    name, values = decode(f.read())
    s = SOL(name)

    for n, v in values.iteritems():
        s[n] = v

    if opened is True:
        f.close()

    return s
1181983
def load_any_file(filename):
    
    import f311

    # Splits attempts using ((binary X text) file) criterion
    if a99.is_text_file(filename):
        return load_with_classes(filename, f311.classes_txt())
    else:
        return load_with_classes(filename, f311.classes_bin())
65318
def find_version_by_regex(
    file_source, version_token="__version__"
):  # type: (str,str)->Optional[str]
    
    if not file_source:
        return None
    version_match = re.search(
        r"^" + version_token + r" = ['\"]([^'\"]*)['\"]", file_source, re.M
    )
    if version_match:
        candidate = version_match.group(1)
        if candidate == "" or candidate == ".":  # yes, it will match to a .
            return None
        return candidate
    return None
1374634
def matches?(filename, candidates)
      filename = filename.downcase
      candidates = candidates.compact.map(&:name)
      @exts_and_langs.any? { |ext| filename.end_with?(ext) }
    end
268336
def get_version(filename):
    
    init_py = open(filename).read()
    return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
115324
def load_schema(file_or_fp):
    
    fp = open(file_or_fp, 'r') if isinstance(file_or_fp, str) else file_or_fp
    obj = json.load(fp)
    schema = Schema(obj)
    return schema