
    df,                     r   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y)    Nc              #      K   t        j                         }t        j                  |        	 |  t        j                  |       y # t        j                  |       w xY wwN)osgetcwdchdir)dirorigs     ]/home/api-vastappli/venv/lib/python3.12/site-packages/pkg_resources/_vendor/jaraco/context.pypushdr   
   s<     99;DHHSM	
s   *A!A A!AA!c           
   #   n  K   |?t         j                  j                  |       j                  dd      j                  dd      }|%t	        j
                  t        j                  d      } | dj                  di t                      	 d}d	}d
j                  ||f      } | |j                  ddt        |       it                       ||      5  | ddd        | dj                  di t                      y# 1 sw Y   *xY w#  | dj                  di t                      w xY w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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formatvarsjoininfer_compression)url
target_dirrunnerr   getterextractcmds          r
   tarball_contextr"      s     WW%%c*229bAII&RTU
~"":#8#8E
 &&&0017"Kjj&'*+zszzG&7&<GGH: 		 	+$++5df56	 	 	+$++5df56s7   B	D5A
D DD #!D5D	D "D22D5c                 L    | dd }t        ddd      }|j                  |d      S )zF
    Given a URL or filename, infer the compression code for tar.
    NzjJ)gzbzxz)dictget)r   compression_indicatormappings      r
   r   r   0   s0    
  Hccc*G;;,c22    c              #   h   K   t        j                         }	 |  | |       y#  | |       w xY ww)zk
    Create a temporary directory context. Pass a custom remover
    to override the removal behavior.
    N)tempfilemkdtemp)removertemp_dirs     r
   r4   r4   ;   s0      !Hs   2% 	2
/2Tc              #     K   d| v rdnd} |       5 }|d| |g}|r|j                  d|g       t        t        j                  j                  d      }|r|nd}t        j                  ||       | ddd       y# 1 sw Y   yxY ww)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_contextrC   H   s      C<%TC	 xGS(+JJ
F+,rww,!tc&1  s   BA!A<3	B<BBc               #      K   d  y wr   r   r   r/   r
   nullrE   [   s	     	s   c                   t    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y)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                     || _         y r   )
exceptions)selfrI   s     r
   __init__zExceptionTrap.__init__   s	    $r/   c                     | S r   r   rJ   s    r
   	__enter__zExceptionTrap.__enter__   s    r/   c                      | j                   d   S Nr   exc_inforM   s    r
   typezExceptionTrap.type       }}Qr/   c                      | j                   d   S )N   rQ   rM   s    r
   valuezExceptionTrap.value   rT   r/   c                      | j                   d   S )N   rQ   rM   s    r
   tbzExceptionTrap.tb   rT   r/   c                 V    |d   }|xr t        || j                        }|r|| _        |S rP   )
issubclassrI   rR   )rJ   rR   rS   matchess       r
   __exit__zExceptionTrap.__exit__   s/    {<:dDOO<$DMr/   c                 ,    t        | j                        S r   )boolrS   rM   s    r
   __bool__zExceptionTrap.__bool__   s    DIIr/   _testc                J     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                  x    t        j                        5 } | i | d d d               S # 1 sw Y   xY wr   )rG   rI   )argskwargstraprc   funcrJ   s      r
   wrapperz%ExceptionTrap.raises.<locals>.wrapper   s=    t/ &4d%f%&;& &s   	09)r   wraps)rJ   ri   rc   rj   s   ``` r
   raiseszExceptionTrap.raises   s'    & 
		 
	
 r/   c                 D    | j                  |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
        rb   )rl   operatornot_)rJ   ri   s     r
   passeszExceptionTrap.passes   s    & {{4x}}{55r/   N)__name__
__module____qualname____doc__rR   	ExceptionrK   rN   propertyrS   rW   rZ   r^   ra   r`   rl   rp   r   r/   r
   rG   rG   `   sr    :  H#,, %             %) 66r/   rG   c                       e Zd ZdZy)suppressz
    A version of contextlib.suppress with decorator support.

    >>> @suppress(KeyError)
    ... def key_error():
    ...     {}['']
    >>> key_error()
    N)rq   rr   rs   rt   r   r/   r
   rx   rx      s    r/   rx   )r   r   
contextlibr   r1   shutilrn   contextmanagerr   r"   r   rmtreer4   rC   rE   rG   rx   ContextDecoratorr   r/   r
   <module>r~      s    	         $(U 7 763 ]] 	 	 !  $ 
 
j6 j6Zz""J$?$? r/   