Created
February 4, 2018 17:35
-
-
Save hartym/10a020925980972db4e85d51badead34 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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