AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/__pycache__/jsonpatch.cpython-310.pyc
o

M`�p�@s�dZddlmZddlZddlZddlZddlZddlZzddlm	Z	Wne
y/eZ	Ynwddlm
Z
mZdZdZz
ddlmZmZWne
yYddlmZmZeZYnwdZd	Zd
ZdZejdkrkeefZGd
d�de�ZGdd�de�ZGdd�de�Z Gdd�dee!�Z"dd�Z#ej$ej%e#d�Z&de
fdd�Z'e
fdd�Z(Gdd�de)�Z*Gdd �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)�Z1Gd-d.�d.e)�Z2d/d0�Z3dS)1z Apply JSON-Patches (RFC 6902) �)�unicode_literalsN)�MappingProxyType)�JsonPointer�JsonPointerException�)�MutableMapping�MutableSequenceu Stefan Kögl <stefan@skoegl.net>z1.32z0https://github.com/stefankoegl/python-json-patchzModified BSD License)�rc@�eZdZdZdS)�JsonPatchExceptionzBase Json Patch exceptionN��__name__�
__module__�__qualname__�__doc__�rr�+/usr/lib/python3/dist-packages/jsonpatch.pyrJ�rc@r
)�InvalidJsonPatchz, Raised if an invalid JSON Patch is created NrrrrrrNrrc@r
)�JsonPatchConflicta
Raised if patch could not be applied due to conflict situation such as:
    - attempt to add object key when it already exists;
    - attempt to operate with nonexistence object key;
    - attempt to insert value to array at position beyond its size;
    - etc.
    NrrrrrrRrrc@r
)�JsonPatchTestFailedz A Test operation failed Nrrrrrr[rrcCs<t�t�}|D]\}}||�|�qtdd�|��D��S)z'Convert duplicate keys values to lists.css0�|]\}}|t|�dkr|dn|fVqdS)rrN)�len)�.0�key�valuesrrr�	<genexpr>fs
��
�zmultidict.<locals>.<genexpr>)�collections�defaultdict�list�append�dict�items)�
ordered_pairs�mdictr�valuerrr�	multidict_s
�r%)�object_pairs_hookFcCs2t|t�r
tj||d�}nt||d�}|�||�S)a�Apply 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

    :param pointer_cls: JSON pointer class to use.
    :type pointer_cls: Type[JsonPointer]

    :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
    ��pointer_cls)�
isinstance�
basestring�	JsonPatch�from_string�apply)�doc�patch�in_placer(rrr�apply_patchrs
!r1cCstj|||d�S)a!Generates patch by comparing 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

    :param pointer_cls: JSON pointer class to use.
    :type pointer_cls: Type[JsonPointer]

    >>> 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')r+�	from_diff)�src�dstr(rrr�
make_patch�sr5c@sbeZdZdZefdd�Zdd�Zdd�Zdd	�Zd
d�Z	e
dd
��Ze
dd��Zej
dd��ZdS)�PatchOperationz'A single operation inside a JSON Patch.c
Cs�||_|�d�std��t|d|j�r |dj|_|d|_n|d|_z	|�|j�|_Wnty>}ztd��d}~ww||_dS)N�pathz#Operation must have a 'path' memberzInvalid 'path')	r(�__contains__rr)r7�location�pointer�	TypeError�	operation)�selfr<r(�exrrr�__init__�s

��
zPatchOperation.__init__cCstd��)zGAbstract method that applies a patch operation to the specified object.z%should implement the patch operation.)�NotImplementedError)r=�objrrrr-��zPatchOperation.applycCstt|j����S�N)�hash�	frozensetr<r!�r=rrr�__hash__�szPatchOperation.__hash__cC�t|t�sdS|j|jkS�NF)r)r6r<�r=�otherrrr�__eq__��
zPatchOperation.__eq__cC�
||kSrCrrJrrr�__ne__��
zPatchOperation.__ne__cCsd�|jjdd��S)N�/���)�joinr:�partsrFrrrr7�szPatchOperation.pathcCs2z	t|jjd�WSty|jjdYSw)NrR)�intr:rT�
ValueErrorrFrrrr�s
�zPatchOperation.keycCs*t|�|jjd<|jj|_|j|jd<dS)NrRr7)�strr:rTr7r9r<)r=r$rrrr�s
N)r
rrrrr?r-rGrLrO�propertyr7r�setterrrrrr6�s

r6c@�(eZdZdZdd�Zdd�Zdd�ZdS)	�RemoveOperationz/Removes an object property or an array element.c
CsL|j�|�\}}z||=W|Sttfy%}z	d�|�}t|��d}~ww)Nz(can't remove a non-existent object '{0}')r:�to_last�KeyError�
IndexError�formatr)r=rA�subobj�partr>�msgrrrr-�s�
��zRemoveOperation.applycCs2|j|kr|j|kr|jd7_|S|d8}|S�Nr�r7r�r=r7rrrr�_on_undo_remove��

�zRemoveOperation._on_undo_removecCs2|j|kr|j|kr|jd8_|S|d8}|Srcrdrerrr�_on_undo_add�rgzRemoveOperation._on_undo_addN�r
rrrr-rfrhrrrrr[�s

r[c@rZ)	�AddOperationz,Adds an object property or an array element.c
Cs�z|jd}Wnty}ztd��d}~ww|j�|�\}}t|t�rF|dkr0|�|�|S|t|�ks:|dkr>t	d��|�
||�|St|t�rY|durS|}|S|||<|S|durftd�
t|����t	d�
|j|���)Nr$�/The operation does not contain a 'value' member�-rzcan't insert outside of list�invalid document type {0}�2unable to fully resolve json pointer {0}, part {1})r<r]rr:r\r)rrrr�insertrr;r_�typer9)r=rAr$r>r`rarrrr-	s4���

