Given a file name to a valid file returns the file object.
175360
def file_contents(file_name):
    """"""
    curr_dir = os.path.abspath(os.path.dirname(__file__))
    with open(os.path.join(curr_dir, file_name)) as the_file:
        contents = the_file.read()
    return contents
1258097
def get_file_contents(filename):
    
    data = None
    try:
        with open(filename) as pf:
            data = pf.read()
    except IOError:
        # File not found, return None
        pass
    return data
697672
def to_file(self, filename):
        
        filename = os.path.expanduser(filename)
        libfn = utils.get_lib_fn('toFile%s'%self._libsuffix)
        libfn(self.pointer, filename)
649001
def read_file(name):
    """"""
    cur_path = os.path.dirname(__file__)
    exts = ('txt', 'rst')
    for ext in exts:
        path = os.path.join(cur_path, '.'.join((name, ext)))
        if os.path.exists(path):
            with open(path, 'rt') as file_obj:
                return file_obj.read()

    return ''
1045710
def filedet(name, fobj=None, suffix=None):
    
    name = name or (fobj and fobj.name) or suffix
    separated = name.split('.')
    if len(separated) == 1:
        raise FiledetException('file name error.')

    key = '.' + separated[-1]
    return _file_type_map.get(key)
233384
def get_hash_for_filename(filename, hashfile_path):
    """"""
    filehash = ''
    with open(hashfile_path, 'r') as stream:
        for _cnt, line in enumerate(stream):
            if line.rstrip().endswith(filename):
                filehash = re.match(r'^[A-Za-z0-9]*', line).group(0)
                break
    if filehash:
        return filehash
    raise AttributeError("Filename %s not found in hash file" % filename)
294003
def get_property(self, filename):
        """"""

        with open(self.filepath(filename)) as f:
            return f.read().strip()
448314
def touch_file(self, filename):
        """"""
        path_to_file = self.__file_class__(os.path.join(self, filename))
        path_to_file.touch()
        return path_to_file
946774
def file(self, filename):
        
        try:  # attempt python3 approach first
            if isinstance(filename, bytes):
                bi = filename
            else:
                bi = bytes(filename, 'utf-8')
            return str(_file(self._magic_t, bi), 'utf-8')
        except:
            return _file(self._magic_t, filename.encode('utf-8'))
892879
def valid_file(value):
    
    if not value:
        raise argparse.ArgumentTypeError("'' is not a valid file path")
    elif not os.path.exists(value):
        raise argparse.ArgumentTypeError(
            "%s is not a valid file path" % value)
    elif os.path.isdir(value):
        raise argparse.ArgumentTypeError(
            "%s is a directory, not a regular file" % value)
    return value
630806
def file_checksum(fname):
    
    size = os.path.getsize(fname)
    with open(fname, "r+") as f:
        checksum = hashlib.md5(mmap.mmap(f.fileno(), size)).hexdigest()
    return checksum
45310
function getFileByName(filename){
    if(!isLoaded[filename]){
        isLoaded[filename] = true;
        let CIniUserMgr	= CreateFile(filename);
        if (CIniUserMgr.IsHave()) {
            iniList[filename] = CIniUserMgr;
        }
    }
    return iniList[filename];
}
1167840
def read_file(filename):
    
    if os.path.isfile(filename):
        with open(filename, 'r') as f:
            return f.read()
1302474
def is_valid_file(path):
    '''  '''
    return os.path.exists(path) and os.path.isfile(path)
986230
def normalizeFilename(filename):
    
    result = os.path.expanduser(filename)
    result = os.path.abspath(result)
    return result
408150
def glob(self, filename):
        """"""
        if isinstance(filename, six.string_types):
            return [
                # Convert the filenames to string from bytes.
                compat.as_str_any(matching_filename)
                for matching_filename in py_glob.glob(
                    compat.as_bytes(filename))
            ]
        else:
            return [
                # Convert the filenames to string from bytes.
                compat.as_str_any(matching_filename)
                for single_filename in filename
                for matching_filename in py_glob.glob(
                    compat.as_bytes(single_filename))
            ]
821495
def get_file_fullpath(name, dirname=None):
        # type: (AnyStr, Optional[AnyStr]) -> Optional[AnyStr]
        """"""
        if name is None:
            return None
        if is_string(name):
            name = str(name)
        else:
            raise RuntimeError('The input function name or path must be string!')
        for sep in ['\\', '/', os.sep]:  # Loop all possible separators
            if sep in name:  # name is full path already
                name = os.path.abspath(name)
                return name
        if dirname is not None:
            dirname = os.path.abspath(dirname)
            name = dirname + os.sep + name
        return name