Ejemplo n.º 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)
Ejemplo n.º 2
0
def lines_from_dir(filepat, dirname):
    names = gen_find(filepat,dirname)
    files = gen_open(names)
    lines = gen_cat(files)
    return lines
Ejemplo n.º 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,
Ejemplo n.º 4
0
def lines_from_dir(filepat, dirname):
    names = Path(dirname).rglob(filepat)
    files = gen_open(names)
    lines = gen_cat(files)
    return lines