Skip to main content

Useful decorators and context managers

Project description

https://img.shields.io/pypi/v/jaraco.context.svg https://img.shields.io/pypi/pyversions/jaraco.context.svg tests Ruff https://readthedocs.org/projects/jaracocontext/badge/?version=latest https://img.shields.io/badge/skeleton-2024-informational https://tidelift.com/badges/package/pypi/jaraco.context

Highlights

See the docs linked from the badge above for the full details, but here are some features that may be of interest.

  • ExceptionTrap provides a general-purpose wrapper for trapping exceptions and then acting on the outcome. Includes passes and raises decorators to replace the result of a wrapped function by a boolean indicating the outcome of the exception trap. See this keyring commit for an example of it in production.

  • suppress simply enables contextlib.suppress as a decorator.

  • on_interrupt is a decorator used by CLI entry points to affect the handling of a KeyboardInterrupt. Inspired by Lucretiel/autocommand#18.

  • pushd is similar to pytest’s monkeypatch.chdir or path’s default context, changes the current working directory for the duration of the context.

  • tarball will download a tarball, extract it, change directory, yield, then clean up after. Convenient when working with web assets.

  • null is there for those times when one code branch needs a context and the other doesn’t; this null context provides symmetry across those branches.

For Enterprise

Available as part of the Tidelift Subscription.

This project and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use.

Learn more.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jaraco.context-5.3.0.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

jaraco.context-5.3.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file jaraco.context-5.3.0.tar.gz.

File metadata

  • Download URL: jaraco.context-5.3.0.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for jaraco.context-5.3.0.tar.gz
Algorithm Hash digest
SHA256 c2f67165ce1f9be20f32f650f25d8edfc1646a8aeee48ae06fb35f90763576d2
MD5 e876ac2f03352e21f59878702ceb26d8
BLAKE2b-256 c960e83781b07f9a66d1d102a0459e5028f3a7816fdd0894cba90bee2bbbda14

See more details on using hashes here.

Provenance

File details

Details for the file jaraco.context-5.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for jaraco.context-5.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3e16388f7da43d384a1a7cd3452e72e14732ac9fe459678773a3608a812bf266
MD5 3e718bbdfc9dcaeac1e53aae95467d15
BLAKE2b-256 d24011b7bc1898cf1dcb87ccbe09b39f5088634ac78bb25f3383ff541c2b40aa

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page