HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/functools.cpython-310.pyc
o

�N�g��@sbdZddlZddlZddlZddlZddlmZe�e	�Z
ddd�Zd
dd�Zdd	�Z
d
d�ZdS)z-
Utility functions to modify other functions
�N)�SaltInvocationErrorcCs�|durtjj�dd�|durtjj�dd�|j��D]\}}||vr)|||<qtj|j||j	|j
|jd�}|j�
|j�|S)aN
    Redefine (clone) a function under a different globals() namespace scope.

    Any keys missing in the passed ``global_dict`` that is present in the
    passed function ``__globals__`` attribute get's copied over into
    ``global_dict``, thus avoiding ``NameError`` from modules imported in
    the original function module.

    :param defaults:
        .. deprecated:: 3005

    :param preserve_context:
        .. deprecated:: 3005

        Allow keeping the context taken from orignal namespace,
        and extend it with globals() taken from
        new targetted namespace.
    Ni�z�Passing 'defaults' to 'namespaced_function' is deprecated, slated for removal in {version} and no longer does anything for the function being namespaced.z�Passing 'preserve_context' to 'namespaced_function' is deprecated, slated for removal in {version} and no longer does anything for the function being namespaced.)�nameZargdefsZclosure)�salt�utilsZversionsZ
warn_until�__globals__�items�types�FunctionType�__code__�__name__�__defaults__�__closure__�__dict__�update)�functionZglobal_dict�defaultsZpreserve_context�key�valueZnew_namespaced_function�r�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/functools.py�namespaced_functions.��	��rcCsjt�|j|jt|�|j|j�}|j�|j�|r"t	|t�r"||_
|S|j}d|�d�}||j
p0d|_
|S)z
    Copy a function
    z 
This function is an alias of ``z``.
�)rr	r
r�strrr
rr�
isinstance�__doc__r)Zfunr�docZ	alias_funZ	orig_nameZ	alias_msgrrr�alias_functionCs��rcCs<g}i}|D]}t|t�r|�|�q|�|�q||d�S)a�
    Helper function to parse function_arguments (module.run format)
    into args and kwargs.
    This function is similar to salt.utils.data.repack_dictlist, except that this
    handles mixed (i.e. dict and non-dict) arguments in the input list.

    :param list function_arguments: List of items and dicts with kwargs.

    :rtype: dict
    :return: Dictionary with ``args`` and ``kwargs`` keyword.
    )�args�kwargs)r�dictr�append)Zfunction_arguments�
function_args�function_kwargs�itemrrr�parse_functionZs

r$cOs�tjj�|�}tt|jt|jpg�d�|jpg��}|jdt|jp$g�t|jp*g��}gi}}t|p8g�D]$}t	|t�sG|�
|�q:|��D]}	|	|vrX||	||	<qK|�|�qKq:|�
�|�|�|D]
}
|
|vrw|�
||
�qjt|jp}g�t|jp�g�}t|�}g}
||kr�|j|d�D]}
|
|vr�|
�
|
�q�|d7}q�|
r�td�d�|
����||kr�td�||���||i|��S)z�
    Calls a function from the specified module.

    :param function salt_function: Function reference to call
    :return: The result of the function call
    N�zMissing arguments: {}z, z6Function expects {} positional parameters, got only {})rrrZget_function_argspecr�zip�lenr�reversedrr �keysr�reverser�format�join)Z
salt_functionrrZargspecr"Z
expected_argsr!Zkw_to_arg_typeZfuncsetZ	kwarg_key�argZ_exp_prmZ_passed_prm�missingrrr�
call_functionpsT���

�	
�
��r/)NN)N)r�loggingrZsalt.utils.argsrZsalt.utils.versionsZsalt.exceptionsr�	getLoggerr�logrrr$r/rrrr�<module>s


4