HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/dictupdate.cpython-310.pyc
o

�N�gM-�@sdZddlZddlZddlmZddlZddlmZddl	m
Z
ddlmZddl
mZe�e�Zd$d
d�Zdd
�Zd%dd�Zdd�Zd%dd�Zd&dd�Zed	fdd�Zed	fdd�Zed�ed	fdd��Zed�ed	fdd��Zed �ed	fd!d ��Zed"�ed	fd#d"��ZdS)'z]
Alex Martelli's soulution for recursive dict update from
http://stackoverflow.com/a/3233356
�N)�Mapping)�DEFAULT_TARGET_DELIM)�SaltInvocationError)�jinja_filter)�OrderedDictTFc
	s*t|t�r
t|t�std��t|���}tt|����t|�@s"d}|r�|D]_}||}z|�|d�}Wnty?d}Ynwt|t�rVt|t�rVt|||d�}|||<q&t|t�rt|t�r|rxt	�
|�����fdd�|D���||<q&||||<q&||||<q&|S|D]}	||	||	<q�|S)a�
    Recursive version of the default dict.update

    Merges upd recursively into dest

    If recursive_update=False, will use the classic dict.update, or fall back
    on a manual merge (helpful for non-dict types like FunctionWrapper)

    If merge_lists=True, will aggregate list object types instead of replace.
    The list in ``upd`` is added to the list in ``dest``, so the resulting list
    is ``dest[key] + upd[key]``. This behavior is only activated when
    recursive_update=True. By default merge_lists=False.

    .. versionchanged:: 2016.11.6
        When merging lists, duplicate values are removed. Values already
        present in the ``dest`` list are not added from the ``upd`` list.
    z9Cannot update using non-dict types in dictupdate.update()FN��merge_listscsg|]}|�vr|�qS�r	)�.0�x��mergedr	�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/dictupdate.py�
<listcomp>7szupdate.<locals>.<listcomp>)�
isinstancer�	TypeError�list�keys�set�get�AttributeError�update�copy�deepcopy�extend)
�destZupdZrecursive_updaterZupdkeys�key�valZdest_subkey�ret�kr	rrrs6�


rcCs<i}|��D]\}}||vr|||g||<q|||<q|S)N)�items)�obj_a�obj_brrrr	r	r�
merge_listCs
r#cCst�|�}t|||d�S�Nr)rrr)r!r"rZcopiedr	r	r�
merge_recurseMs
r%cCsddlm}|||dd�S)Nr)�merge_recursive�)�level)Zsalt.serializers.yamlexr&)r!r"Z_yamlex_merge_recursiver	r	r�merge_aggregateRsr)cCs,|D]}||vr||||<qt|||d�Sr$)r%)r!r"r�objr	r	r�merge_overwriteXs
�r+�smart�yamlcCs�|dkr|�d�ddks|�d�rd}nd}|dkr"t||�}|S|dkr.t|||�}|S|dkr9t||�}|S|d	krEt|||�}|S|d
krPt||�}|St�d|�t||�}|S)Nr,�|���ZyamlexZyamlex_Z	aggregateZrecurserZ	overwriteZnonez2Unknown merging strategy '%s', fallback to recurse)�split�
startswithr#r%r)r+�log�warning)r!r"ZstrategyZrendererrr
r	r	r�merge_s,
��
�	�
�
r4cCsd||vr
|�|�}n|g}|}|r0|�d�}||vs!t||t�s*|r&t�ni||<||}|s|S)a�
    Ensures that in_dict contains the series of recursive keys defined in keys.

    :param dict in_dict: The dict to work with.
    :param str keys: The delimited string with one or more keys.
    :param str delimiter: The delimiter to use in `keys`. Defaults to ':'.
    :param bool ordered_dict: Create OrderedDicts if keys are missing.
                              Default: create regular dicts.
    :rtype: dict
    :return: Returns the modified in-place `in_dict`.
    r)r0�popr�dictr)�in_dictr�	delimiter�ordered_dictZa_keys�dict_pointerZcurrent_keyr	r	r�ensure_dict_keyzs

