%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/__pycache__/jsonpointer.cpython-312.pyc

�

�^ZD&���dZddlmZdZdZdZdZ	ddlmZe	Z
	ddl
mZmZdd	lmZdd
lZdd
lZe�Zdd�Zefd�Zd
�ZGd�de�ZGd�de�ZGd�de�Zd�Zd�Zy
#e$reZY�[wxYw#e$rddlmZmZY�ewxYw)z7 Identify specific nodes in a JSON document (RFC 6901) �)�unicode_literalsu Stefan Kögl <stefan@skoegl.net>z2.0z2https://github.com/stefankoegl/python-json-pointerzModified BSD License)�izip)�Mapping�Sequence)�teeNc�>�t|�}|j|||�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    �-/usr/lib/python3/dist-packages/jsonpointer.py�set_pointerr?s!��,�'�"�G��;�;�s�E�7�+�+�c�<�t|�}|j||�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_pointerrYs ��H�'�"�G��?�?�3��(�(rc�F�t|�\}}|D]}nt||�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�s/���x�=�D�A�q�
���
����1�:�rc��eZdZy)�JsonPointerExceptionN)�__name__�
__module__�__qualname__�rrrr�s��rrc��eZdZdZd�Zd�Zy)�	EndOfListz)Result of accessing element "-" of a listc��||_y�N)�list_)�selfr&s  r�__init__zEndOfList.__init__�s	����
rc�v�dj|jjt|j���S)Nz{cls}({lst}))�cls�lst)�format�	__class__r�reprr&�r's r�__repr__zEndOfList.__repr__�s2���$�$����)@�)@�)-�d�j�j�)9�%�;�	;rN)rrr �__doc__r(r0r!rrr#r#�s��3��;rr#c��eZdZdZej
d�Zej
d�Zd�Zd�Z	e
fd�ZeZdd�Z
d�Zd	�Zd
�Zd�Zed��Zd
�Zd�Zed��Zy)r	z;A JSON Pointer that can reference parts of an JSON documentz0|[1-9][0-9]*$z(~[^01]|~$)c�6�|jj|�}|r(tdj|j	����|jd�}|j
d�dk7rtd��|D�cgc]
}t|���}}||_ycc}w)NzFound invalid escape {}�/r�zlocation must starts with /)	�_RE_INVALID_ESCAPE�searchrr,�group�split�pop�unescape�parts)r'r�invalid_escaper<�parts     rr(zJsonPointer.__init__�s����0�0�7�7��@���&�'@�'G�'G��$�$�&�((�)�
)��
�
�c�"���9�9�Q�<�2��&�'D�E�E�,1�2�D��$��2��2���
��3s�:Bc��|js|dfS|jddD]}|j||�}�||j||jd�fS)z>Resolves ptr until the last step, returns (sub-doc, last-step)N���)r<�walk�get_part�r'rr>s   r�to_lastzJsonPointer.to_last�s^���z�z���9���J�J�s��O�	'�D��)�)�C��&�C�	'��D�M�M�#�t�z�z�"�~�6�6�6rc��|jD]}	|j||�}�|S#t$r|tur�|cYcSwxYw)zBResolves the pointer against doc and returns the referenced object)r<rAr�_nothing)r'rrr>s    rrzJsonPointer.resolve�sT���J�J�	#�D�
#��i�i��T�*��	#��
��
(�
#��h�&��"�N�	
#�s�'�A�Ac��t|j�dk(r|rtd��|S|stj|�}|j|�\}}|||<|S)zFResolve the pointer against the doc and replace the target with value.rzcannot set root in place)�lenr<r�copy�deepcopyrD)r'rr
r�parentr>s      rr
zJsonPointer.set�sY���t�z�z�?�a���*�+E�F�F��L���-�-��$�C����c�*������t���
rc��t|t�r|St|t�rD|dk(r|S|jj	t|��st
d|z��t|�St|d�r|St
dt|�z��)z)Returns the next step in the correct type�-z"'%s' is not a valid sequence index�__getitem__zXDocument '%s' does not support indexing, must be mapping/sequence or support __getitem__)
�
isinstancerr�_RE_ARRAY_INDEX�match�strr�int�hasattr�typerCs   rrBzJsonPointer.get_part�s����c�7�#��K�
��X�
&��s�{����'�'�-�-�c�$�i�8�*�+O�RV�+V�W�W��t�9��
�S�-�
(��K�'�(Y�[_�`c�[d�(e�f�
frc�0�|j||�}t|d�sJdt|�����t|t�r|dk(rt|�S	||S	||S#t$rtd|�d���wxYw#t$rtd|�d|����wxYw)z7 Walks one step in doc and returns the referenced part rNzinvalid document type rMzindex 'z' is out of boundszmember 'z' not found in )	rBrTrUrOrr#�
IndexErrorr�KeyErrorrCs   rrAzJsonPointer.walks����}�}�S�$�'���s�M�*�U�$�s�)�,U�U�*��c�8�$��s�{� ��~�%�
U��4�y� �	T��t�9����
U�*�D�+S�T�T�
U���	T�&��c�'R�S�S�	T�s�A�A:�A7�:Bc�`�|jdt|j�|jk(S)�- Returns True if self contains the given ptr N)r<rH)r'�ptrs  r�containszJsonPointer.containss$���z�z�/�3�s�y�y�>�*�c�i�i�7�7rc�$�|j|�S)rZ)r\)r'�items  r�__contains__zJsonPointer.__contains__s���}�}�T�"�"rc��|jD�cgc]
}t|���}}djd�|D��Scc}w)zwReturns the string representation of the pointer

        >>> ptr = JsonPointer('/~0/0/~1').path == '/~0/0/~1'
        r5c3�&K�|]	}d|z���y�w�r4Nr!��.0r>s  r�	<genexpr>z#JsonPointer.path.<locals>.<genexpr>)s����4�d�s�T�z�4���)r<�escape�join)r'r>r<s   r�pathzJsonPointer.path"s9��+/�*�*�5�$����5��5��w�w�4�e�4�4�4��6s�;c�V�t|t�sy|j|jk(S)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)rOr	r<)r'�others  r�__eq__zJsonPointer.__eq__+s$���%��-���z�z�U�[�[�(�(rc�>�tt|j��Sr%)�hash�tupler<r/s r�__hash__zJsonPointer.__hash__8s���E�$�*�*�%�&�&rc��|D�cgc]}tt|����}}|djd�|D���}|Scc}w)z�Constructs a JsonPointer from a list of (unescaped) paths

        >>> JsonPointer.from_parts(['a', '~', '/', 0]).path == '/a/~0/~1/0'
        True
        r5c3�&K�|]	}d|z���y�wrbr!rcs  rrez)JsonPointer.from_parts.<locals>.<genexpr>Cs����7��#��*�7�rf)rgrRrh)r*r<r>r[s    r�
from_partszJsonPointer.from_parts;sC��05�5�t���D�	�"�5��5��"�'�'�7��7�7�8���
��6s�AN�T)rrr r1�re�compilerPr6r(rDrFr�getr
rBrAr\r_�propertyrirlrp�classmethodrsr!rrr	r	�s���E�!�b�j�j�!1�2�O�#����M�2��
�	7�$,�
��C�� f�4T�28�#��5��5�)�'����rr	c�F�|jdd�jdd�S)N�~�~0r4�~1��replace��ss rrgrgGs ���9�9�S�$��'�'��T�2�2rc�F�|jdd�jdd�S)Nr}r4r|r{r~r�s rr;r;Js ���9�9�T�3��'�'��c�2�2rrt)r1�
__future__r�
__author__�__version__�__website__�__license__�	itertoolsr�unicoderR�ImportError�zip�collections.abcrr�collectionsrrurI�objectrFrrr�	Exceptionrr#r	rgr;r!rr�<module>r�s���B>�'�0�
���B��$����
�C�.�1��	���8��,�4+3�%)�P�(	�9�	�;��;�`�&�`�F3�3��w���D���
�.�-�-�.�s"�A,�A9�,A6�5A6�9
B	�B	

Zerion Mini Shell 1.0