lines(query) -- print the number of words in a given file
768198
def words(query):
	
	filename = support.get_file_name(query)
	if(os.path.isfile(filename)):
		with open(filename) as openfile:
			print len(openfile.read().split())
	else:
		print 'File not found : ' + filename
951707
def print_text(args, infilenames, outfilename=None):
    
    for infilename in infilenames:
        parsed_text = get_parsed_text(args, infilename)
        if parsed_text:
            for line in parsed_text:
                print(line)
            print('')
94325
def _format_file_lines(files):
    ''''''
    LINES_TO_SHOW = 10
    if len(files) <= LINES_TO_SHOW:
        lines = '\n'.join(files)
    else:
        lines = ('\n'.join(files[:LINES_TO_SHOW - 1]) + '\n...{} total'.format(
            len(files)))
    return lines
892598
def sample_lines(lines, n):
    ''''''
    if len(lines) <= n:
        return ''.join(lines)
    else:
        m = len(lines)
        return ''.join([lines[x * m // n + m // (2 * n)] for x in range(n)])
1169610
def count_word(arg):
    ''''''

    conn = sqlite3.connect(os.path.join(DEFAULT_PATH, 'word.db'))
    curs = conn.cursor()
    if arg[0].isdigit():
        if len(arg) == 1:
            curs.execute('SELECT count(*) FROM Word WHERE pr ==  %d' % (int(arg[0])))
        elif len(arg) == 2 and arg[1] == '+':
            curs.execute('SELECT count(*) FROM Word WHERE pr >=  %d' % (int(arg[0])))
        elif len(arg) == 3 and arg[1] == '-':
            curs.execute('SELECT count(*) FROM Word WHERE pr >=  %d AND pr<=  % d' % (int(arg[0]), int(arg[2])))
    elif arg[0].isalpha():
        if arg == 'all':
            curs.execute('SELECT count(*) FROM Word')
        elif len(arg) == 1:
            curs.execute('SELECT count(*) FROM Word WHERE aset == "%s"' % arg.upper())
    res = curs.fetchall()
    print(res[0][0])
    curs.close()
    conn.close()
844281
def count_lines(fname, mode='rU'):
    '''
    '''

    with open(fname, mode) as f:
        for i, l in enumerate(f):
            pass
    return i + 1
565618
def seqres_lines(self):
    """"""
  
    lines = []
  
    for chain in self.keys():
      seq = self[chain]
      serNum = 1
      startidx = 0
      while startidx < len(seq):
        endidx = min(startidx+13, len(seq))
        lines += ["SEQRES  %2i %s %4i  %s\n" % (serNum, chain, len(seq), " ".join(seq[startidx:endidx]))]
        serNum += 1
        startidx += 13
    
    return lines
587697
def _print_lines(self, lines, start, breaks=(), frame=None):
        """"""
        if frame:
            current_lineno = frame.f_lineno
            exc_lineno = self.tb_lineno.get(frame, -1)
        else:
            current_lineno = exc_lineno = -1
        for lineno, line in enumerate(lines, start):
            s = str(lineno).rjust(3)
            if len(s) < 4:
                s += ' '
            if lineno in breaks:
                s += 'B'
            else:
                s += ' '
            if lineno == current_lineno:
                s += '->'
            elif lineno == exc_lineno:
                s += '>>'
            self.message(s + '\t' + line.rstrip())
419212
def print_prefixed_lines(lines: List[Tuple[str, Optional[str]]]) -> str:
    """"""
    existing_lines = [line for line in lines if line[1] is not None]
    pad_len = reduce(lambda pad, line: max(pad, len(line[0])), existing_lines, 0)
    return "\n".join(
        map(
            lambda line: line[0].rjust(pad_len) + line[1], existing_lines  # type:ignore
        )
    )
955384
def readlines(self):
        """"""
        if self.grammar:
            tot = []
            # Used this way instead of a 'for' loop against
            # self.file.readlines() so that there wasn't two copies of the file
            # in memory.
            while 1:
                line = self.file.readline()
                if not line:
                    break
                tot.append(line)
            return tot
        return self.file.readlines()
1257122
def count_lines_in_file(self, fname=''):
        
        i = 0
        if fname == '':
            fname = self.fullname
        try:
            #with open(fname, encoding="utf8") as f:
            with codecs.open(fname, "r",encoding='utf8', errors='ignore') as f:    
                for i, _ in enumerate(f):
                    pass
            return i + 1    
        except Exception as ex:
            print('cant count lines in file in "', fname, '":', str(ex))
            return 0
1015382
def lines_stats(dir_path, file_filter):
    
    n_files = 0
    n_lines = 0
    for p in Path(dir_path).select_file(file_filter):
        n_files += 1
        n_lines += count_lines(p.abspath)
    return n_files, n_lines
756374
def get_lines(self):
        
        with open(self.path, "r") as data:
            self.lines = data.readlines()  # store data in arrays

        return self.lines
1232653
def print_files(opts, file_paths):
    
    print("Parsing the following files:")
    for file_path in file_paths:
        print("  " + strip_prefix(file_path, opts.abs_input))
    print("--------------------")
    print(str(len(file_paths)) + " total\n")
1106319
def get_file_name(query):
	
	match = re.search(r'\S*\.[\d\w]{1,4}', query)
	if(match):
		filename = match.group()
		return filename
	else:
		start = match.start()
		end = match.end()
		spaces = re.finditer(r' ', query)
		space_index = []
		for space in spaces:
			space_index.append(space.start())
		space_index.pop()
		for i in space_index:
			filename = query[i+1:end]
			if(os.path.isfile(filename)):
				return filename
		return None
695709
def file_to_list(in_file):
    '''  '''
    lines = []
    for line in in_file:
        # Strip new line
        line = line.strip('\n')

        # Ignore empty lines
        if line != '':
            # Ignore comments
            if line[0] != '#':
                lines.append(line)

    return lines
1071660
def iter_query(query):
    """"""
    try:
        itr = click.open_file(query).readlines()
    except IOError:
        itr = [query]
    return itr