_i$ d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZej d Z ej dde fd Z d Zej ej fd Z ej dde fd Zej d Z G d d Z G d dej" ej$ Z G d dej$ Zy) Nc # K t j }t j | | t j | y# t j | w xY ww)z >>> tmp_path = getfixture('tmp_path') >>> with pushd(tmp_path): ... assert os.getcwd() == os.fspath(tmp_path) >>> assert os.getcwd() != os.fspath(tmp_path) N)osgetcwdchdir)dirorigs /builddir/build/BUILDROOT/alt-python312-setuptools-69.0.2-3.el8.x86_64/opt/alt/python312/lib/python3.12/site-packages/pkg_resources/_vendor/jaraco/context.pypushdr s> 99;DHHSM s *A!A A!AA!c # K |?t j j | j dd j dd }|&t j t j d }nt j dt | dj di t d }d }dj ||f } | |j ddt | it || 5 | ddd | d j di t y# 1 sw Y *xY w# | d j di t w xY ww)z 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. Nz.tar.gz z.tgzT)shellzrunner parameter is deprecatedzmkdir {target_dir}zwget {url} -O -z7tar x{compression} --strip-components=1 -C {target_dir}z | compressionzrm -Rf {target_dir} )r pathbasenamereplace functoolspartial subprocess check_callwarningswarnDeprecationWarningformatvarsjoininfer_compression)url target_dirrunnerr getterextractcmds r tarball_contextr$ s% WW%%c*229bAII&RTU ~"":#8#8E 68JK &&&0017"Kjj&'*+zszzG&7&<GGH : +$++5df56 +$++5df56s7 B$E'A D+ 1D6D+ >!ED($D+ +"E Ec L | dd }t ddd }|j |d S )a 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' NzjJ)gzbzxz)dictget)r compression_indicatormappings r r r : s0 Hccc*G;;,c22 c # h K t j } | | | y# | | w xY ww)aN 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) N)tempfilemkdtemp)removertemp_dirs r r6 r6 N s0 !Hs 2% 2 /2Tc # K d| v rdnd} | 5 }|d| |g}|r|j d|g t t j j d }|r|nd}t j || | ddd y# 1 sw Y yxY ww)z 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. githgclonez--branchwN)stdout)extendopenr r devnullr r ) r branchquietdest_ctxexerepo_dirr# r? r<