Skip to main content

DotChain - Python method chaining and piping with asyncio support.

Install

pip install dotchain

Usage

Chain Synchronously

Call .Result() to get the value.

value = DotChain(data | iterable).method().property.Result()

Chain Asynchronously

Do not call .Result() when using await.

value = await DotChain(data | iterable).method().property

NOTE: Must be in an event loop to use await.

Piping

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.

# Piping
value = DotChain(data | iterable).Pipe.method().other_method().Result()

# Chaining and Piping
value = DotChain(data | iterable).method().property.Pipe.other_method().Chain.property.Result()

Contexts

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.

import utils  # 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()

Call inline functions

value = DotChain(data | iterable).method().Call(lambda item: item.property).Result()

Examples

from dotchain import DotChain
import log_utils

# Chaining
order = DotChain(user).get_order('123').cancel().Result()

# Chaining with Piping
email_result = DotChain(user).get_order('123').cancel().Pipe.send_email().Result()

# With lookup contexts
order = DotChain(user).With(log_utils).get_order('123').cancel().Pipe.log_cancel().Result()

order = DotChain(user).With({'log_it': lambda order: log_utils.log_cancel(order)}).Pipe.log_it().Result()

# Inline callables
order = DotChain(user).get_order('123').cancel().Pipe.Call(lambda order: log_utils.log_cancel(order)).Result()

See Tests for more examples and usage.

Metadata

Release files for dotchain 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dotchain 0.0.1
File Size Uploaded Provenance Actions
dotchain-0.0.1.tar.gz 7.4 kB Without provenance Details for dotchain-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dotchain 0.0.1
File Interpreter ABI Platform Actions
dotchain-0.0.1-py3-none-any.whl Python 3 none any Details for dotchain-0.0.1-py3-none-any.whl

Total release size: 15.7 kB

Release files / dotchain-0.0.1.tar.gz

Download URL dotchain-0.0.1.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1300d893588c3291d0d7661c2b7c4038892a3246608515332de15018904e9e8f
BLAKE2b-256 checksum
How to use checksums
9a1ca293ca6c3f7cb6650b1838c923c71d52d5d123db30b7019e56d2bc295886
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / dotchain-0.0.1-py3-none-any.whl

Download URL dotchain-0.0.1-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c390b1a25285359f119ec3bd6678608d3b4b0f6535f7f4d2faac60fb5a05cd4f
BLAKE2b-256 checksum
How to use checksums
392ea8202a908ac724ce2535f11c9722fe0fa020d99fcc5e0569a18e25f28177
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Security for dotchain 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page