Skip to content

Instantly share code, notes, and snippets.

@hartym
Created February 4, 2018 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hartym/10a020925980972db4e85d51badead34 to your computer and use it in GitHub Desktop.
Save hartym/10a020925980972db4e85d51badead34 to your computer and use it in GitHub Desktop.
import bonobo
from bonobo.util.bags import BagType
from bonobo_quirksmode.config import set_output_type
def generate():
yield from ('a', 'b', 'c')
LetterBag = BagType('LetterBag', ['letter'])
@set_output_type(LetterBag)
def tolower(x):
yield x.lower()
@set_output_type(LetterBag)
def toupper(x):
yield x.upper()
def get_graph(**options):
graph = bonobo.Graph()
chain = graph.add_chain(
generate,
tolower,
print,
)
graph.add_chain(
toupper,
_input=chain.input,
_output=chain.output,
)
return graph
def get_services(**options):
return {}
if __name__ == '__main__':
with bonobo.parse_args() as options:
bonobo.run(get_graph(**options), services=get_services(**options))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment