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-6.0.1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

jaraco.context-6.0.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file jaraco_context-6.0.1.tar.gz.

File metadata

  • Download URL: jaraco_context-6.0.1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for jaraco_context-6.0.1.tar.gz
Algorithm Hash digest
SHA256 9bae4ea555cf0b14938dc0aee7c9f32ed303aa20a3b73e7dc80111628792d1b3
MD5 bb22ef027077b1fa8528ef1d9840b838
BLAKE2b-256 dfadf3777b81bf0b6e7bc7514a1656d3e637b2e8e15fab2ce3235730b3e7a4e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for jaraco.context-6.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f797fc481b490edb305122c9181830a3a5b76d84ef6d1aef2fb9b47ab956f9e4
MD5 f6457686dc21f042213377525b94640b
BLAKE2b-256 ffdb0c52c4cf5e4bd9f5d7135ec7669a3a767af21b3a308e1ed3674881e52b62

See more details on using hashes here.

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