pip install dotchain
Call .Result() to get the value.
value=DotChain(data|iterable).method().property.Result()Do not call .Result() when using await.
value=awaitDotChain(data|iterable).method().propertyNOTE: Must be in an event loop to use
await.
Pipe can be called anywhere in the chain to start piping the data.
Chain can be called anywhere in the chain to start chaining the data again.
# Pipingvalue=DotChain(data|iterable).Pipe.method().other_method().Result()
# Chaining and Pipingvalue=DotChain(data|iterable).method().property.Pipe.other_method().Chain.property.Result()Contexts can be provided to resolve methods and properties so they can be used inline.
With can be called anywhere in the chain to add or clear contexts.
importutils# contains `log(...)`value=DotChain(data|iterable).With(utils).method().log().Result()
value=DotChain(data|iterable).With({'utils': utils}).method().utils.log().Result()
value=DotChain(data|iterable).With(self).method().utils.log().Result()value=DotChain(data|iterable).method().Call(lambdaitem: item.property).Result()fromdotchainimportDotChainimportlog_utils# Chainingorder=DotChain(user).get_order('123').cancel().Result()
# Chaining with Pipingemail_result=DotChain(user).get_order('123').cancel().Pipe.send_email().Result()
# With lookup contextsorder=DotChain(user).With(log_utils).get_order('123').cancel().Pipe.log_cancel().Result()
order=DotChain(user).With({'log_it': lambdaorder: log_utils.log_cancel(order)}).Pipe.log_it().Result()
# Inline callablesorder=DotChain(user).get_order('123').cancel().Pipe.Call(lambdaorder: log_utils.log_cancel(order)).Result()See Tests for more examples and usage.