Skip to content

Instantly share code, notes, and snippets.

@tdgunes tdgunes/test.py
Created Jul 7, 2014

Embed
What would you like to do?
Pyplyn multiple pipes
import pyplyn as p
first_pipe = p.Pipe(name="first")
first_pipe.add(p.LambdaFilter(lambda x: "hello" in x))
first_pipe.add(p.LambdaExtension(lambda x: x.title()))
first_pipe.add(p.Writer("./test/output-1.txt"))
second_pipe = p.Pipe(name="second")
second_pipe.add(p.LambdaFilter(lambda x: "world" in x))
second_pipe.add(p.LambdaExtension(lambda x: x.upper()))
second_pipe.add(p.Writer("./test/output-2.txt"))
main_pipe = p.Pipe(name="main")
main_pipe.add(p.LineReader("./test/input.txt"))
main_pipe.add(p.OutDuplicator(first_pipe, second_pipe))
main_pipe.run()
combine_pipe = p.Pipe(name="combine")
combine_pipe.add(p.InDuplicator(p.LineReader("./test/output-1.txt"), p.LineReader("./test/output-2.txt")))
combine_pipe.add(p.LambdaExtension(lambda x: " ".join([i.strip() for i in x])))
combine_pipe.add(p.LambdaExtension(lambda x: x+"\n"))
combine_pipe.add(p.Writer("./test/output-3.txt"))
combine_pipe.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.