Revonzy Mini Shell

Revonzy Mini Shell

Şuanki Dizin: /proc/self/root/lib/python3.9/site-packages/__pycache__/
Dosya Yükle :
Şuanki Dosya : //proc/self/root/lib/python3.9/site-packages/__pycache__/jsonpatch.cpython-39.pyc

a

d�GZ�_�@s�dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZdZ
dZzddlmZmZWn&ey�ddlmZmZeZYn0dZdZd	Zd
Ze	jdkr�eefZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�dee �Z!dd�Z"ej#ej$e"d�Z%d0dd�Z&dd�Z'Gdd�de(�Z)Gdd�de(�Z*Gd d!�d!e*�Z+Gd"d#�d#e*�Z,Gd$d%�d%e*�Z-Gd&d'�d'e*�Z.Gd(d)�d)e*�Z/Gd*d+�d+e*�Z0Gd,d-�d-e(�Z1d.d/�Z2dS)1z Apply JSON-Patches (RFC 6902) �)�unicode_literalsN)�JsonPointer�JsonPointerException�)�MutableMapping�MutableSequenceu Stefan Kögl <stefan@skoegl.net>z1.21z0https://github.com/stefankoegl/python-json-patchzModified BSD License)�rc@seZdZdZdS)�JsonPatchExceptionzBase Json Patch exceptionN��__name__�
__module__�__qualname__�__doc__�rr�-/usr/lib/python3.9/site-packages/jsonpatch.pyr	Gsr	c@seZdZdZdS)�InvalidJsonPatchz, Raised if an invalid JSON Patch is created Nr
rrrrrKsrc@seZdZdZdS)�JsonPatchConflictaRaised if patch could not be applied due to conflict situation such as:
    - attempt to add object key then it already exists;
    - attempt to operate with nonexistence object key;
    - attempt to insert value to array at position beyond of it size;
    - etc.
    Nr
rrrrrOsrc@seZdZdZdS)�JsonPatchTestFailedz A Test operation failed Nr
rrrrrXsrcCs<t�t�}|D]\}}||�|�qtdd�|��D��S)z'Convert duplicate keys values to lists.css.|]&\}}|t|�dkr |dn|fVqdS)rrN)�len)�.0�key�valuesrrr�	<genexpr>cs�zmultidict.<locals>.<genexpr>)�collections�defaultdict�list�append�dict�items)Z
ordered_pairsZmdictr�valuerrr�	multidict\s
�r )Zobject_pairs_hookFcCs*t|t�rt�|�}nt|�}|�||�S)aOApply list of patches to specified json document.

    :param doc: Document object.
    :type doc: dict

    :param patch: JSON patch as list of dicts or raw JSON-encoded string.
    :type patch: list or str

    :param in_place: While :const:`True` patch will modify target document.
                     By default patch will be applied to document copy.
    :type in_place: bool

    :return: Patched document object.
    :rtype: dict

    >>> doc = {'foo': 'bar'}
    >>> patch = [{'op': 'add', 'path': '/baz', 'value': 'qux'}]
    >>> other = apply_patch(doc, patch)
    >>> doc is not other
    True
    >>> other == {'foo': 'bar', 'baz': 'qux'}
    True
    >>> patch = [{'op': 'add', 'path': '/baz', 'value': 'qux'}]
    >>> apply_patch(doc, patch, in_place=True) == {'foo': 'bar', 'baz': 'qux'}
    True
    >>> doc == other
    True
    )�
isinstance�
basestring�	JsonPatch�from_string�apply)�doc�patch�in_placerrr�apply_patchos
r)cCst�||�S)a�Generates patch by comparing of two document objects. Actually is
    a proxy to :meth:`JsonPatch.from_diff` method.

    :param src: Data source document object.
    :type src: dict

    :param dst: Data source document object.
    :type dst: dict

    >>> src = {'foo': 'bar', 'numbers': [1, 3, 4, 8]}
    >>> dst = {'baz': 'qux', 'numbers': [1, 4, 7]}
    >>> patch = make_patch(src, dst)
    >>> new = patch.apply(src)
    >>> new == dst
    True
    )r#�	from_diff)�src�dstrrr�
