from funcy import rcompose, flatten # TODO: remove the dispatcher component from the pipeline; it no longer actually dispatches class ClientPipeline: def __init__(self, packer, dispatcher, receiver, interpreter): self.pipe = rcompose( packer, dispatcher, receiver, interpreter, flatten, # each analysis call returns an iterable. Can be empty, singleton or multi item. Hence, flatten. ) def __call__(self, *args, **kwargs): yield from self.pipe(*args, **kwargs)