o
    a                     @   s   d dl Z z
d dlmZmZ W n ey   dZd dlmZ Y nw e Zdd Zdd Z	dd	 Z
d
d Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zedu rXdd Zndd Zdd ZdS )    N)	Parameter	signature)getfullargspecc                 C   s   | d S )z Add one to the current value     xr   r   =/usr/lib/python3/dist-packages/pyrsistent/_transformations.pyinc      r
   c                 C   s   | d S )z% Subtract one from the current value r   r   r   r   r   r	   dec   r   r   c                 C   s"   z| |= W dS  t y   Y dS w )zL Discard the element and returns a structure without the discarded elements N)KeyError)evolverkeyr   r   r	   discard   s
   r   c                    s   t |   fddS )zE Regular expression matcher to use together with transform functions c                    s   t | to	 | S N)
isinstancestrmatch)r   rr   r	   <lambda>"   s    zrex.<locals>.<lambda>)recompile)exprr   r   r	   rex   s   
r   c                 C   s   dS )z  Matcher that matches any value Tr   )_r   r   r	   ny%   s   r   c                 c   s.    t dt| |D ]}| |||  V  q	d S )Nr   )rangelen)lnir   r   r	   _chunks+   s   r#   c                 C   s(   | }t |dD ]
\}}t|||}q|S )N   )r#   _do_to_path)	structureZtransformationsr   pathcommandr   r   r	   	transform0   s   r)   c                 C   s<   |st |r
|| S |S t| |d }t| ||dd  |S )Nr   r   )callable_get_keys_and_values_update_structure)r&   r'   r(   kvsr   r   r	   r%   7   s   r%   c                 C   s*   z|   W S  ty   tt|  Y S w r   )itemsAttributeErrorlist	enumerate)r&   r   r   r	   _items?   s
   
r2   c              	   C   s<   zt | dr| | W S t| |W S  ttfy   | Y S w )N__getitem__)hasattrgetattr
IndexErrorr   )r&   r   defaultr   r   r	   _getG   s   

r8   c                    sf   t  r*t }|dkr fddt| D S |dkr& fddt| D S td t|  tfgS )Nr   c                    s    g | ]\}} |r||fqS r   r   .0kvkey_specr   r	   
<listcomp>Y   s     z(_get_keys_and_values.<locals>.<listcomp>r$   c                    s"   g | ]\}} ||r||fqS r   r   r9   r=   r   r	   r?   ]   s   " z5callable in transform path must take 1 or 2 arguments)r*   
_get_arityr2   
ValueErrorr8   _EMPTY_SENTINEL)r&   r>   Zarityr   r=   r	   r+   R   s   r+   c                 C   s    t | }t|jt|jpd S )Nr   )r   r   argsdefaults)fZargspecr   r   r	   r@   i   s   r@   c                 C   s   t dd t| j D S )Nc                 s   s2    | ]}|j tju r|jtjtjfv rd V  qdS )r   N)r7   r   emptykindZPOSITIONAL_ONLYZPOSITIONAL_OR_KEYWORD)r:   pr   r   r	   	<genexpr>n   s    

z_get_arity.<locals>.<genexpr>)sumr   Z
parametersvalues)rE   r   r   r	   r@   m   s   c           
      C   s   ddl m} |  }|s"|tu r"t|D ]	\}}t|| q| S |D ]\}}d}|tu r3d}| }t|||}	|	|us?|rC|	||< q$| S )Nr   )pmapFT)Zpyrsistent._pmaprL   r   r   reversedrB   r%   Z
persistent)
r&   r-   r'   r(   rL   er;   r<   Zis_emptyresultr   r   r	   r,   w   s    r,   )r   inspectr   r   ImportErrorr   objectrB   r
   r   r   r   r   r#   r)   r%   r2   r8   r+   r@   r,   r   r   r   r	   <module>   s.    	