make_patch�sr-c@s�eZdZdZdd�Zdd�Zdd�ZeZdd	�Zd
d�Z	dd
�Z
dd�Zedd��Z
eddd��Zdd�Zedd��Zd dd�Zdd�ZdS)!r#agA JSON Patch is a list of Patch Operations.

    >>> patch = JsonPatch([
    ...     {'op': 'add', 'path': '/foo', 'value': 'bar'},
    ...     {'op': 'add', 'path': '/baz', 'value': [1, 2, 3]},
    ...     {'op': 'remove', 'path': '/baz/1'},
    ...     {'op': 'test', 'path': '/baz', 'value': [1, 3]},
    ...     {'op': 'replace', 'path': '/baz/0', 'value': 42},
    ...     {'op': 'remove', 'path': '/baz/1'},
    ... ])
    >>> doc = {}
    >>> result = patch.apply(doc)
    >>> expected = {'foo': 'bar', 'baz': [42]}
    >>> result == expected
    True

    JsonPatch object is iterable, so you could easily access to each patch
    statement in loop:

    >>> lpatch = list(patch)
    >>> expected = {'op': 'add', 'path': '/foo', 'value': 'bar'}
    >>> lpatch[0] == expected
    True
    >>> lpatch == patch.patch
    True

    Also JsonPatch could be converted directly to :class:`bool` if it contains
    any operation statements:

    >>> bool(patch)
    True
    >>> bool(JsonPatch([]))
    False

    This behavior is very handy with :func:`make_patch` to write more readable
    code:

    >>> old = {'foo': 'bar', 'numbers': [1, 3, 4, 8]}
    >>> new = {'baz': 'qux', 'numbers': [1, 4, 7]}
    >>> patch = make_patch(old, new)
    >>> if patch:
    ...     # document have changed, do something useful
    ...     patch.apply(old)    #doctest: +ELLIPSIS
    {...}
    cCs||_ttttttd�|_dS)N)�remove�add�replace�move�test�copy)r'�RemoveOperation�AddOperation�ReplaceOperation�
MoveOperation�
TestOperation�
CopyOperation�
operations)�selfr'rrr�__init__�s�zJsonPatch.__init__cCs|��S)zstr(self) -> self.to_string())�	to_string�r;rrr�__str__�szJsonPatch.__str__cCs
t|j�S�N)�boolr'r>rrr�__bool__�szJsonPatch.__bool__cCs
t|j�Sr@)�iterr'r>rrr�__iter__�szJsonPatch.__iter__cCstt|j��Sr@)�hash�tuple�_opsr>rrr�__hash__�szJsonPatch.__hash__cCst|t�sdS|j|jkS�NF)r!r#rG�r;�otherrrr�__eq__�s
zJsonPatch.__eq__cCs
||kSr@rrJrrr�__ne__�szJsonPatch.__ne__cCst|�}||�S)z�Creates JsonPatch instance from string source.

        :param patch_str: JSON patch as raw string.
        :type patch_str: str

        :return: :class:`JsonPatch` instance.
        )�
_jsonloads)�clsZ	patch_strr'rrrr$�s	zJsonPatch.from_stringTcCs*t�}|�dd||�t|���}||�S)aOCreates JsonPatch instance based on comparing of two document
        objects. Json patch would be created for `src` argument against `dst`
        one.

        :param src: Data source document object.
        :type src: dict

        :param dst: Data source document object.
        :type dst: dict

        :return: :class:`JsonPatch` instance.

        >>> src = {'foo': 'bar', 'numbers': [1, 3, 4, 8]}
        >>> dst = {'baz': 'qux', 'numbers': [1, 4, 7]}
        >>> patch = JsonPatch.from_diff(src, dst)
        >>> new = patch.apply(src)
        >>> new == dst
        True
        �N)�DiffBuilder�_compare_valuesr�execute)rOr+r,�optimizationZbuilder�opsrrrr*szJsonPatch.from_diffcCst�|j�S)z!Returns patch set as JSON string.)�json�dumpsr'r>rrrr=!szJsonPatch.to_stringcCstt|j|j��Sr@)rF�map�_get_operationr'r>rrrrG%szJsonPatch._opsFcCs(|st�|�}|jD]}|�|�}q|S)a/Applies the patch to given object.

        :param obj: Document object.
        :type obj: dict

        :param in_place: Tweaks way how patch would be applied - directly to
                         specified `obj` or to his copy.
        :type in_place: bool

        :return: Modified `obj`.
        )r3�deepcopyrGr%)r;�objr(�	operationrrrr%)s



