o
    Wi9                     @  s   d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z	 d dlm
Z
 eddZejZG d	d
 d
e	Zee
eef df Ze
eeef Zeeeef df ZdddZej	ddddZdS )    )annotationsN)	Generator)MutableMapping)
NamedTuple)Union_UnsetUNSETc                   @  s"   e Zd ZU ded< dZded< dS )Varstrname defaultN)__name__
__module____qualname____annotations__r    r   r   I/home/ubuntu/.local/lib/python3.10/site-packages/pre_commit/envcontext.pyr	      s   
 r	   .partsSubstitutionTenvMutableMapping[str, str]returnr
   c                   s   d  fdd| D S )Nr   c                 3  s.    | ]}t |tr |j|jn|V  qd S N)
isinstancer	   getr   r   ).0partr   r   r   	<genexpr>   s
    
zformat_env.<locals>.<genexpr>)join)r   r   r   r   r   
format_env   s   r!   patchPatchesT_envMutableMapping[str, str] | NoneGenerator[None]c              	   c  s    |du rt jn|}t|}| D ] \}}|tu r||d qt|tr,t||||< q|||< qzdV  W |  |	| dS |  |	| w )a  In this context, `os.environ` is modified according to `patch`.

    `patch` is an iterable of 2-tuples (key, value):
        `key`: string
        `value`:
            - string: `environ[key] == value` inside the context.
            - UNSET: `key not in environ` inside the context.
            - template: A template is a tuple of strings and Var which will be
              replaced with the previous environment
    N)
osenvirondictr   popr   tupler!   clearupdate)r"   r$   r   beforekvr   r   r   
envcontext    s   

r1   )r   r   r   r   r   r
   r   )r"   r#   r$   r%   r   r&   )
__future__r   
contextlibenumr'   collections.abcr   r   typingr   r   Enumr   r   r	   r+   r
   r   ValueTr#   r!   contextmanagerr1   r   r   r   r   <module>   s$    
