Your IP : 18.217.228.195


Current Path : /opt/imunify360/venv/lib64/python3.11/site-packages/pyrsistent/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/pyrsistent/__pycache__/_pmap.cpython-311.pyc

�

O�Dg]I���ddlmZmZddlmZddlmZddlmZGd�d��Z	Gd�de	��Z
Gd	�d
e	��ZGd�de��Z
eje
��eje
��d
�Zeid��Zidfd�Zd�ZdS)�)�Mapping�Hashable)�chain)�pvector��	transformc�*�eZdZdZd�Zd�Zd�Zd�ZdS)�PMapViewa�View type for the persistent map/dict type `PMap`.

    Provides an equivalent of Python's built-in `dict_values` and `dict_items`
    types that result from expreessions such as `{}.values()` and
    `{}.items()`. The equivalent for `{}.keys()` is absent because the keys are
    instead represented by a `PSet` object, which can be created in `O(1)` time.

    The `PMapView` class is overloaded by the `PMapValues` and `PMapItems`
    classes which handle the specific case of values and items, respectively

    Parameters
    ----------
    m : mapping
        The mapping/dict-like object of which a view is to be created. This
        should generally be a `PMap` object.
    c���t|t��s4t|t��rt|��}nt	d���t
�|d|��dS)Nz"PViewMap requires a Mapping object�_map)�
isinstance�PMapr�pmap�	TypeError�object�__setattr__)�self�ms  �p/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/site-packages/pyrsistent/_pmap.py�__init__zPMapView.__init__sb���!�T�"�"�	F��!�W�%�%�
F���G�G���� D�E�E�E����4���+�+�+�+�+�c�*�t|j��S�N)�lenr�rs r�__len__zPMapView.__len__"s���4�9�~�~�rc�@�tt|���d����)Nz
 is immutable)r�type)r�k�vs   rrzPMapView.__setattr__%s���T�$�Z�Z�Z�Z�9�:�:�:rc� �td����Nz"Persistent maps are not reversible�rrs r�__reversed__zPMapView.__reversed__(����<�=�=�=rN)�__name__�
__module__�__qualname__�__doc__rrrr$�rrr
r
sZ��������",�,�,����;�;�;�>�>�>�>�>rr
c�0�eZdZdZd�Zd�Zd�Zd�Zd�ZdS)�
PMapValuesaView type for the values of the persistent map/dict type `PMap`.

    Provides an equivalent of Python's built-in `dict_values` type that result
    from expreessions such as `{}.values()`. See also `PMapView`.

    Parameters
    ----------
    m : mapping
        The mapping/dict-like object of which a view is to be created. This
        should generally be a `PMap` object.
    c�4�|j���Sr�r�
itervaluesrs r�__iter__zPMapValues.__iter__7s���y�#�#�%�%�%rc�8�||j���vSrr.)r�args  r�__contains__zPMapValues.__contains__:s���d�i�*�*�,�,�,�,rc�B�dtt|�����d�S�Nzpmap_values(�)��list�iterrs r�__str__zPMapValues.__str__>�!��1�d�4��:�:�.�.�1�1�1�1rc�B�dtt|�����d�Sr5r7rs r�__repr__zPMapValues.__repr__Ar;rc��||urdSdS�NTFr*�r�xs  r�__eq__zPMapValues.__eq__Ds��
��9�9�T�T��UrN�	r&r'r(r)r0r3r:r=rBr*rrr,r,+si������
�
�&�&�&�-�-�-�2�2�2�2�2�2�����rr,c�0�eZdZdZd�Zd�Zd�Zd�Zd�ZdS)�	PMapItemsa|View type for the items of the persistent map/dict type `PMap`.

    Provides an equivalent of Python's built-in `dict_items` type that result
    from expreessions such as `{}.items()`. See also `PMapView`.

    Parameters
    ----------
    m : mapping
        The mapping/dict-like object of which a view is to be created. This
        should generally be a `PMap` object.
    c�4�|j���Sr)r�	iteritemsrs rr0zPMapItems.__iter__Vs���y�"�"�$�$�$rc�d�|\}}n#t$rYdSwxYw||jvo|j||kS)NF)�	Exceptionr)rr2rr s    rr3zPMapItems.__contains__YsB���U�a�����&�&�&����&�����D�I�~�3�$�)�A�,�!�"3�3s��
�c�B�dtt|�����d�S�Nzpmap_items(r6r7rs rr:zPMapItems.__str___�!��0�T�$�t�*�*�-�-�0�0�0�0rc�B�dtt|�����d�SrKr7rs rr=zPMapItems.__repr__brLrc�l�||urdSt|t|����sdS|j|jkSr?)r
rrr@s  rrBzPMapItems.__eq__es:����9�9�T�T��A�t�D�z�z�*�*�	)�5�5��Y�!�&�(�(rNrCr*rrrErEJsi������
�
�%�%�%�4�4�4�1�1�1�1�1�1�)�)�)�)�)rrEc�R��eZdZdZdZ�fd�Zed���Zed���Zd�Z	ed���Z
d�Zej
Z
d	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZejZd�ZeZeZeZd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&e&Z'd�Z(d�Z)d �Z*Gd!�d"e+��Z,d#�Z-�xZ.S)$ra�
    Persistent map/dict. Tries to follow the same naming conventions as the built in dict where feasible.

    Do not instantiate directly, instead use the factory functions :py:func:`m` or :py:func:`pmap` to
    create an instance.

    Was originally written as a very close copy of the Clojure equivalent but was later rewritten to closer
    re-assemble the python dict. This means that a sparse vector (a PVector) of buckets is used. The keys are
    hashed and the elements inserted at position hash % len(bucket_vector). Whenever the map size exceeds 2/3 of
    the containing vectors size the map is reallocated to a vector of double the size. This is done to avoid
    excessive hash collisions.

    This structure corresponds most closely to the built in dict type and is intended as a replacement. Where the
    semantics are the same (more or less) the same function names have been used but for some cases it is not possible,
    for example assignments and deletion of values.

    PMap implements the Mapping protocol and is Hashable. It also supports dot-notation for
    element access.

    Random access and insert is log32(n) where n is the size of the map.

    The following are examples of some common operations on persistent maps

    >>> m1 = m(a=1, b=3)
    >>> m2 = m1.set('c', 3)
    >>> m3 = m2.remove('a')
    >>> m1 == {'a': 1, 'b': 3}
    True
    >>> m2 == {'a': 1, 'b': 3, 'c': 3}
    True
    >>> m3 == {'b': 3, 'c': 3}
    True
    >>> m3['c']
    3
    >>> m3.c
    3
    )�_size�_buckets�__weakref__�_cached_hashc�t��tt|���|��}||_||_|Sr)�superr�__new__rPrQ)�cls�size�bucketsr�	__class__s    �rrVzPMap.__new__�s3����T�3���'�'��,�,����
���
��rc�X�t|��t|��z}||}||fSr)�hashr)rY�key�index�buckets    r�_get_bucketzPMap._get_bucket�s+���S�	�	�C��L�L�(�������f�}�rc��t�||��\}}|r|D]\}}||kr|cS�t|���r)rr`�KeyError)rYr]�_r_rr s      r�_getitemz
PMap._getitem�s[���$�$�W�c�2�2�	��6��	��
�
���1���8�8��H�H�H���s�m�m�rc�B�t�|j|��Sr)rrdrQ�rr]s  r�__getitem__zPMap.__getitem__�s���}�}�T�]�C�0�0�0rc�l�t�||��\}}|r|D]\}}||krdS�dSdSr?)rr`)rYr]rcr_rs     r�	_containszPMap._contains�sW���$�$�W�c�2�2�	��6��	��
 �
 ���1���8�8��4�4���5��urc�8�|�|j|��Sr)rirQrfs  rr3zPMap.__contains__�s���~�~�d�m�S�1�1�1rc�*�|���Sr)�iterkeysrs rr0z