zJsonPatch.applycCsTd|vrtd��|d}t|t�s*td��||jvrBtd�|���|j|}||�S)N�opz&Operation does not contain 'op' memberzOperation must be a stringzUnknown operation {0!r})rr!r"r:�format)r;r\r]rOrrrrY>s


zJsonPatch._get_operationN)T)F)rrr
rr<r?rBZ__nonzero__rDrHrLrM�classmethodr$r*r=�propertyrGr%rYrrrrr#�s$-


r#c@s^eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Ze	dd
��Z
e	dd��Zejdd��ZdS)�PatchOperationz'A single operation inside a JSON Patch.cCs |d|_t|j�|_||_dS)N�path)�locationr�pointerr\)r;r\rrrr<Qs
zPatchOperation.__init__cCstd��dS)zAAbstract method that applies patch operation to specified object.z!should implement patch operation.N)�NotImplementedError)r;r[rrrr%VszPatchOperation.applycCstt|j����Sr@)rE�	frozensetr\rr>rrrrHZszPatchOperation.__hash__cCst|t�sdS|j|jkSrI)r!rar\rJrrrrL]s
zPatchOperation.__eq__cCs
||kSr@rrJrrrrMbszPatchOperation.__ne__cCsd�|jjdd��S)N�/���)�joinrd�partsr>rrrrbeszPatchOperation.pathcCs6zt|jjd�WSty0|jjdYS0dS)Nrh)�intrdrj�
ValueErrorr>rrrriszPatchOperation.keycCs*t|�|jjd<|jj|_|j|jd<dS)Nrhrb)�strrdrjrbrcr\)r;rrrrrps
N)
rrr
rr<r%rHrLrMr`rbr�setterrrrrraNs

rac@s(eZdZdZdd�Zdd�Zdd�ZdS)	r4z/Removes an object property or an array element.c
CsZ|j�|�\}}z
||=Wn:ttfyT}zd�|�}t|��WYd}~n
d}~00|S)Nz&can't remove non-existent object '{0}')rd�to_last�KeyError�
IndexErrorr^r)r;r[�subobj�part�ex�msgrrrr%zs

zRemoveOperation.applycCs0|j|kr,|j|kr$|jd7_n|d8}|S�Nr�rbr�r;rbrrrr�_on_undo_remove�s


zRemoveOperation._on_undo_removecCs0|j|kr,|j|kr$|jd8_n|d8}|Srvrwrxrrr�_on_undo_add�s


zRemoveOperation._on_undo_addN�rrr
rr%ryrzrrrrr4ws
r4c@s(eZdZdZdd�Zdd�Zdd�ZdS)	r5z,Adds an object property or an array element.c
Cs�z|jd}Wn,ty:}ztd��WYd}~n
d}~00|j�|�\}}t|t�r�|dkrj|�|�q�|t|�ks~|dkr�t	d��q�|�
||�n4t|t�r�|dur�|}q�|||<ntd�
t|����|S)Nr�/The operation does not contain a 'value' member�-rzcan't insert outside of list�invalid document type {0})r\rprrdror!rrrr�insertr�	TypeErrorr^�type)r;r[rrtrrrsrrrr%�s&�



zAddOperation.applycCs0|j|kr,|j|kr$|jd7_n|d7}|Srvrwrxrrrry�s


zAddOperation._on_undo_removecCs0|j|kr,|j|kr$|jd8_n|d7}|Srvrwrxrrrrz�s


zAddOperation._on_undo_addNr{rrrrr5�sr5c@s(eZdZdZdd�Zdd�Zdd�ZdS)	r6z=Replaces an object property or an array element by new value.c
Cs�z|jd}Wn,ty:}ztd��WYd}~n
d}~00|j�|�\}}|durX|St|t�r�|t|�ksv|dkr�td��n8t|t	�r�||vr�d�
|�}t|��ntd�
t|����|||<|S)Nrr|rzcan't replace outside of listz'can't replace non-existent object '{0}'r~)
r\rprrdror!rrrrr^r�r�)r;r[rrtrrrsrurrrr%�s&�




zReplaceOperation.applycCs|Sr@rrxrrrry�sz ReplaceOperation._on_undo_removecCs|Sr@rrxrrrrz�szReplaceOperation._on_undo_addNr{rrrrr6�sr6c@sNeZdZdZdd�Zedd��Zedd��Zejdd��Zd	d
�Z	dd�Z
d
S)r7z=Moves an object property or an array element to new location.c
Cs�zt|jd�}Wn,ty>}ztd��WYd}~n
d}~00|�|�\}}z||}Wn4ttfy�}ztt|���WYd}~n
d}~00|j|kr�|St	|t
�r�|j�|�r�td��td|jdd���
|�}td|j|d���
|�}|S)N�from�.The operation does not contain a 'from' memberz(Cannot move values into its own childrenr.�r]rbr/�r]rbr)rr\rprrorqrrmrdr!r�containsr4r%r5rc�r;r[�from_ptrrtrrrsrrrrr%�s>�"


�����zMoveOperation.applycCs"t|jd�}d�|jdd��S)Nr�rgrh)rr\rirj�r;r�rrr�	from_pathszMoveOperation.from_pathcCs@t|jd�}zt|jd�WSty:|jdYS0dS�Nr�rh)rr\rkrjr�r�rrr�from_keys
zMoveOperation.from_keycCs,t|jd�}t|�|jd<|j|jd<dSr�)rr\rmrjrb)r;rr�rrrr�scCs\|j|kr,|j|kr$|jd7_n|d8}|j|krX|j|krP|jd7_n|d7}|Srv�r�r�rbrrxrrrry#s



zMoveOperation._on_undo_removecCs\|j|kr,|j|kr$|jd8_n|d8}|j|krX|j|krP|jd8_n|d7}|Srvr�rxrrrrz0s



zMoveOperation._on_undo_addN)rrr
rr%r`r�r�rnryrzrrrrr7�s"



