,Re, N d dl Z d dlZd dlZd dlZd dlZd dlZd dlZej d Zej ddefd Z d Z
ej ej fd Zej ddefd Z
ej d Z G d d
Z G d dej ej ZdS )
Nc # K t j }t j | | V t j | d S # t j | w xY wN)osgetcwdchdir)dirorigs /builddir/build/BUILDROOT/alt-python311-setuptools-65.6.3-2.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pkg_resources/_vendor/jaraco/context.pypushdr
sO
9;;DHSMMM
s A Ac
# K |Gt j | dd dd }| t j t j d } | dj d
i t d}d }d
||f } | |j d
dt | it || 5 |V ddd n# 1 swxY w Y | dj d
i t dS # | dj d
i t w xY w)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)shellzmkdir {target_dir}zwget {url} -O -z7tar x{compression} --strip-components=1 -C {target_dir}z | compressionzrm -Rf {target_dir} )r pathbasenamereplace functoolspartial
subprocess
check_callformatvarsjoininfer_compression)url
target_dirrunnerr getterextractcmds r
tarball_contextr" s W%%c**229bAAII&RTUU
~":#8EEE
F&&00001117"Kjj&'*++zszGG&7&<&<GGGHHH
U:
+$+55dff5566666+$+55dff556666s1 AD( (C9-D( 9C==D( C=D( ($Ec f | dd }t ddd }| |d S )zF
Given a URL or filename, infer the compression code for tar.
NzjJ)gzbzxz)dictget)r compression_indicatormappings r
r r 0 s;
Hccc***G;;,c222 c # p K t j } |V | | dS # | | w xY w)zk
Create a temporary directory context. Pass a custom remover
to override the removal behavior.
N)tempfilemkdtemp)removertemp_dirs r
r4 r4 ; sP !!Hs (
5Tc # K d| v rdnd} | 5 }|d| |g}|r| d|g t t j j d }|r|nd}t j || |V ddd dS # 1 swxY w Y dS )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: s r
repo_contextrC H s C<<%%TC xGS(+ -JJ
F+,,,rw,,!+tc&1111 s ABBBc # K d V d S r r r r/ r
nullrE [ s EEEEEr/ c e Zd ZdZdZeffdZd Zed Z ed Z
ed Zd Zd Z
ed
dZd Zd
S )
ExceptionTrapaG
A context manager that will catch certain exceptions and provide an
indication they occurred.
>>> with ExceptionTrap() as trap:
... raise Exception()
>>> bool(trap)
True
>>> with ExceptionTrap() as trap:
... pass
>>> bool(trap)
False
>>> with ExceptionTrap(ValueError) as trap:
... raise ValueError("1 + 1 is not 3")
>>> bool(trap)
True
>>> with ExceptionTrap(ValueError) as trap:
... raise Exception()
Traceback (most recent call last):
...
Exception
>>> bool(trap)
False
)NNNc || _ d S r )
exceptions)selfrI s r
__init__zExceptionTrap.__init__ s
$r/ c | S r r rJ s r
__enter__zExceptionTrap.__enter__ s r/ c | j d S Nr exc_inforM s r
typezExceptionTrap.type }Qr/ c | j d S )N rQ rM s r
valuezExceptionTrap.value rT r/ c | j d S )N rQ rM s r
tbzExceptionTrap.tb rT r/ c V |d }|ot || j }|r|| _ |S rP )
issubclassrI rR )rJ rR rS matchess r
__exit__zExceptionTrap.__exit__ s5 {<:dDO<< %$DMr/ c * t | j S r )boolrS rM s r
__bool__zExceptionTrap.__bool__ s DIr/ _testc N t j fd }|S )a
Wrap func and replace the result with the truth
value of the trap (True if an exception occurred).
First, give the decorator an alias to support Python 3.8
Syntax.
>>> raises = ExceptionTrap(ValueError).raises
Now decorate a function that always fails.
>>> @raises
... def fail():
... raise ValueError('failed')
>>> fail()
True
c t j 5 } | i | d d d n# 1 swxY w Y | S r )rG rI )argskwargstraprc funcrJ s r
wrapperz%ExceptionTrap.raises.