PMap.__iter__�����}�}���rc� �td���r"r#rs rr$zPMap.__reversed__�r%rc��	||S#t$r;}td�t|��j|����|�d}~wwxYw)Nz{0} has no attribute '{1}')rb�AttributeError�formatrr&)rr]�es   r�__getattr__zPMap.__getattr__�sa��	���9����	�	�	� �,�3�3�D��J�J�4G��M�M����
�����	���s�
�
A�6A
�
Ac#�FK�|���D]	\}}|V��
dSr�rG)rrrcs   rrlz
PMap.iterkeys��8�����N�N�$�$�	�	�D�A�q��G�G�G�G�	�	rc#�FK�|���D]	\}}|V��
dSrru)rrcr s   rr/zPMap.itervalues�rvrc#�>K�|jD]}|r|D]\}}||fV���dSr)rQ)rr_rr s    rrGzPMap.iteritems�sL�����m�	�	�F��
�"���D�A�q��Q�$�J�J�J�J��	�	rc� �t|��Sr)r,rs r�valueszPMap.values�s���$���rc�$�ddlm}||��S)N�)�PSet)�_psetr})rr}s  r�keysz	PMap.keys�s"���������t�D�z�z�rc� �t|��Sr)rErs r�itemsz
PMap.items�s������rc��|jSr�rPrs rrzPMap.__len__�s
���z�rc�`�d�tt|������S)Nz	pmap({0}))rq�str�dictrs rr=z
PMap.__repr__�s"���!�!�#�d�4�j�j�/�/�2�2�2rc��||urdSt|t��stSt|��t|��krdSt|t��r�t|d��r"t|d��r|j|jkrdS|j|jkrdSt|�	����t|�	����kSt|t��r%t|�	����|kSt|�	����t|�
����kS)NTFrS)r
r�NotImplementedrr�hasattrrSrQr�rGr��r�others  rrBzPMap.__eq__�s.���5�=�=��4��%��)�)�	"�!�!��t�9�9��E�
�
�"�"��5��e�T�"�"�	3���n�-�-�
�'�%��2P�2P�
��)�U�-?�?�?��u��}���.�.��t�����(�(�)�)�T�%�/�/�2C�2C�-D�-D�D�D�
��t�
$�
$�	3�����(�(�)�)�U�2�2��D�N�N�$�$�%�%��e�k�k�m�m�)<�)<�<�<rc� �td���)NzPMaps are not orderabler#r�s  r�__lt__zPMap.__lt__s���1�2�2�2rc�*�|���Sr)r=rs rr:zPMap.__str__	rmrc��t|d��s3tt|�������|_|jS)NrS)r�r\�	frozensetrGrSrs r�__hash__z
PMap.__hash__s@���t�^�,�,�	B� $�Y�t�~�~�/?�/?�%@�%@� A� A�D��� � rc�v�|����||�����S)a4
        Return a new PMap with key and val inserted.

        >>> m1 = m(a=1, b=2)
        >>> m2 = m1.set('a', 3)
        >>> m3 = m1.set('c' ,4)
        >>> m1 == {'a': 1, 'b': 2}
        True
        >>> m2 == {'a': 3, 'b': 2}
        True
        >>> m3 == {'a': 1, 'b': 2, 'c': 4}
        True
        )�evolver�set�
persistent�rr]�vals   rr�zPMap.sets.���|�|�~�~�!�!�#�s�+�+�6�6�8�8�8rc�t�|����|�����S)z�
        Return a new PMap without the element specified by key. Raises KeyError if the element
        is not present.

        >>> m1 = m(a=1, b=2)
        >>> m1.remove('a')
        pmap({'b': 2})
        )r��remover�rfs  rr�zPMap.remove!s,���|�|�~�~�$�$�S�)�)�4�4�6�6�6rc�R�	|�|��S#t$r|cYSwxYw)a
        Return a new PMap without the element specified by key. Returns reference to itself
        if element is not present.

        >>> m1 = m(a=1, b=2)
        >>> m1.discard('a')
        pmap({'b': 2})
        >>> m1 is m1.discard('c')
        True
        )r�rbrfs  r�discardzPMap.discard,s=��	��;�;�s�#�#�#���	�	�	��K�K�K�	���s��&�&c� �|jd�g|�R�S)a,
        Return a new PMap with the items in Mappings inserted. If the same key is present in multiple
        maps the rightmost (last) value is inserted.

        >>> m1 = m(a=1, b=2)
        >>> m1.update(m(a=2, c=3), {'a': 17, 'd': 35}) == {'a': 17, 'b': 2, 'c': 3, 'd': 35}
        True
        c��|Srr*)�l�rs  r�<lambda>zPMap.update.<locals>.<lambda>Es��Q�r)�update_with)r�mapss  r�updatezPMap.update<s!�� �t����6��6�6�6�6rc	���|���}|D]H}|���D]1\}}|�|||vr||||��n|���2�I|���S)a%
        Return a new PMap with the items in Mappings maps inserted. If the same key is present in multiple
        maps the values will be merged using merge_fn going from left to right.

        >>> from operator import add
        >>> m1 = m(a=1, b=2)
        >>> m1.update_with(add, m(a=2)) == {'a': 3, 'b': 2}
        True

        The reverse behaviour of the regular merge. Keep the leftmost element instead of the rightmost.

        >>> m1 = m(a=1)
        >>> m1.update_with(lambda l, r: l, m(a=2), {'a':3})
        pmap({'a': 1})
        )r�r�r�r�)r�	update_fnr�r��mapr]�values       rr�zPMap.update_withGs��� �,�,�.�.���	^�	^�C�!�i�i�k�k�
^�
^�
��U����C�3�'�>�>���7�3�<��!?�!?�!?�W\�]�]�]�]�
^��!�!�#�#�#rc�,�|�|��Sr)r�r�s  r�__add__zPMap.__add__^s���{�{�5�!�!�!rc�0�tt|��ffSr)rr�rs r�
__reduce__zPMap.__reduce__cs���d�4�j�j�]�"�"rc�"�t||��S)a�
        Transform arbitrarily complex combinations of PVectors and PMaps. A transformation
        consists of two parts. One match expression that specifies which elements to transform
        and one transformation function that performs the actual transformation.

        >>> from pyrsistent import freeze, ny
        >>> news_paper = freeze({'articles': [{'author': 'Sara', 'content': 'A short article'},
        ...                                   {'author': 'Steve', 'content': 'A slightly longer article'}],
        ...                      'weather': {'temperature': '11C', 'wind': '5m/s'}})
        >>> short_news = news_paper.transform(['articles', ny, 'content'], lambda c: c[:25] + '...' if len(c) > 25 else c)
        >>> very_short_news = news_paper.transform(['articles', ny, 'content'], lambda c: c[:15] + '...' if len(c) > 15 else c)
        >>> very_short_news.articles[0].content
        'A short article'
        >>> very_short_news.articles[1].content
        'A slightly long...'

        When nothing has been transformed the original data structure is kept

        >>> short_news is news_paper
        True
        >>> very_short_news is news_paper
        False
        >>> very_short_news.articles[0] is news_paper.articles[0]
        True
        r)r�transformationss  rrzPMap.transformgs��4���/�/�/rc��|Srr*rs r�copyz	PMap.copy�s���rc�T�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
S)�
PMap._Evolver)�_buckets_evolverrP�_original_pmapc�h�||_|j���|_|j|_dSr)r�rQr�r�rP)r�
original_pmaps  rrzPMap._Evolver.__init__�s/��"/�D��$1�$:�$B�$B�$D�$D�D�!�&�,�D�J�J�Jrc�B�t�|j|��Sr)rrdr�rfs  rrgzPMap._Evolver.__getitem__�s���=�=��!6��<�<�<rc�2�|�||��dSr)r�r�s   r�__setitem__zPMap._Evolver.__setitem__�s���H�H�S�#�����rc�F��	�|�f}t�|j|��\}}t|j��d|jzk}|r�|D],\�	}�	|kr!|�ur�	�fd�|D��}||j|<|cS�-|r*|���|�|���S|g}|�|��||j|<|xjdz
c_nG|r*|���|�|���S|g|j|<|xjdz
c_|S)Ngq=
ףp�?c�2��g|]\}}|�kr||fn|�f��Sr*r*)�.0�k2�v2rr�s   ��r�
<listcomp>z%PMap._Evolver.set.<locals>.<listcomp>�s4���)b�)b�)b�QW�QS�UW�b�A�g�g�2�r�(�(�B��9�)b�)b�)brr|)rr`r�rrP�_reallocater��extend)
rr]r��kvr^r_�reallocation_requiredr �
new_bucketrs
  `      @rr�zPMap._Evolver.set�se�����s��B� �,�,�T�-B�C�H�H�M�E�6�$'��(=�$>�$>���
�AR�$R�!��
 �"�$�$�D�A�q��C�x�x��C�<�<�)b�)b�)b�)b�)b�[a�)b�)b�)b�J�;E�D�1�%�8�#���� �)�.��$�$�&�&�&��8�8�C��-�-�-� �T�
��!�!�&�)�)�)�/9��%�e�,��
�
�a��
�
�
�(�.��$�$�&�&�&��8�8�C��-�-�-�02�t��%�e�,��
�
�a��
�
��Krc��dt|j��z}|dgz}|j���}tjd�|D����D]E\}}t|��|z}||r||�||f���=||fg||<�Ft�����|_|j�	|��dS)N�c3�K�|]}|�|V��	dSrr*)r�rAs  r�	<genexpr>z,PMap._Evolver._reallocate.<locals>.<genexpr>�s'����+D�+D�!�!�+D�A�+D�+D�+D�+D�+D�+Dr)
rr�r�r�
from_iterabler\�appendrr�r�)r�new_size�new_listrYrr r^s       rr�zPMap._Evolver._reallocate�s����3�t�4�5�5�5�H��4�&�(�H��+�6�6�8�8�G��+�+D�+D�w�+D�+D�+D�D�D�
/�
/���1��Q���(�*���E�?�/��U�O�*�*�A�q�6�2�2�2�2�()�1�v�h�H�U�O�O�%,�I�I�$5�$5�$7�$7�D�!��!�(�(��2�2�2�2�2rc�4�|j���Sr)r��is_dirtyrs rr�zPMap._Evolver.is_dirty�s���(�1�1�3�3�3rc��|���r1t|j|j�����|_|jSr)r�rrPr�r�r�rs rr�zPMap._Evolver.persistent�s?���}�}���
[�&*�4�:�t�7L�7W�7W�7Y�7Y�&Z�&Z��#��&�&rc��|jSrr�rs rrzPMap._Evolver.__len__�s
���:�rc�B�t�|j|��Sr)rrir�rfs  rr3zPMap._Evolver.__contains__�s���>�>�$�"7��=�=�=rc�0�|�|��dSr)r�rfs  r�__delitem__zPMap._Evolver.__delitem__�s���K�K������rc�.��t�|j���\}}|rN�fd�|D��}t|��t|��kr |r|nd|j|<|xjdzc_|Std�������)Nc�*��g|]\}}|�k�||f��Sr*r*)r�rr r]s   �rr�z(PMap._Evolver.remove.<locals>.<listcomp>�s&���F�F�F��!�Q�Q�#�X�X�q�!�f�X�X�Xrr|z{0})rr`r�rrPrbrq)rr]r^r_r�s `   rr�zPMap._Evolver.remove�s���� �,�,�T�-B�C�H�H�M�E�6��
 �F�F�F�F�6�F�F�F�
��v�;�;��Z���0�0�AK�3U�:�:�QU�D�)�%�0��J�J�!�O�J�J��K��5�<�<��,�,�-�-�-rN)r&r'r(�	__slots__rrgr�r�r�r�r�rr3r�r�r*rr�_Evolverr��s�������C�	�	-�	-�	-�
	=�	=�	=�	�	�	�	�	�	�B	3�	3�	3� 	4�	4�	4�	'�	'�	'�	�	�	�	>�	>�	>�	�	�	�
	.�
	.�
	.�
	.�
	.rr�c�,�|�|��S)a-
        Create a new evolver for this pmap. For a discussion on evolvers in general see the
        documentation for the pvector evolver.

        Create the evolver and perform various mutating updates to it:

        >>> m1 = m(a=1, b=2)
        >>> e = m1.evolver()
        >>> e['c'] = 3
        >>> len(e)
        3
        >>> del e['a']

        The underlying pmap remains the same:

        >>> m1 == {'a': 1, 'b': 2}
        True

        The changes are kept in the evolver. An updated pmap can be created using the
        persistent() function on the evolver.

        >>> m2 = e.persistent()
        >>> m2 == {'b': 2, 'c': 3}
        True

        The new pmap will share data with the original pmap in the same way that would have
        been done if only using operations on the pmap.
        )r�rs rr�zPMap.evolver�s��:�}�}�T�"�"�"r)/r&r'r(r)r�rV�staticmethodr`rdrgrir3r�getr0r$rsrlr/rGrzrr�rr=rB�__ne__r��__le__�__gt__�__ge__r:r�r�r�r�r�r�r��__or__r�rr�rr�r��
