+
     hP%  c                  s<   ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t^ RIt^ RIHt ]P                  R8  d   ^ RIHt M^ RIt]P$                  R R l4       t]P$                  RR R ll4       tR	 R
 ltR t]! ]]4      t]P$                  R 4       tR t]P$                  ]P4                  3R l4       t]P$                  RR]3R l4       tR t ! R R4      t ! R R]P>                  ]P@                  4      t ! R R]P@                  4      t!R# )    )annotationsN)Iterator)tarfilec                    V ^8  d   QhRRRR/# )   dirzstr | os.PathLikereturnIterator[str | os.PathLike] Zformat   "F/usr/lib/python3.14/site-packages/setuptools/_vendor/jaraco/context.py__annotate__r      s        %@     c              #  s   "   \         P                  ! 4       p\         P                  ! V 4        V x  \         P                  ! V4       R#   \         P                  ! T4       i ; i5i)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)osZgetcwdZchdir)r   Zorig   & r   pushdr      s=      99;DHHSM	
s   ,A&A A&A##A&c               r   )r   
target_dirzstr | os.PathLike | Noner   r   r	   r
   r   r   r   r   (   s     " "-" "r   c              #  s  "   Vf@   \         P                  P                  V 4      P                  RR4      P                  RR4      p\         P                  ! V4        \
        P                  P                  V 4      p\        P                  ! VRR7      ;_uu_ 4       pVP                  V\        R7       RRR4       Vx  \        P                  ! V4       R#   + '       g   i     L,; i  \        P                  ! T4       i ; i5i)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.gzZ z.tgzzr|*)ZfileobjZmode)pathZfilter)r   r   ZbasenameZreplaceZmkdirurllibZrequestZurlopenr   openZ
extractallstrip_first_componentshutilrmtree)urlr   ZreqZtfs   &&  r   tarballr   '   s       WW%%c*229bAII&RTU

 HHZ"nn$$S)\\#E22bMMz2GMH 3j!	 32 	j!s6   AD?C+ C4C+  DC(	#C+ +DDc               s     V ^8  d   QhRRRR/# )r   memberztarfile.TarInfor   r	   r
   r   r   r   r   G   s       r   c                sL    V P                   P                  R ^4      w  q n         V # )Z/)ZnameZsplit)r   r   Z_s   && r   r   r   G   s#     [[&&sA.NA{Mr   c                 sH    R p\         P                  ! V\        V 4      4      # )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                s@   a a V V3R  lp\         P                  ! V4      # )c            	   ?  s   <"   S! V / VB ;_uu_ 4       pS! V4      ;_uu_ 4       pVx  R R R 4       R R R 4       R #   + '       g   i     L; i  + '       g   i     R # ; i5iNr	   )argskwargsZsavedZresinnerouters   *,  r   composedZ/_compose.<locals>.compose_two.<locals>.composedd   s@     '''5%,,#	 3?'',,'''s/   A#A<	A
A#AAA 		A#)
contextlibcontextmanager)r   r    r!   s   ff r   compose_twoZ_compose.<locals>.compose_twoc   s    	 ((22r   )	functoolsZreduceZreversed)Zcmgrsr$   s   * r   _composer&   O   s     (3 K%99r   c            	   /  s2  "   \         P                  ! R \        ^R7       VP                  R\        4      p\        V / VB ;_uu_ 4       q2! V4      ;_uu_ 4       pVx  RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i5i)zBtarball_context is deprecated. Use tarball or tarball_cwd instead.Z
stacklevelr   N)warningswarnDeprecationWarningZpopr   r   )r   r   Z	pushd_ctxZtballr   s   *,   r   tarball_contextr+   p   sj     MML
 

7E*I	$	!&	!	!UIe,<,<	 -=	!	!,<,<	!	!	!s6   AB	BA0	B&
B0B ;BB		Bc                s    \         P                  ! R\        ^R7       V RR p\        RRRR7      pVP	                  VR4      # )	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 replacementr'   NZzZjZJ)ZgzZbzZxzi)r(   r)   r*   ZdictZget)r   Zcompression_indicatorZmappings   &  r   infer_compressionr,   |   sG     MM=  Hccc*G;;,c22r   c              #  sl   "   \         P                  ! 4       p Vx  V ! V4       R#   T ! T4       i ; i5i)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)tempfileZmkdtemp)Zremovertemp_dirr   r   r.   r.      s/      !Hs   4' 
4
14Tc              #  sR  "   RV 9   d   RMRpV! 4       ;_uu_ 4       pVRW.pV'       d   VP                  RV.4       \        \        P                  P                  R4      pV'       d   TMRp\
        P                  ! WhR7       Vx  RRR4       R#   + '       g   i     R# ; i5i)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.