r7c@seZdZdZdd�ZdS)r8z!Test value by specified location.c
Cs�z0|j�|�\}}|dur |}n|j�||�}Wn0ty`}ztt|���WYd}~n
d}~00z|jd}Wn,ty�}ztd��WYd}~n
d}~00||kr�d}t|�	|t
|�|t
|����|S)Nrr|z0{0} ({1}) is not equal to tested value {2} ({3}))rdro�walkrrrmr\rprr^r�)r;r[rrrs�valrtrrurrrr%As&"��zTestOperation.applyN�rrr
rr%rrrrr8>sr8c@seZdZdZdd�ZdS)r9zA Copies an object property or an array element to a new location c
Cs�zt|jd�}Wn,ty>}ztd��WYd}~n
d}~00|�|�\}}zt�||�}Wn4ttfy�}ztt	|���WYd}~n
d}~00t
d|j|d���|�}|S)Nr�r�r/r�)
rr\rprror3rZrqrrmr5rcr%r�rrrr%\s&�"��zCopyOperation.applyNr�rrrrr9Ysr9c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)rQcCs4iig|_ggg|_g|_}||dg|dd�<dSr@)�
index_storage�index_storage2�_DiffBuilder__root)r;�rootrrrr<ts


zDiffBuilder.__init__cCsfz:|j|}|�|�}|dur*|g||<n||�|�Wn&ty`|j|�||f�Yn0dSr@)r��getrr�r�)r;r�index�st�storage�storedrrr�store_indexzs

zDiffBuilder.store_indexcCs�z"|j|�|�}|r |��WSWn\ty~|j|}tt|�ddd�D]*}||d|krN|�|�dYSqNYn0dS)Nrrhr)r�r��popr�r��ranger)r;rr�r�r��irrr�
take_index�s
zDiffBuilder.take_indexcCs,|j}|d}|||g|d<|d<|dS)Nrr�r�)r;r]r�Zlastrrrr�szDiffBuilder.insertcCs*|\}}}||d<||d<g|dd�<dS)Nrrr)r;r�Z	link_prevZ	link_next�_rrrr.�s
zDiffBuilder.removeccs.|j}|d}||ur*|dV|d}qdS�Nr�r�)r;�startr��currrrr�	iter_from�s