��r;cCsV||vr#|�|�\}}}t||||d�tjjj||d|d�}||fS|}|}||fS)aC
    Helper function to:
    - Ensure all but the last key in `keys` exist recursively in `in_dict`.
    - Return the dict at the one-to-last key, and the last key

    :param dict in_dict: The dict to work with.
    :param str keys: The delimited string with one or more keys.
    :param str delimiter: The delimiter to use in `keys`. Defaults to ':'.
    :param bool ordered_dict: Create OrderedDicts if keys are missing.
                              Default: create regular dicts.
    :rtype: tuple(dict, str)
    :return: (The dict at the one-to-last key, the last key)
    �r8r9N)�defaultr8)�
rpartitionr;�salt�utils�dataZ
traverse_dict)r7rr8r9Zall_but_last_keys�_�last_keyr:r	r	r�_dict_rpartition�s���rD�set_dict_key_valuecCs t||||d�\}}|||<|S)ax
    Ensures that in_dict contains the series of recursive keys defined in keys.
    Also sets whatever is at the end of `in_dict` traversed with `keys` to `value`.

    :param dict in_dict: The dictionary to work with
    :param str keys: The delimited string with one or more keys.
    :param any value: The value to assign to the nested dict-key.
    :param str delimiter: The delimiter to use in `keys`. Defaults to ':'.
    :param bool ordered_dict: Create OrderedDicts if keys are missing.
                              Default: create regular dicts.
    :rtype: dict
    :return: Returns the modified in-place `in_dict`.
    r<)rD�r7r�valuer8r9r:rCr	r	rrE�s

��update_dict_key_valuec	Cs�t||||d�\}}||vs||dur|rt�ni||<z
||�|�W|Sty9td�t||����ttfyOtd�t||�t|����w)a�
    Ensures that in_dict contains the series of recursive keys defined in keys.
    Also updates the dict, that is at the end of `in_dict` traversed with `keys`,
    with `value`.

    :param dict in_dict: The dictionary to work with
    :param str keys: The delimited string with one or more keys.
    :param any value: The value to update the nested dict-key with.
    :param str delimiter: The delimiter to use in `keys`. Defaults to ':'.
    :param bool ordered_dict: Create OrderedDicts if keys are missing.
                              Default: create regular dicts.
    :rtype: dict
    :return: Returns the modified in-place `in_dict`.
    r<Nz0The last key contains a {}, which cannot update.zCannot update {} with a {}.)	rDrrrr�format�type�
ValueErrorrrFr	r	rrH�s*
�
�
������append_dict_key_valuec	Csjt||||d�\}}||vs||durg||<z
||�|�W|Sty4td�t||����w)a�
    Ensures that in_dict contains the series of recursive keys defined in keys.
    Also appends `value` to the list that is at the end of `in_dict` traversed
    with `keys`.

    :param dict in_dict: The dictionary to work with
    :param str keys: The delimited string with one or more keys.
    :param any value: The value to append to the nested dict-key.
    :param str delimiter: The delimiter to use in `keys`. Defaults to ':'.
    :param bool ordered_dict: Create OrderedDicts if keys are missing.
                              Default: create regular dicts.
    :rtype: dict
    :return: Returns the modified in-place `in_dict`.
    r<Nz0The last key contains a {}, which cannot append.)rD�appendrrrIrJrFr	r	rrL�s
��
����extend_dict_key_valuec	Cs�t||||d�\}}||vs||durg||<z
||�|�W|Sty4td�t||����tyHtd�t||�t|����w)a�
    Ensures that in_dict contains the series of recursive keys defined in keys.
    Also extends the list, that is at the end of `in_dict` traversed with `keys`,
    with `value`.

    :param dict in_dict: The dictionary to work with
    :param str keys: The delimited string with one or more keys.
    :param any value: The value to extend the nested dict-key with.
    :param str delimiter: The delimiter to use in `keys`. Defaults to ':'.
    :param bool ordered_dict: Create OrderedDicts if keys are missing.
                              Default: create regular dicts.
    :rtype: dict
    :return: Returns the modified in-place `in_dict`.
    r<Nz0The last key contains a {}, which cannot extend.zCannot extend {} with a {}.)rDrrrrIrJrrFr	r	rrNs*
�
�
�����)TF)F)r,r-F)�__doc__r�logging�collections.abcrZsalt.utils.datar?Z
salt.defaultsrZsalt.exceptionsrZsalt.utils.decorators.jinjarZsalt.utils.odictr�	getLogger�__name__r2rr#r%r)r+r4r;rDrErHrLrNr	r	r	r�<module>s<

0



��'�!