From dde5ba45eabd10fe46d86541bd4ec75beba6d40d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 4 Apr 2024 14:19:18 -0400 Subject: [PATCH] Renamed tarball_context to tarball and deprecated tarball_context compatibility shim. Closes #3 --- README.rst | 2 +- jaraco/context.py | 11 ++++++++++- newsfragments/3.feature.rst | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 newsfragments/3.feature.rst diff --git a/README.rst b/README.rst index df60e62..1dedb0b 100644 --- a/README.rst +++ b/README.rst @@ -30,7 +30,7 @@ See the docs linked from the badge above for the full details, but here are some - ``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_context`` will download a tarball, extract it, change directory, yield, then clean up after. Convenient when working with web assets. +- ``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. diff --git a/jaraco/context.py b/jaraco/context.py index 5b978dd..7b298df 100644 --- a/jaraco/context.py +++ b/jaraco/context.py @@ -26,7 +26,7 @@ def pushd(dir): @contextlib.contextmanager -def tarball_context(url, target_dir=None, pushd=pushd): +def tarball(url, target_dir=None, pushd=pushd): """ Get a tarball, extract it, change to that directory, yield, then clean up. @@ -51,6 +51,15 @@ def tarball_context(url, target_dir=None, pushd=pushd): runner('rm -Rf {target_dir}'.format(**vars())) +def tarball_context(*args, **kwargs): + warnings.warn( + "tarball_context is deprecated. Use tarball instead.", + DeprecationWarning, + stacklevel=2, + ) + return tarball(*args, **kwargs) + + def infer_compression(url): """ Given a URL or filename, infer the compression code for tar. diff --git a/newsfragments/3.feature.rst b/newsfragments/3.feature.rst new file mode 100644 index 0000000..5c7ff4b --- /dev/null +++ b/newsfragments/3.feature.rst @@ -0,0 +1 @@ +Renamed tarball_context to tarball and deprecated tarball_context compatibility shim. \ No newline at end of file