Beispiel #1
0
 def _to_frame(self, usecols, chunk_cnt, show_prog):
     _c = Property()
     _c.lineno = 0
     _c.linecnt = get_line_count(self.abspath)
     _c.show_prog = show_prog
     _c.chunk_cnt = chunk_cnt
     return pd.concat(self._to_frame_gen(_c, usecols))
Beispiel #2
0
def _file_head_or_tail(flike, head, count=10):
    tmp_file, _ = unique_tmp_path(TMP_PREFIX)
    with open(tmp_file, 'w') as out:
        c = 'head' if head else 'tail'
        abspath = get_realpath(flike.abspath)
        cmd = [c, '-n', str(count), abspath]
        check_call(cmd, stdout=out)

    cnt = get_line_count(tmp_file)
    if head:
        linfos = flike._linfos[0:cnt]
    else:
        linfos = flike._linfos[-cnt:]
    return TempFile(flike._ctx, tmp_file, linfos, True)
Beispiel #3
0
def _find_in_fileo_grep(ctx, result_file, tmp_file, word, idx, _file, fileno,
                        options, print_prog):
    # grep to tmp
    found = True
    with open(tmp_file, 'w') as out:
        try:
            _find_in_fileo_grep_call(ctx, word, idx, _file, fileno,
                                     options, out, print_prog)
        except CalledProcessError:
            found = False

    # fill info with match count
    cnt = get_line_count(tmp_file)
    with open(result_file, 'a') as out:
        cmd = ['cat', tmp_file]
        check_call(cmd, stdout=out)
    if found:
        return LineInfo(LineInfoImpl_Count(_file.node, _file.kind,
                                           _file.date, _file, cnt))
Beispiel #4
0
 def __init__(self, ctx, path, linfos, showall=False):
     super(TempFile, self).__init__(ctx, linfos)
     self._abspath = path
     self._count = get_line_count(path)
     self.showall = showall
Beispiel #5
0
 def _calc_lcount(self):
     if self._lcount == -1:
         self._lcount = get_line_count(self.abspath)
     return self._lcount
Beispiel #6
0
 def __len__(self):
     return get_line_count(self.abspath)