
    j$                     |   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZej        d             Z	ej        dde	fd            Z
d Zej        ej        fd            Zej        ddefd            Zej        d             Z G d	 d
          Z G d dej        ej                  Z G d dej                  ZdS )    Nc              #      K   t          j                    }t          j        |            	 | V  t          j        |           dS # t          j        |           w xY w)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     P/opt/deyu/venv/lib/python3.11/site-packages/setuptools/_vendor/jaraco/context.pypushdr
      sQ       9;;DHSMMM			
s   A Ac           
   #     K   |Gt           j                            |                               dd                              dd          }|!t	          j        t          j        d          }nt          j	        dt                      | dj        di t                                 	 d	}d
}d                    ||f          } | |j        ddt          |           it                                  ||          5  |V  ddd           n# 1 swxY w Y    | dj        di t                                 dS #  | dj        di t                                 w xY 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)shellzrunner parameter is deprecatedzmkdir {target_dir}zwget {url} -O -z7tar x{compression} --strip-components=1 -C {target_dir}z | compressionzrm -Rf {target_dir} )r   pathbasenamereplace	functoolspartial
subprocess
check_callwarningswarnDeprecationWarningformatvarsjoininfer_compression)url
target_dirrunnerr
   getterextractcmds          r	   tarball_contextr$      s      W%%c**229bAAII&RTUU
~":#8EEE68JKKK
 F&&00001117"Kjj&'*++zszGG&7&<&<GGGHHHU: 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	+$+55dff5566666+$+55dff556666s1   ,AE DE DE DE $E'c                 f    | dd         }t          ddd          }|                    |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'
    NzjJ)gzbzxz)dictget)r   compression_indicatormappings      r	   r   r   :   s;      Hccc***G;;,c222    c              #   p   K   t          j                    }	 |V   | |           dS #  | |           w xY w)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)tempfilemkdtemp)removertemp_dirs     r	   r6   r6   N   sP       !!Hs   ( 5Tc              #     K   d| v rdnd} |            5 }|d| |g}|r|                     d|g           t          t          j        j        d          }|r|nd}t          j        ||           |V  ddd           dS # 1 swxY w Y   dS )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)extendopenr   r   devnullr   r   )	r   branchquietdest_ctxexerepo_dirr#   r?   r<   s	            r	   repo_contextrE   a   s       C<<%%TC	 xGS(+ 	-JJ
F+,,,rw,,!+tc&1111                 s   ABBBc               #      K   dV  dS )z
    A null context suitable to stand in for a meaningful context.

    >>> with null() as value:
    ...     assert value is None
    Nr   r   r1   r	   nullrG   t   s       
EEEEEr1   c                       e Zd ZdZdZeffdZd Zed             Z	ed             Z
ed             Zd Zd	 Zed
dZd ZdS )ExceptionTrapa  
    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                     || _         d S N)
exceptions)selfrL   s     r	   __init__zExceptionTrap.__init__   s    $r1   c                     | S rK   r   rM   s    r	   	__enter__zExceptionTrap.__enter__       r1   c                     | j         d         S Nr   exc_inforP   s    r	   typezExceptionTrap.type       }Qr1   c                     | j         d         S )N   rU   rP   s    r	   valuezExceptionTrap.value   rX   r1   c                     | j         d         S )N   rU   rP   s    r	   tbzExceptionTrap.tb   rX   r1   c                 V    |d         }|ot          || j                  }|r|| _        |S rT   )
issubclassrL   rV   )rM   rV   rW   matchess       r	   __exit__zExceptionTrap.__exit__   s5    {<:dDO<< 	%$DMr1   c                 *    t          | j                  S rK   )boolrW   rP   s    r	   __bool__zExceptionTrap.__bool__   s    DIr1   _testc                N     t          j                   fd            }|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 swxY w Y    |          S rK   )rI   rL   )argskwargstraprg   funcrM   s      r	   wrapperz%ExceptionTrap.raises.<locals>.wrapper   s    t// &4d%f%%%& & & & & & & & & & & & & & &5;;s   	+//)r   wraps)rM   rm   rg   rn   s   ``` r	   raiseszExceptionTrap.raises   sF    & 
			 	 	 	 	 	 
		
 r1   c                 D    |                      |t          j                  S )a  
        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
        rf   )rp   operatornot_)rM   rm   s     r	   passeszExceptionTrap.passes   s    & {{4x}{555r1   N)__name__
__module____qualname____doc__rV   	ExceptionrN   rQ   propertyrW   r[   r^   rb   re   rd   rp   rt   r   r1   r	   rI   rI      s         B  H#,, % % % %       X      X      X      %)     66 6 6 6 6r1   rI   c                       e Zd ZdZdS )suppressz
    A version of contextlib.suppress with decorator support.

    >>> @suppress(KeyError)
    ... def key_error():
    ...     {}['']
    >>> key_error()
    N)ru   rv   rw   rx   r   r1   r	   r|   r|      s           r1   r|   c                   *    e Zd ZdZ	 	 ddZd Zd ZdS )	on_interrupta  
    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)()
    errorrZ   c                 "    || _         || _        d S rK   )actioncode)rM   r   r   s      r	   rN   zon_interrupt.__init__  s     			r1   c                     | S rK   r   rP   s    r	   rQ   zon_interrupt.__enter__  rR   r1   c                     |t           us| j        dk    rd S | j        dk    rt          | j                  || j        dk    S )Nignorer   r|   )KeyboardInterruptr   
SystemExitr   )rM   exctypeexcinstexctbs       r	   rb   zon_interrupt.__exit__  sK    +++t{h/F/FF[G##TY''W4{j((r1   N)r   rZ   )ru   rv   rw   rx   rN   rQ   rb   r   r1   r	   r~   r~      sZ         (       ) ) ) ) )r1   r~   )r   r   
contextlibr   r3   shutilrr   r   contextmanagerr
   r$   r   rmtreer6   rE   rG   rI   r|   ContextDecoratorr~   r   r1   r	   <module>r      s   				                     $(U 7 7 7 7:3 3 3( ]    $ !    $ 
 
 
n6 n6 n6 n6 n6 n6 n6 n6b    z"J$?   %) %) %) %) %):. %) %) %) %) %)r1   