HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/1784574/root/lib/python3/dist-packages/__pycache__/
Upload File :
Current File : //proc/1784574/root/lib/python3/dist-packages/__pycache__/jsonpointer.cpython-311.pyc
�

q�Rb�*��F�dZddlmZdZdZdZdZ	ddlmZe	Z
d�Zn#e$re
Zd	�ZYnwxYw	dd
lmZmZn#e$rdd
lmZmZYnwxYwddlmZmZddlZddlZe��Zdd�Zefd�Zd�ZGd�de��ZGd�de��ZGd�de��Zd�Zd�Z dS)z7 Identify specific nodes in a JSON document (RFC 6901) �)�unicode_literalsu Stefan Kögl <stefan@skoegl.net>z2.3z2https://github.com/stefankoegl/python-json-pointerzModified BSD License)�izipc�,�|�d��S)N�raw_unicode_escape)�encode��us �-/usr/lib/python3/dist-packages/jsonpointer.py�<lambda>r/s��1�8�8�$8�9�9��c��|S�N�rs r
rr2s��1�r)�Mapping�Sequence)�tee�chainNTc�N�t|��}|�|||��S)a�Resolves pointer against doc and sets the value of the target within doc.

    With inplace set to true, doc is modified as long as pointer is not the
    root.

    >>> obj = {'foo': {'anArray': [ {'prop': 44}], 'another prop': {'baz': 'A string' }}}

    >>> set_pointer(obj, '/foo/anArray/0/prop', 55) ==     {'foo': {'another prop': {'baz': 'A string'}, 'anArray': [{'prop': 55}]}}
    True

    >>> set_pointer(obj, '/foo/yet another prop', 'added prop') ==     {'foo': {'another prop': {'baz': 'A string'}, 'yet another prop': 'added prop', 'anArray': [{'prop': 55}]}}
    True

    >>> obj = {'foo': {}}
    >>> set_pointer(obj, '/foo/a%20b', 'x') ==     {'foo': {'a%20b': 'x' }}
    True
    )�JsonPointer�set)�doc�pointer�value�inplaces    r
�set_pointerrAs'��,�'�"�"�G��;�;�s�E�7�+�+�+rc�L�t|��}|�||��S)aa Resolves pointer against doc and returns the referenced object

    >>> obj = {'foo': {'anArray': [ {'prop': 44}], 'another prop': {'baz': 'A string' }}, 'a%20b': 1, 'c d': 2}

    >>> resolve_pointer(obj, '') == obj
    True

    >>> resolve_pointer(obj, '/foo') == obj['foo']
    True

    >>> resolve_pointer(obj, '/foo/another prop') == obj['foo']['another prop']
    True

    >>> resolve_pointer(obj, '/foo/another prop/baz') == obj['foo']['another prop']['baz']
    True

    >>> resolve_pointer(obj, '/foo/anArray/0') == obj['foo']['anArray'][0]
    True

    >>> resolve_pointer(obj, '/some/path', None) == None
    True

    >>> resolve_pointer(obj, '/a b', None) == None
    True

    >>> resolve_pointer(obj, '/a%20b') == 1
    True

    >>> resolve_pointer(obj, '/c d') == 2
    True

    >>> resolve_pointer(obj, '/c%20d', None) == None
    True
    )r�resolve)rr�defaults   r
�resolve_pointerr[s&��H�'�"�"�G��?�?�3��(�(�(rc�P�t|��\}}|D]}t||��S)z� Transforms a list to a list of tuples of adjacent items

    s -> (s0,s1), (s1,s2), (s2, s3), ...

    >>> list(pairwise([]))
    []

    >>> list(pairwise([1]))
    []

    >>> list(pairwise([1, 2, 3, 4]))
    [(1, 2), (2, 3), (3, 4)]
    )rr)�iterable�a�b�_s    r
