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
    