ZgitZhgZclonez--branchZwN)stdout)Zextendr   r   r   devnull
subprocessZ
check_call)	r   ZbranchZquietZdest_ctxZexeZrepo_dirZcmdr0   r/   s	   &&&&     r   repo_contextr2      sx      C<%TC	xGS+JJ
F+,rww,!tc1 
s   B'A,B	
B'B$		B'c                 sf    \         P                  ! R\        ^R7       \        P                  ! 4       # )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.nullcontextr'   )r(   r)   r*   r"   Znullcontextr	   r   r   nullr3      s*     MM8
 !!##r   c                  s    ] tR t^tRtRt]33R ltR t]	R 4       t
]	R 4       t]	R 4       tR tR	 tR
]/R ltR tRtR# )ExceptionTrapaA  
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
Nc                	s    Wn         R # r   )
exceptions)selfr5      &&r   __init__ZExceptionTrap.__init__   s    $r   c                	    V # r   r	   r6      &r   	__enter__ZExceptionTrap.__enter__       r   c                	s(    V P                   ^ ,          # r    exc_infor:   r;   r   typeZExceptionTrap.type       }}Qr   c                	s(    V P                   ^,          # )   r?   r:   r;   r   valueZExceptionTrap.value   rB   r   c                	s(    V P                   ^,          # )r   r?   r:   r;   r   tbZExceptionTrap.tb   rB   r   c                	sr    V^ ,          pT;'       d    \        W P                  4      pV'       d   Wn        V# r>   )Z
issubclassr5   r@   )r6   r@   rA   Zmatchess   &*  r   __exit__ZExceptionTrap.__exit__  s.    {<<:dOO<$Mr   c                	s,    \        V P                  4      # r   )boolrA   r:   r;   r   __bool__ZExceptionTrap.__bool__  s    DIIr   _testc               sN   a aa \         P                  ! S4      VVV 3R l4       pV# )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                 s   < \        SP                  4      ;_uu_ 4       pS! V / VB  R R R 4       S! X4      #   + '       g   i     L; ir   )r4   r5   )r   r   ZtraprI   funcr6   s   *, r   wrapperZ%ExceptionTrap.raises.<locals>.wrapper!  s9    t//4d%f% 0; 0/s	   	8A	)r%   Zwraps)r6   rJ   rI   rK   s   ffd r   raisesZExceptionTrap.raises  s'    & 
		 
	
 r   c                sD    V P                  V\        P                  R7      # )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
)rI   )rL   operatorZnot_)r6   rJ   r7   r   passesZExceptionTrap.passes)  s    & {{4x}}{55r   )r@   r5   )NNN)__name__
__module____qualname____firstlineno____doc__r@   Z	Exceptionr8   r<   ZpropertyrA   rD   rE   rF   rH   rG   rL   rN   __static_attributes__r	   r   r   r4   r4      su    B  H#,, %            D 66r   r4   c                  s    ] tR tRtRtRtR# )suppressi?  z
A version of contextlib.suppress with decorator support.

>>> @suppress(KeyError)
... def key_error():
...     {}['']
>>> key_error()
r	   N)rO   rP   rQ   rR   rS   rT   r	   r   r   rU   rU   ?  s    r   rU   c                  s0    ] tR tRtRtRR ltR tR tRtR# )	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               	s    Wn         W n        R # r   actioncode)r6   rX   rY   s   ""&r   r8   Zon_interrupt.__init__]  s    	r   c                	r9   r   r	   r:   r;   r   r<   Zon_interrupt.__enter__a  r=   r   c                	s    V\         Jg   V P                  R 8X  d   R# V P                  R8X  d   \        V P                  4      VhV P                  R8H  # )ZignoreNerrorrU   )ZKeyboardInterruptrX   Z
SystemExitrY   )r6   ZexctypeZexcinstZexctbs   &&&&r   rF   Zon_interrupt.__exit__d  sE    ++t{{h/F[[G#TYY'W4{{j((r   rW   N)rZ   rC   )	rO   rP   rQ   rR   rS   r8   r<   rF   rT   r	   r   r   rV   rV   J  s    $)r   rV   )i   i   r   )"Z
__future__r   r"   r%   rM   r   r   r1   Zsysr-   Zurllib.requestr   r(   Ztypingr   Zversion_infoZ	backportsr   r#   r   r   r   r&   Ztarball_cwdr+   r,   r   r.   r2   r3   r4   rU   ZContextDecoratorrV   r	   r   r   <module>r[      s*   "    	   
     g!    " ">:< ug&  32 ]]  $ !  $$&n6 n6bz""J$?$? ):.. )r   