zDiffBuilder.iter_fromccs.|j}|d}||ur*|dV|d}qdSr�r�)r;r�r�rrrrD�s

zDiffBuilder.__iter__ccs�|j}|d}||ur�|d|ur�|d|dd}}|j|jkr�t|�tkr�t|�tkr�td|j|jdd��jV|dd}q|djV|d}qdS)Nrr�r0rr�)r�rcr�r4r5r6r\)r;r�r�Zop_firstZ	op_secondrrrrS�s&
�
��zDiffBuilder.executec	Cs�|�|t�}|dur�|d}t|j�tkrL|�|�D]}|�|j|j�|_q4|�|�|j	t
||�kr�td|j	t
||�d��}|�|�n.t
dt
||�|d��}|�|�}|�||t�dS)Nr�r1�r]r�rbr/r�)r��
_ST_REMOVEr�rrkr�ryrbr.rc�
_path_joinr7rr5r��_ST_ADD)	r;rbr�itemr�r]�v�new_op�	new_indexrrr�_item_added�s*
��
zDiffBuilder._item_addedc	Cs�tdt||�d��}|�|t�}|�|�}|dur�|d}t|j�tkrj|�|�D]}|�	|j
|j�|_qR|�|�|j|jkr�t
d|j|jd��}||d<q�|�|�n|�||t�dS)Nr.r�r�r1r�)r4r�r�r�rr�rrkr�rzrbr.rcr7r�r�)	r;rbrr�r�r�r�r]r�rrr�
_item_removed�s*�

�
zDiffBuilder._item_removedcCs |�tdt||�|d���dS)Nr0r�)rr6r�)r;rbrr�rrr�_item_replaced�s
�zDiffBuilder._item_replacedc	Cs�t|���}t|���}||}||}|D]}|�|t|�||�q,|D]}|�|t|�||�qL||@D]}|�||||||�qpdSr@)�set�keysr�rmr�rR)	r;rbr+r,Zsrc_keysZdst_keysZ
added_keysZremoved_keysrrrr�_compare_dicts�szDiffBuilder._compare_dictscCs�t|�t|�}}t||�}t||�}t|�D]�}||kr�||||}	}
|	|
krXq.q�t|	t�r�t|
t�r�|�t||�|	|
�q�t|	t�r�t|
t�r�|�	t||�|	|
�q�|�
|||	�|�|||
�q.||kr�|�
||||�q.|�||||�q.dSr@)r�max�minr�r!rr�r�r�_compare_listsr�r�)r;rbr+r,Zlen_srcZlen_dstZmax_lenZmin_lenr�old�newrrrr�s*


�
�zDiffBuilder._compare_listscCsr||krdSt|t�r6t|t�r6|�t||�||�n8t|t�r`t|t�r`|�t||�||�n|�|||�dSr@)r!rr�r�rr�r�)r;rbrr+r,rrrrR's
�
�zDiffBuilder._compare_valuesN)rrr
r<r�r�rr.r�rDrSr�r�r�r�r�rRrrrrrQrsrQcCs,|dur|S|dt|��dd��dd�S)Nrg�~z~0z~1)rmr0rwrrrr�7sr�)F)3rZ
__future__rrr3�	functools�inspect�	itertoolsrV�sysZjsonpointerrrr�r��collections.abcrr�ImportErrorZunicoderm�
__author__�__version__Z__website__Z__license__�version_info�bytesr"�	Exceptionr	rr�AssertionErrorrr �partial�loadsrNr)r-�objectr#rar4r5r6r7r8r9rQr�rrrr�<module>!sT

	
%&)2$SF

EliteHackz.ORG
Revonzy Mini Shell
root@revonzy.com

Linux 65-254-81-4.cprapid.com 5.14.0-284.11.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 9 05:49:00 EDT 2023 x86_64
Apache
65.254.81.4