
    IR-e                         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j
        d          Z	 di dddf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                    g }g }t          |t                    r|                                }nt          |          }t	          j        ||          D ]}	t          |	t                    r|	d         }
|                    |	           n|	}
|                    |	           t          j	        |
          st                              |
          st          d|
           ||fD ]D}	|	@t          j	        |	          st                              |	          st          d|	           Ed                    |          g}|r|                    d|            |dd         }|| j        }d| d| i}i }t          |          D ]W\  }}	|	\  }}d| }|||<   |                    d| d	|            |                    d
                    |                     X|r0|                    d|            |                    d|            d                    |                              d          }d                    |                              d          }t%          d          }t'          j                    j        }|rL|j        }|j        }|                    d          r(t0          j                            |          d         dz   }nd}d}|j        dz
  }t9          j        d                    d|z  |||                    }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, *____func_kwargs=z	, {0}={0}z, **    z.pycz.pyz<string>__main__zE{0}    def {name}({sig1}):
        return __{name}__func({sig2})
    
)namesig1sig2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varargs	varkwargsr   pos_argskey_argsiter_kwargsitemargnamedef_signaturecall_signatureglobal_vars
local_varsidxkeyvaluedefault_varmodfrmfilenamemodnamelinenotemplatecodenew_funcs                              5lib/python3.11/site-packages/astropy/utils/codegen.pyr   r      s   2 HH&$ #llnn6ll k22 	C 	CdE"" 	"1gGOOD!!!!GOOD!!!W%% 	C[->->w-G-G 	CAAABBB	C )$ D D && Dk.?.?.E.E D!"BD"B"BCCCYYx(()M ._7__---"111%N|}$$$$d+KJx(( 7 7	T
U%oo"'
;5#5555666k00556666 2/I//0000Y00111GGM**11$77MWW^,,33D99N
a
 
 C


 
 
'C
 <,V$$ 	=w''11!4u<H
 \AF 	 	6M=~ 	 	
 	
	 H 8Xx00D{J'''$H!H|HO    )r4   r&   r   r   r+   rer/   introspectionr   __all__r1   r   r   r   rP   rO   <module>rT      s    : :       				 				  . . . . . .)
* bj/00 "ddq q q q q qrP   