__classcell__)rZs@rrrjs��������$�$�JE�I����������\��
����\��1�1�1��	�	��\�	�2�2�2��+�C����>�>�>������������� � � ����������3�3�3�=�=�=�$�^�F�3�3�3��F�
�F�
�F����!�!�!�
9�9�9� 	7�	7�	7���� 	7�	7�	7�$�$�$�."�"�"��F�#�#�#�0�0�0�8���[.�[.�[.�[.�[.�6�[.�[.�[.�z#�#�#�#�#�#�#rrc���|r|}n(	dt|��zpd}n#t$rd}YnwxYw|dgz}t|t��st	|��}|���D]C\}}t
|��}||z}||}|r|�||f���;||fg||<�Dtt|��t���
|����S)Nr��)rrIr
rr�r�r\r�rrr�)	�initial�pre_sizerXrYrr �hr^r_s	         r�_turbo_mappingr�s�������	��s�7�|�|�#�(�q�D�D���	�	�	��D�D�D�	����
�d�V�m�G��g�w�'�'� ��w�-�-���
�
���&�&���1���G�G���D��������	&��M�M�1�a�&�!�!�!�!� �!�f�X�G�E�N�N���G���g�i�i�.�.�w�7�7�8�8�8s��+�+c�@�|s
|dkrtSt||��S)a�
    Create new persistent map, inserts all elements in initial into the newly created map.
    The optional argument pre_size may be used to specify an initial size of the underlying bucket vector. This
    may have a positive performance impact in the cases where you know beforehand that a large number of elements
    will be inserted into the map eventually since it will reduce the number of reallocations required.

    >>> pmap({'a': 13, 'b': 14}) == {'a': 13, 'b': 14}
    True
    r)�_EMPTY_PMAPr�)r�r�s  rrr)s*����x�1�}�}����'�8�,�,�,rc� �t|��S)z�
    Creates a new persistent map. Inserts all key value arguments into the newly created map.

    >>> m(a=13, b=14) == {'a': 13, 'b': 14}
    True
    )r)�kwargss rrr9s����<�<�rN)�collections.abcrr�	itertoolsr�pyrsistent._pvectorr�pyrsistent._transformationsrr
r,rErr�registerr�r�rrr*rr�<module>r�s���-�-�-�-�-�-�-�-�������'�'�'�'�'�'�1�1�1�1�1�1�#>�#>�#>�#>�#>�#>�#>�#>�J���������>)�)�)�)�)��)�)�)�@V#�V#�V#�V#�V#�6�V#�V#�V#�p����������$����9�9�9�@�n�R��#�#���a�
-�
-�
-�
-� ����r

?>