module documentation

Undocumented

Class ExceptionTrap A context manager that will catch certain exceptions and provide an indication they occurred.
Class on_interrupt Replace a KeyboardInterrupt with SystemExit(1)
Class suppress A version of contextlib.suppress with decorator support.
Function infer_compression Given a URL or filename, infer the compression code for tar.
Function null A null context suitable to stand in for a meaningful context.
Function pushd >>> tmp_path = getfixture('tmp_path') >>> with pushd(tmp_path): ... assert os.getcwd() == os.fspath(tmp_path) >>> assert os.getcwd() != os.fspath(tmp_path)
Function repo_context Check out the repo indicated by url.
Function tarball_context Get a tarball, extract it, change to that directory, yield, then clean up. `runner` is the function to invoke commands. `pushd` is a context manager for changing the directory.
Function temp_dir Create a temporary directory context. Pass a custom remover to override the removal behavior.
def infer_compression(url): (source)

Given a URL or filename, infer the compression code for tar. >>> infer_compression('http://foo/bar.tar.gz') 'z' >>> infer_compression('http://foo/bar.tgz') 'z' >>> infer_compression('file.bz') 'j' >>> infer_compression('file.xz') 'J'

A null context suitable to stand in for a meaningful context. >>> with null() as value: ... assert value is None

>>> tmp_path = getfixture('tmp_path') >>> with pushd(tmp_path): ... assert os.getcwd() == os.fspath(tmp_path) >>> assert os.getcwd() != os.fspath(tmp_path)

@contextlib.contextmanager
def repo_context(url, branch=None, quiet=True, dest_ctx=temp_dir): (source)

Check out the repo indicated by url. If dest_ctx is supplied, it should be a context manager to yield the target directory for the check out.

@contextlib.contextmanager
def tarball_context(url, target_dir=None, runner=None, pushd=pushd): (source)

Get a tarball, extract it, change to that directory, yield, then clean up. `runner` is the function to invoke commands. `pushd` is a context manager for changing the directory.

Create a temporary directory context. Pass a custom remover to override the removal behavior. >>> import pathlib >>> with temp_dir() as the_dir: ... assert os.path.isdir(the_dir) ... _ = pathlib.Path(the_dir).joinpath('somefile').write_text('contents') >>> assert not os.path.exists(the_dir)