
    n&phP%                    B   S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
rS SKrS SKJr  \R                  S:  a  S SKJr  OS SKr\R$                  SS j5       r\R$                   S   SS jj5       r    SS jrS	 r\" \\5      r\R$                  S
 5       rS r\R$                  \R4                  4S j5       r\R$                  SS\4S j5       rS r " S S5      r " S S\R>                  \R@                  5      r " S S\R@                  5      r!g)    )annotationsN)Iterator)      )tarfilec              #     #    [         R                  " 5       n[         R                  " U 5         U v   [         R                  " U5        g! [         R                  " U5        f = f7f)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)osgetcwdchdir)dirorigs     T/var/www/html/venv/lib/python3.13/site-packages/setuptools/_vendor/jaraco/context.pypushdr      s=      99;DHHSM	
s   ,A%A
 A%
A""A%c              #    #    Uc?  [         R                  R                  U 5      R                  SS5      R                  SS5      n[         R                  " U5         [
        R                  R                  U 5      n[        R                  " USS9 nUR                  U[        S9  SSS5        Uv   [        R                  " U5        g! , (       d  f       N)= f! [        R                  " U5        f = f7f)av  
Get a tarball, extract it, yield, then clean up.

>>> import urllib.request
>>> url = getfixture('tarfile_served')
>>> target = getfixture('tmp_path') / 'out'
>>> tb = tarball(url, target_dir=target)
>>> import pathlib
>>> with tb as extracted:
...     contents = pathlib.Path(extracted, 'contents.txt').read_text(encoding='utf-8')
>>> assert not os.path.exists(extracted)
Nz.tar.gz z.tgzzr|*)fileobjmode)pathfilter)r	   r   basenamereplacemkdirurllibrequesturlopenr   open
extractallstrip_first_componentshutilrmtree)url
target_dirreqtfs       r   tarballr%   '   s       WW%%c*229bAII&RTU

 HHZ"nn$$S)\\#E2bMMz2GMH 3j!	 32 	j!s6   AC44C C%C 1C4
CC C11C4c                L    U R                   R                  SS5      u  o l         U $ )N/   )namesplit)memberr   _s      r   r   r   G   s#     [[&&sA.NA{M    c                 H    S n[         R                  " U[        U 5      5      $ )aQ  
Compose any number of dependent context managers into a single one.

The last, innermost context manager may take arbitrary arguments, but
each successive context manager should accept the result from the
previous as a single parameter.

Like :func:`jaraco.functools.compose`, behavior works from right to
left, so the context manager should be indicated from outermost to
innermost.

Example, to create a context manager to change to a temporary
directory:

>>> temp_dir_as_cwd = _compose(pushd, temp_dir)
>>> with temp_dir_as_cwd() as dir:
...     assert os.path.samefile(os.getcwd(), dir)
c                @   ^ ^ U U4S jn[         R                  " U5      $ )Nc               ?     >#    T" U 0 UD6 nT" U5       nUv   S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f7fN )argskwargssavedresinnerouters       r   composed/_compose.<locals>.compose_two.<locals>.composedd   s8     ''5%,#	 3?'',,''s)   	A	<+<	A
9	<
A
A)
contextlibcontextmanager)r7   r8   r9   s   `` r   compose_two_compose.<locals>.compose_twoc   s    	 ((22r-   )	functoolsreducereversed)cmgrsr=   s     r   _composerC   O   s     (3 K%99r-   c               /     #    [         R                  " S[        SS9  UR                  S[        5      n[        U 0 UD6 o2" U5       nUv   S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f7f)NzBtarball_context is deprecated. Use tarball or tarball_cwd instead.   
stacklevelr   )warningswarnDeprecationWarningpopr   r%   )r3   r4   	pushd_ctxtballr   s        r   tarball_contextrN   p   sa     MML
 

7E*I	$	!&	!UIe,<	 -=	!	!,<,<	!	!s4   <A>A-AA-	A>
A*	&A--
A;7A>c                z    [         R                  " S[        SS9  U SS n[        SSSS	9nUR	                  US5      $ )
z
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'
z3infer_compression is deprecated with no replacementrE   rF   NzjJ)gzbzxz)rH   rI   rJ   dictget)r!   compression_indicatormappings      r   infer_compressionr[   |   sG     MM=  Hccc*G;;,c22r-   c              #  j   #    [         R                  " 5       n Uv   U " U5        g! U " U5        f = f7f)a@  
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', encoding='utf-8')
>>> assert not os.path.exists(the_dir)
N)tempfilemkdtemp)removertemp_dirs     r   r`   r`      s/      !Hs   3& 	3
03Tc              #  .  #    SU ;   a  SOSnU" 5        nUSX/nU(       a  UR                  SU/5        [        [        R                  R                  S5      nU(       a  UOSn[
        R                  " XhS9  Uv   SSS5        g! , (       d  f       g= f7f)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.
