예제 #1
0
# gencat.py
#
# Concatenate multiple generators into a single sequence


def gen_cat(sources):
    for s in sources:
        for item in s:
            yield item


# Example use

if __name__ == '__main__':
    from genfind import gen_find
    from genopen import gen_open

    lognames = gen_find("access-log*", "www")
    logfiles = gen_open(lognames)
    loglines = gen_cat(logfiles)
    for line in loglines:
        print(line)
예제 #2
0
파일: genopen.py 프로젝트: ddxd/leetcode
def lines_from_dir(filepat, dirname):
    names = gen_find(filepat,dirname)
    files = gen_open(names)
    lines = gen_cat(files)
    return lines
예제 #3
0
# gencat.py
#
# Concatenate multiple generators into a single sequence

def gen_cat(sources):
    for s in sources:
        for item in s:
            yield item

# Example use

if __name__ == '__main__':
    from genfind import  gen_find
    from genopen import  gen_open

    lognames = gen_find("access-log*","www")
    logfiles = gen_open(lognames)
    loglines = gen_cat(logfiles)
    for line in loglines:
        print line,
예제 #4
0
파일: linesdir.py 프로젝트: zeroam/TIL
def lines_from_dir(filepat, dirname):
    names = Path(dirname).rglob(filepat)
    files = gen_open(names)
    lines = gen_cat(files)
    return lines