�pairwiser%�s3���x�=�=�D�A�q�
����
���1�:�:�rc��eZdZdS)�JsonPointerExceptionN)�__name__�
__module__�__qualname__rrr
r'r'�s�������Drr'c��eZdZdZd�Zd�ZdS)�	EndOfListz)Result of accessing element "-" of a listc��||_dSr)�list_)�selfr.s  r
�__init__zEndOfList.__init__�s
����
�
�
rc�h�d�|jjt|j�����S)Nz{cls}({lst}))�cls�lst)�format�	__class__r(�reprr.�r/s r
�__repr__zEndOfList.__repr__�s3���$�$���)@�)-�d�j�)9�)9�%�;�;�	;rN)r(r)r*�__doc__r0r8rrr
r,r,�s8������3�3����;�;�;�;�;rr,c��eZdZdZejd��Zejd��Zd�Zd�Z	e
fd�ZeZdd�Z
ed	���Zd
�Zd�Zd�Zd
�Zd�Zd�ZeZed���Zd�Zd�Zd�Zd�Zed���ZdS)rz:A JSON Pointer that can reference parts of a JSON documentz0|[1-9][0-9]*$z(~[^01]|~$)c�F�|j�|��}|r4td�|��������|�d��}|�d��dkrtd���d�|D��}||_dS)NzFound invalid escape {}�/r�zLocation must start with /c�,�g|]}t|����Sr)�unescape��.0�parts  r
�
<listcomp>z(JsonPointer.__init__.<locals>.<listcomp>�s��2�2�2�D��$���2�2�2r)�_RE_INVALID_ESCAPE�searchr'r4�group�split�pop�parts)r/r�invalid_escaperIs    r
r0zJsonPointer.__init__�s����0�7�7��@�@���	)�&�'@�'G�'G��$�$�&�&�((�((�)�)�
)��
�
�c�"�"���9�9�Q�<�<�2���&�'C�D�D�D�2�2�E�2�2�2����
�
�
rc��|js|dfS|jdd�D]}|�||��}�|t�||jd��fS)z>Resolves ptr until the last step, returns (sub-doc, last-step)N���)rI�walkr�get_part�r/rrBs   r
�to_lastzJsonPointer.to_last�sg���z�	���9���J�s��s�O�	'�	'�D��)�)�C��&�&�C�C��K�(�(��d�j��n�=�=�=�=rc��|jD]7}	|�||��}�#t$r|tur�|cYcSwxYw|S)zBResolves the pointer against doc and returns the referenced object)rIrMr'�_nothing)r/rrrBs    r
rzJsonPointer.resolve�sl���J�	#�	#�D�
#��i�i��T�*�*����'�
#�
#�
#��h�&�&��"�N�N�N�N�N�	
#�����
s�"�=�=Tc�$�t|j��dkr|rtd���|S|stj|��}|�|��\}}t
|t��r|dkr|�|��n|||<|S)zFResolve the pointer against the doc and replace the target with value.rzCannot set root in place�-)	�lenrIr'�copy�deepcopyrP�
isinstancer�append)r/rrr�parentrBs      r
rzJsonPointer.set�s����t�z�?�?�a����
G�*�+E�F�F�F��L��	%��-��$�$�C����c�*�*�����f�h�'�'�	!�D�C�K�K��M�M�%� � � � � �F�4�L��
rc�f�t|t��r|St|t��rU|dkr|Stj�t
|����std|z���t|��St|d��r|Stdt|��z���)z)Returns the next step in the correct typerTz"'%s' is not a valid sequence index�__getitem__zXDocument '%s' does not support indexing, must be mapping/sequence or support __getitem__)rXrrr�_RE_ARRAY_INDEX�match�strr'�int�hasattr�type)r2rrBs   r
rNzJsonPointer.get_part�s����c�7�#�#�	f��K�
��X�
&�
&�	f��s�{�{����.�4�4�S��Y�Y�?�?�
X�*�+O�RV�+V�W�W�W��t�9�9��
�S�-�
(�
(�	f��K�'�(Y�[_�`c�[d�[d�(e�f�f�
frc��|jS)zYReturns the list of the parts. For example, JsonPointer('/a/b').get_parts() == ['a', 'b'])rIr7s r
�	get_partszJsonPointer.get_partss���z�rc��t�||��}t|d��sJdt|�������t	|t
��r?|dkrt
|��S	||S#t$rtd|�d����wxYw	||S#t$rtd|�d|�����wxYw)z7 Walks one step in doc and returns the referenced part r\zinvalid document type rTzindex 'z' is out of boundszmember 'z' not found in )
rrNrarbrXrr,�
IndexErrorr'�KeyErrorrOs   r
rMzJsonPointer.walk
s����#�#�C��.�.���s�M�*�*�U�U�U�$�s�)�)�)�,U�U�U�U��c�8�$�$�	U��s�{�{� ��~�~�%�
U��4�y� ���
U�
U�
U�*�*�D�D�D�+S�T�T�T�
U����	T��t�9����	T�	T�	T�&�&����c�c�'R�S�S�S�	T���s�1A9�9B�B#�# Cc�V�|jdt|j���|jkS)�- Returns True if self contains the given ptr N)rIrU)r/�ptrs  r
�containszJsonPointer.contains&s"���z�/�3�s�y�>�>�/�*�c�i�7�7rc�,�|�|��S)ri)rk)r/�items  r
�__contains__zJsonPointer.__contains__*s���}�}�T�"�"�"rc��t|t��r|j}n,t|t��rt|��j}n|}	t�t|j|����S#t
d���xYw)zD Returns a new JsonPointer with the given suffix append to this ptr zInvalid suffix)rXrrIr_�
from_partsrr')r/�suffix�suffix_partss   r
�joinzJsonPointer.join.s����f�k�*�*�	"�!�<�L�L�
���
$�
$�	"�&�v�.�.�4�L�L�!�L�	9��)�)�%��
�L�*I�*I�J�J�J��	9�&�'7�8�8�8���s�,A8�8B	c�,�|�|��Sr�rs)r/rqs  r
�__truediv__zJsonPointer.__truediv__;s���y�y�� � � rc�b�d�|jD��}d�d�|D����S)zwReturns the string representation of the pointer

        >>> ptr = JsonPointer('/~0/0/~1').path == '/~0/0/~1'
        c�,�g|]}t|����Sr)�escaper@s  r
