U
    ]                     @   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                    sh   ddddddddd	d
ddddg}t tdr6|dd t tdrL|dd  fdd|D }t| S )NZargcountZnlocalsZ	stacksizeflagscodeZconstsnamesZvarnamesfilenamenameZfirstlinenoZlnotabZfreevarsZcellvarsco_kwonlyargcount   Zkwonlyargcountco_posonlyargcountZposonlyargcountc              	      s"   g | ]}  |td | qS )Z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                    s6   ddddg} fdd|D }t tj|f| S )Nglobalsr   defaultsZclosurec              	      s&   g | ]}  |td | d  qS )__r   r   funcchangesr   r   r   r      s   z copyfunction.<locals>.<listcomp>)functionr   __code__)r   r   Zcodechangesr   r   r   r   r   copyfunction   s       r"   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   )r"   dict__name__)Z	decoratedfr   r   	decorator*   s    
 
zpreserveName.<locals>.decoratorr   )r&   r'   r   r%   r   preserveName&   s    r(   N)	__doc__typesr   r   r   r    r   r"   r(   r   r   r   r   <module>   s   