U
    e»{jÖ  ã                   @   sh   d Z ddlZddlZddlZddlZddlZddlZddlmZ dgZ	e 
d¡Zdi dddfdd„ZdS )	z4Utilities for generating new Python code at runtime.é    Né   )Úfind_current_moduleÚmake_function_with_signaturez^[A-Za-z][A-Za-z_]*© c                 C   sJ  g }g }t |tƒr| ¡ }nt|ƒ}t ||¡D ]R}	t |	tƒrR|	d }
| |	¡ n|	}
| |	¡ t 	|
¡stt
 |
¡s0td|
› �ƒ‚q0||fD ].}	|	dk	rŒt 	|	¡s¬t
 |	¡sŒtd|	› �ƒ‚qŒd |¡g}|rÜ| d|› �¡ |dd… }|dkrö| j}d|› d�| i}i }t|ƒD ]J\}}	|	\}}d|› �}|||< | d|› d	|› �¡ | d
 |¡¡ �q|�r„| d|› �¡ | d|› �¡ d |¡ d¡}d |¡ d¡}tdƒ}t ¡ j}|�rê|j}|j}| d¡�ròtj |¡d d }nd}d}|jd }t djd| |||d�¡}t||dƒ}t|||ƒ || }||_ | j!|_!|S )av  
    Make a new function from an existing function but with the desired
    signature.

    The desired signature must of course be compatible with the arguments
    actually accepted by the input function.

    The ``args`` are strings that should be the names of the positional
    arguments.  ``kwargs`` can map names of keyword arguments to their
    default values.  It may be either a ``dict`` or a list of ``(keyword,
    default)`` tuples.

    If ``varargs`` is a string it is added to the positional arguments as
    ``*<varargs>``.  Likewise ``varkwargs`` can be the name for a variable
    keyword argument placeholder like ``**<varkwargs>``.

    If not specified the name of the new function is taken from the original
    function.  Otherwise, the ``name`` argument can be used to specify a new
    name.

    Note, the names may only be valid Python variable names.
    r   zinvalid argument name: Nz, z, *Ú__Z__funcÚ_kwargsú=z	, {0}={0}z, **Ú é   z.pycz.pyz<string>Ú__main__zE{0}    def {name}({sig1}):
        return __{name}__func({sig2})
    Ú
)ÚnameZsig1Zsig2Zsingle)"Ú
isinstanceÚdictÚitemsÚiterÚ	itertoolsÚchainÚtupleÚappendÚkeywordÚ	iskeywordÚ_ARGNAME_REÚmatchÚSyntaxErrorÚjoinÚ__name__Ú	enumerateÚformatÚlstripr   ÚinspectÚcurrentframeÚf_backÚ__file__ÚendswithÚosÚpathÚsplitextÚf_linenoÚtextwrapÚdedentÚcompileÚevalÚ
__module__Ú__doc__)ÚfuncÚargsÚkwargsÚvarargsZ	varkwargsr   Zpos_argsZkey_argsZiter_kwargsÚitemÚargnameZdef_signatureZcall_signatureÚglobal_varsÚ
local_varsÚidxÚkeyÚvalueZdefault_varÚmodZfrmÚfilenameÚmodnameÚlinenoÚtemplateÚcodeÚnew_funcr   r   úT/var/www/html/bwave/python/venv/lib/python3.8/site-packages/astropy/utils/codegen.pyr      sx    






   üÿ	)r.   r    r   r   r%   Úrer)   Zintrospectionr   Ú__all__r+   r   r   r   r   r   rA   Ú<module>   s   
	    ÿ