githgclonez--branchwN)stdout)extendr   r	   r   devnull
subprocess
check_call)	r!   branchquietdest_ctxexerepo_dircmdrh   rf   s	            r   repo_contextrq      st      C<%TC	xGS+JJ
F+,rww,!tc1 
s   BA'B;	B
BBc                 `    [         R                  " S[        SS9  [        R                  " 5       $ )a(  
A null context suitable to stand in for a meaningful context.

>>> with null() as value:
...     assert value is None

This context is most useful when dealing with two or more code
branches but only some need a context. Wrap the others in a null
context to provide symmetry across all options.
z.null is deprecated. Use contextlib.nullcontextrE   rF   )rH   rI   rJ   r;   nullcontextr2   r-   r   nullrt      s*     MM8
 !!##r-   c                      \ rS rSrSrSr\44S jrS r\	S 5       r
\	S 5       r\	S 5       rS	 rS
 r\S.S jrS rSrg)ExceptionTrap   aA  
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
>>> trap.value
ValueError('1 + 1 is not 3')
>>> trap.tb
<traceback object at ...>

>>> with ExceptionTrap(ValueError) as trap:
...     raise Exception()
Traceback (most recent call last):
...
Exception

>>> bool(trap)
False
)NNNc                    Xl         g r1   )
exceptions)selfry   s     r   __init__ExceptionTrap.__init__   s    $r-   c                    U $ r1   r2   rz   s    r   	__enter__ExceptionTrap.__enter__       r-   c                     U R                   S   $ Nr   exc_infor~   s    r   typeExceptionTrap.type       }}Qr-   c                     U R                   S   $ )Nr(   r   r~   s    r   valueExceptionTrap.value   r   r-   c                     U R                   S   $ )NrE   r   r~   s    r   tbExceptionTrap.tb   r   r-   c                f    US   nU=(       a    [        X R                  5      nU(       a  Xl        U$ r   )
issubclassry   r   )rz   r   r   matchess       r   __exit__ExceptionTrap.__exit__  s+    {<:dOO<$Mr-   c                ,    [        U R                  5      $ r1   )boolr   r~   s    r   __bool__ExceptionTrap.__bool__  s    DIIr-   _testc               N   ^ ^^ [         R                  " T5      UUU 4S j5       nU$ )aQ  
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R                  5       nT" U 0 UD6  S S S 5        T" W5      $ ! , (       d  f       N= fr1   )rv   ry   )r3   r4   trapr   funcrz   s      r   wrapper%ExceptionTrap.raises.<locals>.wrapper!  s6    t/4d%f% 0; 0/s   	0
>)r?   wraps)rz   r   r   r   s   ``` r   raisesExceptionTrap.raises  s'    & 
		 
	
 r-   c                >    U R                  U[        R                  S9$ )aJ  
Wrap func and replace the result with the truth
value of the trap (True if no exception).

First, give the decorator an alias to support Python 3.8
Syntax.

>>> passes = ExceptionTrap(ValueError).passes

Now decorate a function that always fails.

>>> @passes
... def fail():
...     raise ValueError('failed')

>>> fail()
False
r   )r   operatornot_)rz   r   s     r   passesExceptionTrap.passes)  s    & {{4x}}{55r-   )r   ry   N)__name__
__module____qualname____firstlineno____doc__r   	Exceptionr{   r   propertyr   r   r   r   r   r   r   r   __static_attributes__r2   r-   r   rv   rv      ss    B  H#,, %             %) 66r-   rv   c                      \ rS rSrSrSrg)suppressi?  z
A version of contextlib.suppress with decorator support.

>>> @suppress(KeyError)
... def key_error():
...     {}['']
>>> key_error()
r2   N)r   r   r   r   r   r   r2   r-   r   r   r   ?  s    r-   r   c                  .    \ rS rSrSrSS jrS rS rSrg)	on_interruptiJ  a  
Replace a KeyboardInterrupt with SystemExit(1)

>>> def do_interrupt():
...     raise KeyboardInterrupt()
>>> on_interrupt('error')(do_interrupt)()
Traceback (most recent call last):
...
SystemExit: 1
>>> on_interrupt('error', code=255)(do_interrupt)()
Traceback (most recent call last):
...
SystemExit: 255
>>> on_interrupt('suppress')(do_interrupt)()
>>> with __import__('pytest').raises(KeyboardInterrupt):
...     on_interrupt('ignore')(do_interrupt)()
c                   Xl         X l        g r1   actioncode)rz   r   r   s      r   r{   on_interrupt.__init__]  s    	r-   c                    U $ r1   r2   r~   s    r   r   on_interrupt.__enter__a  r   r-   c                    U[         Ld  U R                  S:X  a  g U R                  S:X  a  [        U R                  5      UeU R                  S:H  $ )Nignoreerrorr   )KeyboardInterruptr   
SystemExitr   )rz   exctypeexcinstexctbs       r   r   on_interrupt.__exit__d  sE    ++t{{h/F[[G#TYY'W4{{j((r-   r   N)r   r(   )	r   r   r   r   r   r{   r   r   r   r2   r-   r   r   r   J  s    $)r-   r   )r   zstr | os.PathLikereturnIterator[str | os.PathLike]r1   )r"   zstr | os.PathLike | Noner   r   )r+   tarfile.TarInfor   r   )"
__future__r   r;   r?   r   r	   r   ri   sysr]   urllib.requestr   rH   typingr   version_info	backportsr   r<   r   r%   r   rC   tarball_cwdrN   r[   r    r`   rq   rt   rv   r   ContextDecoratorr   r2   r-   r   <module>r      sO   "    	   
     g!    04"-" " "> :< ug&  32 ]]  $ !  $$&n6 n6bz""J$?$? ):.. )r-   