Skip to content

Commit

Permalink
Renamed tarball_context to tarball and deprecated tarball_context com…
Browse files Browse the repository at this point in the history
…patibility shim.

Closes #3
  • Loading branch information
jaraco committed Apr 4, 2024
1 parent 0bc75c2 commit dde5ba4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/Lucretiel/autocommand/issues/18>`_.
- ``pushd`` is similar to pytest's ``monkeypatch.chdir`` or path's `default context <https://path.readthedocs.io/en/latest/api.html>`_, 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.


Expand Down
11 changes: 10 additions & 1 deletion jaraco/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions newsfragments/3.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Renamed tarball_context to tarball and deprecated tarball_context compatibility shim.

0 comments on commit dde5ba4

Please sign in to comment.