rCz$JsonPointer.path.<locals>.<listcomp>Es��5�5�5�$�����5�5�5rr=c3� K�|]	}d|zV��
dS�r<Nrr@s  r
�	<genexpr>z#JsonPointer.path.<locals>.<genexpr>Fs&����4�4�d�s�T�z�4�4�4�4�4�4r)rIrs)r/rIs  r
�pathzJsonPointer.path?s:��6�5�$�*�5�5�5���w�w�4�4�e�4�4�4�4�4�4rc�P�t|t��sdS|j|jkS)aCompares a pointer to another object

        Pointers can be compared by comparing their strings (or splitted
        strings), because no two different parts can point to the same
        structure in an object (eg no different number representations)
        F)rXrrI)r/�others  r
�__eq__zJsonPointer.__eq__Hs*���%��-�-�	��5��z�U�[�(�(rc�D�tt|j����Sr)�hash�tuplerIr7s r
�__hash__zJsonPointer.__hash__Us���E�$�*�%�%�&�&�&rc�*�t|j��Sr)�
encode_strr}r7s r
�__str__zJsonPointer.__str__Xs���$�)�$�$�$rc�6�dt|j��zdzS)NzJsonPointer(�))r6r}r7s r
r8zJsonPointer.__repr__[s����T�Y���/�#�5�5rc�n�d�|D��}|d�d�|D������}|S)z�Constructs a JsonPointer from a list of (unescaped) paths

        >>> JsonPointer.from_parts(['a', '~', '/', 0]).path == '/a/~0/~1/0'
        True
        c�F�g|]}tt|������Sr)ryr_r@s  r
rCz*JsonPointer.from_parts.<locals>.<listcomp>es&��5�5�5�t���D�	�	�"�"�5�5�5rr=c3� K�|]	}d|zV��
dSr{rr@s  r
r|z)JsonPointer.from_parts.<locals>.<genexpr>fs&����7�7��#��*�7�7�7�7�7�7rru)r2rIrjs   r
rpzJsonPointer.from_parts^sF��6�5�u�5�5�5���c�"�'�'�7�7��7�7�7�7�7�8�8���
rN�T)r(r)r*r9�re�compiler]rDr0rPrRr�getr�classmethodrNrdrMrkrnrsrv�__div__�propertyr}r�r�r�r8rprrr
rr�s�������D�D�!�b�j�!1�2�2�O�#���M�2�2��
�
�
�	>�	>�	>�$,�
�
�
�
��C�����(�f�f��[�f�2���T�T�T�28�8�8�#�#�#�9�9�9�!�!�!��G�
�5�5��X�5�)�)�)�'�'�'�%�%�%�6�6�6�����[���rrc�V�|�dd���dd��S)N�~�~0r<�~1��replace��ss r
ryryjs&���9�9�S�$���'�'��T�2�2�2rc�V�|�dd���dd��S)Nr�r<r�r�r�r�s r
r?r?ms&���9�9�T�3���'�'��c�2�2�2rr�)!r9�
__future__r�
__author__�__version__�__website__�__license__�	itertoolsr�unicoder_r��ImportError�zip�collections.abcrr�collectionsrrr�rV�objectrRrrr%�	Exceptionr'r,rryr?rrr
�<module>r�s��B>�=�'�'�'�'�'�'�0�
���B��$���������
�C�9�9�J�J�������D���J�J�J�����.�1�1�1�1�1�1�1�1�1���.�.�.�-�-�-�-�-�-�-�-�-�-�.����!� � � � � � � �	�	�	�	������6�8�8��,�,�,�,�4+3�%)�%)�%)�%)�P���(	�	�	�	�	�9�	�	�	�;�;�;�;�;��;�;�;�A�A�A�A�A�&�A�A�A�H3�3�3�3�3�3�3�3s��
+�+�8�
A�A