o
    I^                     @   s0   d Z ddlmZmZ dd Zdd Zdd Zd	S )
z
Python introspection helpers.
    )CodeTypeFunctionTypec                    sP   g d}t tdr|dd t tdr|dd  fdd|D }t| S )	N)argcountnlocals	stacksizeflagscodeconstsnamesvarnamesfilenamenamefirstlinenolnotabfreevarscellvarsco_kwonlyargcount   kwonlyargcountco_posonlyargcountposonlyargcountc              	      s"   g | ]}  |td | qS )co_getgetattr.0r   changestemplate 8/usr/lib/python3/dist-packages/automat/_introspection.py
<listcomp>   s    zcopycode.<locals>.<listcomp>)hasattrr   insert)r   r   r
   valuesr    r   r!   copycode   s   

r&   c                    s4   g d} fdd|D }t tj|g|R  S )N)globalsr   defaultsclosurec              	      s&   g | ]}  |td | d  qS )__r   r   funcchangesr   r    r!   r"      s    z copyfunction.<locals>.<listcomp>)functionr&   __code__)r   r,   codechangesr
   r%   r    r+   r!   copyfunction   s
   r0   c                    s    fdd}|S )zL
    Preserve the name of the given function on the decorated function.
    c                    s   t | t jdt jdS )N)r   )r0   dict__name__)	decoratedfr    r!   	decorator*   s   zpreserveName.<locals>.decoratorr    )r5   r6   r    r4   r!   preserveName&   s   r7   N)	__doc__typesr   r   r   r-   r&   r0   r7   r    r    r    r!   <module>   s
    