�
�	��zAddOperation.applycCs2|j|kr|j|kr|jd7_|S|d7}|Srcrdrerrrrf)rgzAddOperation._on_undo_removecCs2|j|kr|j|kr|jd8_|S|d7}|Srcrdrerrrrh1rgzAddOperation._on_undo_addNrirrrrrjs
 rjc@rZ)	�ReplaceOperationz?Replaces an object property or an array element by a new value.c
Cs�z|jd}Wnty}ztd��d}~ww|j�|�\}}|dur&|S|dkr.td��t|t�rB|t|�ks=|dkrAtd��n)t|t	�rU||vrTd�
|�}t|��n|durbtd�
t|����td	�
|j
|���|||<|S)
Nr$rkrlz7'path' with '-' can't be applied to 'replace' operationrzcan't replace outside of listz)can't replace a non-existent object '{0}'rmrn)r<r]rr:r\r)rrrrr_r;rpr9)r=rAr$r>r`rarbrrrr-=s6���
�

�zReplaceOperation.applycC�|SrCrrerrrrf]�z ReplaceOperation._on_undo_removecCrrrCrrerrrrh`rszReplaceOperation._on_undo_addNrirrrrrq:s
 rqc@sNeZdZdZdd�Zedd��Zedd��Zejdd��Zd	d
�Z	dd�Z
d
S)�
MoveOperationz?Moves an object property or an array element to a new location.c
Cszt|jd|j�r|jd}n|�|jd�}Wnty)}ztd��d}~ww|�|�\}}z||}WnttfyK}ztt|���d}~ww|j	|krS|St|t
�rb|j	�|�rbtd��td|jdd�|jd��
|�}td|j|d�|jd��
|�}|S)	N�from�.The operation does not contain a 'from' memberz*Cannot move values into their own children�remove��opr7r'�add�ryr7r$)r)r<r(r]rr\r^rrWr:r�containsr[r-rjr9�r=rA�from_ptrr>r`rar$rrrr-gsT������


�������zMoveOperation.applycCs$|�|jd�}d�|jdd��S)NrurQrR)r(r<rSrT�r=r~rrr�	from_path�szMoveOperation.from_pathcCs>|�|jd�}zt|jd�WSty|jdYSw�NrurR)r(r<rUrTr;rrrr�from_key�s�zMoveOperation.from_keycCs.|�|jd�}t|�|jd<|j|jd<dSr�)r(r<rWrTr7)r=r$r~rrrr��scCs^|j|kr|j|kr|jd7_n|d8}|j|kr-|j|kr)|jd7_|S|d7}|Src�r�r�r7rrerrrrf��



�zMoveOperation._on_undo_removecCs^|j|kr|j|kr|jd8_n|d8}|j|kr-|j|kr)|jd8_|S|d7}|Srcr�rerrrrh�r�zMoveOperation._on_undo_addN)r
rrrr-rXr�r�rYrfrhrrrrrtds%



