
    Vh
                    p    d Z ddlmZ ddlmZmZ ddlmZmZm	Z	m
Z
  G d dee      Zd ZddZdd	Zd
 Zy)z*Collection of low-level utility functions.    )annotations)binary_type	text_type)HashableMappingMutableMappingSequencec                  F    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zy)ImmutableDictz!Dictionary that cannot be updatedc                $    t        |i || _        y N)dict_store)selfargskwargss      W/home/dcms/DCMS/lib/python3.12/site-packages/ansible/module_utils/common/collections.py__init__zImmutableDict.__init__   s    D+F+    c                     | j                   |   S r   r   )r   keys     r   __getitem__zImmutableDict.__getitem__   s    {{3r   c                6    | j                   j                         S r   )r   __iter__r   s    r   r   zImmutableDict.__iter__   s    {{##%%r   c                6    | j                   j                         S r   )r   __len__r   s    r   r   zImmutableDict.__len__   s    {{""$$r   c                F    t        t        | j                                     S r   )hash	frozensetitemsr   s    r   __hash__zImmutableDict.__hash__   s    Idjjl+,,r   c                `    	 | j                         t        |      k(  ry	 y# t        $ r Y yw xY w)NTF)r#   r    	TypeError)r   others     r   __eq__zImmutableDict.__eq__   s=    	}}$u+- .
   		s   ! 	--c                J    dj                  t        | j                              S )NzImmutableDict({0}))formatreprr   r   s    r   __repr__zImmutableDict.__repr__'   s    #**4+<==r   c                .    t        | j                  fi |S )a  
        Create an ImmutableDict as a combination of the original and overriding_mapping

        :arg overriding_mapping: A Mapping of replacement and additional items
        :return: A copy of the ImmutableDict with key-value pairs from the overriding_mapping added

        If any of the keys in overriding_mapping are already present in the original ImmutableDict,
        the overriding_mapping item replaces the one in the original ImmutableDict.
        )r   r   )r   overriding_mappings     r   unionzImmutableDict.union*   s     T[[?,>??r   c                     t        |      fd j                  j                         D        }t         fd|D              S )aK  
        Create an ImmutableDict as a combination of the original minus keys in subtractive_iterable

        :arg subtractive_iterable: Any iterable containing keys that should not be present in the
            new ImmutableDict
        :return: A copy of the ImmutableDict with keys from the subtractive_iterable removed
        c              3  ,   K   | ]  }|vs|  y wr    ).0kremove_keyss     r   	<genexpr>z+ImmutableDict.difference.<locals>.<genexpr>?   s     Fa+1EFs   	c              3  @   K   | ]  }|j                   |   f  y wr   r   )r2   r3   r   s     r   r5   z+ImmutableDict.difference.<locals>.<genexpr>@   s     ?QaQ0?s   )r!   r   keysr   )r   subtractive_iterabler7   r4   s   `  @r   
differencezImmutableDict.difference6   s8       45F4;;++-F?$???r   N)__name__
__module____qualname____doc__r   r   r   r   r#   r'   r+   r.   r9   r1   r   r   r   r      s4    +, &%->
@
@r   r   c                L    t        | t        t        f      xs t        | dd      S )zDIdentify whether the input has a string-like type (including bytes).__ENCRYPTED__F)
isinstancer   r   getattr)seqs    r   	is_stringrC   C   s%     cI{34\_V[8\\r   c                V    |st        |       ry	 t        |        y# t        $ r Y yw xY w)z*Identify whether the input is an iterable.FT)rC   iterr%   rB   include_stringss     r   is_iterablerH   I   s/    y~S	 s    	((c                >    |st        |       ryt        | t              S )zIdentify whether the input is a sequence.

    Strings and bytes are not sequences here,
    unless ``include_string`` is ``True``.

    Non-indexable things are never of a sequence type.
    F)rC   r@   r	   rF   s     r   is_sequencerJ   U   s     y~c8$$r   c                    t        |       st        d      t               }| D ]  }|j                  |d      dz   ||<    |S )aT  Returns a dictionary with the number of appearances of each element of the iterable.

    Resembles the collections.Counter class functionality. It is meant to be used when the
    code is run on Python 2.6.* where collections.Counter is not available. It should be
    deprecated and replaced when support for Python < 2.7 is dropped.
    z%Argument provided  is not an iterabler      )rH   	Exceptionr   get)rB   counterselems      r   countrQ   c   sL     s?@@vH 3!dA.23Or   N)F)r=   
__future__r   ansible.module_utils.sixr   r   .ansible.module_utils.six.moves.collections_abcr   r   r   r	   r   rC   rH   rJ   rQ   r1   r   r   <module>rU      s>    1 " < f f3@Hg 3@l]	%r   