:param f:
    :type f: file
    :return:
500932
def print_ast(f):
    
    for linenum,indent,value in iter_lines(f):
        print("{0}{1}|{2}".format(str(linenum).rjust(3), ' ' * indent, value))
1198558
def _file_dict(self, fn_):
        '''
        
        '''
        if not os.path.isfile(fn_):
            err = 'The referenced file, {0} is not available.'.format(fn_)
            sys.stderr.write(err + '\n')
            sys.exit(42)
        with salt.utils.files.fopen(fn_, 'r') as fp_:
            data = fp_.read()
        return {fn_: data}
1164698
def get_parsed_data(fn, *args, **kwargs):
    
    file_format = detect_format(fn, *args, **kwargs)
    data = get_header(fn, file_format, *args, **kwargs)
    parsed_data = parse_header(data, *args, **kwargs)
    return parsed_data
314104
def from_file(cls, f):
        

        with open_file_like(f, 'r') as fp:
            return cls(json.load(fp))
1259212
def open_file(self, fname, length=None, offset=None, swap=None, block=None, peek=None):
        '''
        
        '''
        if length is None:
            length = self.length
        if offset is None:
            offset = self.offset
        if swap is None:
            swap = self.swap_size

        return binwalk.core.common.BlockFile(fname,
                                             subclass=self.subclass,
                                             length=length,
                                             offset=offset,
                                             swap=swap,
                                             block=block,
                                             peek=peek)
1040306
def _augment_file(self, f):
        

        def get_url(target):
            if target.file_size is None:
                return None
            if target.file_name is not None:
                return self.base_url + '/files/content/{0}/{1}'.format(target.file_id.hex, target.file_name)
            else:
                return self.base_url + '/files/content/{0}'.format(target.file_id.hex, )

        f.get_url = types.MethodType(get_url, f)

        def download_to(target, file_name):
            url = target.get_url()
            r = requests.get(url, stream=True)
            with open(file_name, 'wb') as file_to_write:
                for chunk in r.iter_content(chunk_size=1024):
                    if chunk:  # filter out keep-alive new chunks
                        file_to_write.write(chunk)
                        file_to_write.flush()
            return file_name

        f.download_to = types.MethodType(download_to, f)
        return f
565314
def _fileobj_to_fd(fileobj):
    
    if isinstance(fileobj, _INTEGER_TYPES):
        fd = fileobj
    else:
        for _integer_type in _INTEGER_TYPES:
            try:
                fd = _integer_type(fileobj.fileno())
                break
            except (AttributeError, TypeError, ValueError):
                continue
        else:
            raise ValueError("Invalid file object: {0!r}".format(fileobj))
    if fd < 0:
        raise ValueError("Invalid file descriptor: {0}".format(fd))
    return fd
1104636
def match_file(self, f, update_file=False):
        
        if self.map_func is not None:
            val = self.map_func(f)
        else:
            m = self.regex.search(f.path)
            val = m.group(1) if m is not None else None

        return self._astype(val)
799862
def from_file(cls, f):
        
        word2index = {}
        counts = Counter()
        for i, line in enumerate(f):
            word, count_str = line.split('\t')
            word = word.decode('utf-8')
            word2index[word] = i
            counts[word] = float(count_str)
            if i == 0:
                unk = word
        return cls.from_dict(word2index, unk, counts)
909726
def load_from_file(self, fname):
        
        with open(fname, 'r') as f:
            for line in f:
                k,v = line.split(' = ')
                self._parse_char_line_to_self(k,v)
69868
def get_single_file_info(f_path, int_path):
    
    return { 'path'     : force_unicode(int_path),
             'created'  : os.path.getctime(f_path),
             'last_mod' : os.path.getmtime(f_path)}
856941
def read_file(fname):
    
    print("NO - dont use this function read_file(fname):")
    exit(1)
    lst = []
    with open(fname, 'r') as f:
        #hdr = f.readline()
        for line in f:
            lst.append(line.strip('\n'))
    return lst
470521
def upload_from_fs(fn, profile=None, label=None):
    
    if not os.path.isfile(fn):
        raise ValueError('File is not exists: {}'.format(fn))
    if profile is None:
        profile = 'default'
    conf = get_profile_configs(profile)
    with open(fn, 'rb') as f:
        if not is_image(f, types=conf['TYPES']):
            msg = (('Format of uploaded file "%(name)s" is not allowed. '
                    'Allowed formats is: %(formats)s.') %
                   {'name': fn, 'formats': ', '.join(map(lambda t: t.upper(), conf['TYPES']))})
            raise RuntimeError(msg)
        return _custom_upload(f, profile, label, conf)
1216556
def record_to_fs(self):
        """"""

        fr = self.record

        if fr.contents:
            with self._fs.open(self.file_name, 'w', encoding='utf-8') as f:
                self.record_to_fh(f)
937293
def simplefilter(f):
    
    return type(f.__name__, (FunctionFilter,), {
        '__module__': getattr(f, '__module__'),
        '__doc__': f.__doc__,
        'function': f,
    })
835954
function parseFile(fs, file, type) {
    var filepath = file.getPath();
    var parser = file.getParser();

    if (!parser) {
        return Promise.reject(
            error.FileNotParsableError({
                filename: filepath
            })
        );
    }

    return fs.readAsString(filepath)
    .then(function(content) {
        if (type === 'readme') {
            return parser.parseReadme(content);
        } else if (type === 'glossary') {
            return parser.parseGlossary(content);
        } else if (type === 'summary') {
            return parser.parseSummary(content);
        } else if (type === 'langs') {
            return parser.parseLanguages(content);
        } else {
            throw new Error('Parsing invalid type "' + type + '"');
        }
    })
    .then(function(result) {
        return [
            file,
            result
        ];
    });
}
929846
def parse_ftype(input_file):
    
    if input_file.endswith(".bam"):
        return "bam"
    elif input_file.endswith(".fastq") or \
            input_file.endswith(".fq") or \
            input_file.endswith(".fq.gz") or \
            input_file.endswith(".fastq.gz"):
        return "fastq"
    else:
        raise TypeError("Type of input file ends in neither '.bam' "
                        "nor '.fastq' [file: '" + input_file + "']")