rtc@�eZdZdZdd�ZdS)�
TestOperationz!Test value by specified location.c
Cs�z|j�|�\}}|dur|}n|j�||�}Wnty*}ztt|���d}~wwz|jd}WntyB}ztd��d}~ww||krWd}t|�	|t
|�|t
|����|S)Nr$rkz0{0} ({1}) is not equal to tested value {2} ({3}))r:r\�walkrrrWr<r]rr_rp)r=rAr`ra�valr>r$rbrrrr-�s0�������zTestOperation.applyN�r
rrrr-rrrrr���r�c@r�)�
CopyOperationzA Copies an object property or an array element to a new location c
Cs�z
|�|jd�}Wnty}ztd��d}~ww|�|�\}}z	t�||�}Wnttfy?}ztt	|���d}~wwt
d|j|d�|jd��|�}|S)Nrurvrzr{r')
r(r<r]rr\�copy�deepcopyr^rrWrjr9r-r}rrrr-�s2��������zCopyOperation.applyNr�rrrrr��r�r�c@s�eZdZeej�Zee�Ze	e
eee
eed��Z	efdd�Zdd�Zdd�ZeZdd	�Zd
d�Zdd
�Zdd�Zedefdd��Zeddefdd��Zddd�Zedd��Zd dd�Z dd�Z!dS)!r+)rwrz�replace�move�testr�cCs&||_||_|jD]}|�|�q	dSrC)r/r(�_get_operation)r=r/r(ryrrrr?(s

�zJsonPatch.__init__cCs|��S)zstr(self) -> self.to_string())�	to_stringrFrrr�__str__3rBzJsonPatch.__str__cC�
t|j�SrC)�boolr/rFrrr�__bool__7rPzJsonPatch.__bool__cCr�rC)�iterr/rFrrr�__iter__<rPzJsonPatch.__iter__cCstt|j��SrC)rD�tuple�_opsrFrrrrG?szJsonPatch.__hash__cCrHrI)r)r+r�rJrrrrLBrMzJsonPatch.__eq__cCrNrCrrJrrrrOGrPzJsonPatch.__ne__NcCs|p|j}||�}|||d�S)a�Creates JsonPatch instance from string source.

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

        :param loads: A function of one argument that loads a serialized
                      JSON string.
        :type loads: function

        :param pointer_cls: JSON pointer class to use.
        :type pointer_cls: Type[JsonPointer]

        :return: :class:`JsonPatch` instance.
        r')�json_loader)�cls�	patch_str�loadsr(r�r/rrrr,Js
zJsonPatch.from_stringTc	CsB|p|j}t||||d�}|�dd||�t|���}|||d�S)aCCreates JsonPatch instance based on comparison 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

        :param dumps: A function of one argument that produces a serialized
                      JSON string.
        :type dumps: function

        :param pointer_cls: JSON pointer class to use.
        :type pointer_cls: Type[JsonPointer]

        :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
        r'�N)�json_dumper�DiffBuilder�_compare_valuesr�execute)	r�r3r4�optimization�dumpsr(r��builder�opsrrrr2^s

zJsonPatch.from_diffcCs|p|j}||j�S)z!Returns patch set as JSON string.)r�r/)r=r�r�rrrr��s

zJsonPatch.to_stringcCstt|j|j��SrC)r��mapr�r/rFrrrr��szJsonPatch._opsFcCs(|st�|�}|jD]}|�|�}q
|S)a5Applies the patch to a given object.

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

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

        :return: Modified `obj`.
        )r�r�r�r-)r=rAr0r<rrrr-�s


zJsonPatch.applycCsZd|vrtd��|d}t|t�std��||jvr!td�|���|j|}|||jd�S)Nryz&Operation does not contain 'op' memberzOperation must be a stringzUnknown operation {0!r}r')rr)r*�
operationsr_r()r=r<ryr�rrrr��s


zJsonPatch._get_operationrC)F)"r
rr�staticmethod�jsonr�r��
_jsonloadsr�rr[rjrqrtr�r�r�rr?r�r��__nonzero__r�rGrLrO�classmethodr,r2r�rXr�r-r�rrrrr+�s>
�	-�
$

r+c@s�eZdZejefdd�Zdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)r�cCsL||_||_iig|_ggg|_g|_}||_||_||dg|dd�<dSrC)r�r(�
index_storage�index_storage2�_DiffBuilder__root�src_doc�dst_doc)r=r�r�r�r(�rootrrrr?�s


zDiffBuilder.__init__cCsv|t|�f}z |j|}|�|�}|dur|g||<WdS||�|�WdSty:|j|�||f�YdSwrC)rpr��getrr;r�)r=r$�index�st�	typed_key�storage�storedrrr�store_index�s

�zDiffBuilder.store_indexcCs�|t|�f}z|j|�|�}|r|��WSWdStyG|j|}tt|�ddd�D]}||d|krC|�|�dYSq.YdSw)NrrRr)rpr�r��popr;r��ranger)r=r$r�r�r�r��irrr�
take_index�s
�
���zDiffBuilder.take_indexcCs,|j}|d}|||g|d<|d<|dS)Nrr�r�)r=ryr��lastrrrro�szDiffBuilder.insertcCs*|\}}}||d<||d<g|dd�<dS)Nrrr)r=r��	link_prev�	link_next�_rrrrw�s
zDiffBuilder.removeccs:�|j}|d}||ur|dV|d}||usdSdS�Nr�r�)r=�startr��currrrr�	iter_from���
�zDiffBuilder.iter_fromccs:�|j}|d}||ur|dV|d}||usdSdSr�r�)r=r�r�rrrr��r�zDiffBuilder.__iter__ccs��|j}|d}||urW|d|urG|d|dd}}|j|jkrGt|�tkrGt|�tkrGtd|j|jdd�|jd�jV|dd}q|djV|d}||usdSdS)Nrr�r�r$r{r')r�r9rpr[rjrqr<r()r=r�r��op_first�	op_secondrrrr��s2�
�
�����zDiffBuilder.executec	Cs�|�|t�}|durQ|d}t|j�tkr,t|�tkr,|�|�D]}|�|j|j�|_q |�|�|j	t
||�krOtd|j	t
||�d�|jd�}|�
|�dSdStdt
||�|d�|jd�}|�
|�}|�||t�dS)Nr�r��ryrur7r'rzr{)r��
_ST_REMOVErprrUr�rfr7rwr9�
_path_joinrtr(rorjr��_ST_ADD)	r=r7r�itemr�ry�v�new_op�	new_indexrrr�_item_addeds4
�����
zDiffBuilder._item_addedc
Cs�tdt||�d�|jd�}|�|t�}|�|�}|dure|d}|j�|j�d}t	|�t
kr@|�|�D]}	|	�|j
|j�|_q4|�|�|j|jkr^td|j|jd�|jd�}||d<dS|�|�dS|�||t�dS)Nrwrxr'r�rr�r�)r[r�r(r�r�ror:r\r�rprr�rhr7rrwr9rtr�r�)
r=r7rr�r�r�r�ry�
added_itemr�rrr�
_item_removeds4��

��zDiffBuilder._item_removedcCs&|�tdt||�|d�|jd��dS)Nr�r{r')rorqr�r()r=r7rr�rrr�_item_replaced?s��zDiffBuilder._item_replacedc	Cs�t|���}t|���}||}||}|D]
}|�|t|�||�q|D]
}|�|t|�||�q&||@D]}|�||||||�q8dSrC)�set�keysr�rWr�r�)	r=r7r3r4�src_keys�dst_keys�
added_keys�removed_keysrrrr�_compare_dictsFs�zDiffBuilder._compare_dictscCs�t|�t|�}}t||�}t||�}t|�D]d}||krd||||}	}
|	|
kr+qt|	t�r@t|
t�r@|�t||�|	|
�qt|	t�rUt|
t�rU|�	t||�|	|
�q|�
|||	�|�|||
�q||krr|�
||||�q|�||||�qdSrC)r�max�minr�r)rr�r�r�_compare_listsr�r�)r=r7r3r4�len_src�len_dst�max_len�min_lenr�old�newrrrr�Us,


�
��zDiffBuilder._compare_listscCs�t|t�rt|t�r|�t||�||�dSt|t�r,t|t�r,|�t||�||�dS|�|�|�|�kr8dS|�|||�dSrC)r)rr�r�rr�r�r�)r=r7rr3r4rrrr�qs
�
�	zDiffBuilder._compare_valuesN)r
rrr�r�rr?r�r�rorwr�r�r�r�r�r�r�r�r�rrrrr��s


!r�cCs,|dur|S|dt|��dd��dd�S)NrQ�~z~0z~1)rWr�rdrrrr��s r�)4r�
__future__rrr��	functoolsr��sys�typesr�ImportErrorr �jsonpointerrrr�r��collections.abcrr�unicoderW�
__author__�__version__�__website__�__license__�version_info�bytesr*�	Exceptionrrr�AssertionErrorrr%�partialr�r�r1r5�objectr6r[rjrqrtr�r�r+r�r�rrrr�<module>s^ ��
	(64*VDX

Anon7 - 2022
AnonSec Team