def flatten(): p = Pipe(None, name="flatten") p.flatten() return p
def flat_map(func): p = Pipe(None, name="flatmap") p.flat_map(func) return p
def map_to(func): p = Pipe(None, name="map_to") p.steps.append(func) return p
def curl(url): import urllib.request with urllib.request.urlopen(url) as response: lines = response.readlines() p = Pipe(lines, name="curl") return p
def echo(str_input): p = Pipe([str_input], final=True, name="echo") return p
def cat(filename): reader = open(filename, 'r') return Pipe(reader.read().splitlines(), name="cat")
def pipe(*args, **kwargs): return Pipe(*args, **kwargs)