
    JZN`p                        d Z ddlmZ ddlZddlZddlZddlZddlZ	 ddlm	Z	 n# e
$ r eZ	Y nw xY wddlmZmZ dZdZ	 ddlmZmZ n# e
$ r ddlmZmZ eZY nw xY wdZd	Zd
ZdZej        dk    reefZ G d de          Z G d de          Z G d de          Z  G d dee!          Z"d Z# ej$        ej%        e#          Z&defdZ'efdZ( G d de)          Z* G d de*          Z+ G d de*          Z, G d  d!e*          Z- G d" d#e*          Z. G d$ d%e*          Z/ G d& d'e*          Z0 G d( d)e)          Z1 G d* d+e)          Z2d, Z3dS )-z Apply JSON-Patches (RFC 6902)     )unicode_literalsN)MappingProxyType)JsonPointerJsonPointerException   )MutableMappingMutableSequenceu    Stefan Kögl <stefan@skoegl.net>z1.32z0https://github.com/stefankoegl/python-json-patchzModified BSD License)   r   c                       e Zd ZdZdS )JsonPatchExceptionzBase Json Patch exceptionN__name__
__module____qualname____doc__     )lib/python3.11/site-packages/jsonpatch.pyr   r   J           ####r   r   c                       e Zd ZdZdS )InvalidJsonPatchz, Raised if an invalid JSON Patch is created Nr   r   r   r   r   r   N   s        6666r   r   c                       e Zd ZdZdS )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   r   r   r   r   r   R   s           r   r   c                       e Zd ZdZdS )JsonPatchTestFailedz A Test operation failed Nr   r   r   r   r   r   [   r   r   r   c                     t          j        t                    }| D ] \  }}||                             |           !t	          d |                                D                       S )z'Convert duplicate keys values to lists.c              3   Z   K   | ]&\  }}|t          |          d k    r|d         n|fV  'dS )r   r   N)len).0keyvaluess      r   	<genexpr>zmultidict.<locals>.<genexpr>f   sY         C 
3v;;!++fQii8     r   )collectionsdefaultdictlistappenddictitems)ordered_pairsmdictr    values       r   	multidictr,   _   sz     #D))E# ! !
Uc
%       !;;==     r   )object_pairs_hookFc                     t          |t                    rt                              ||          }nt          ||          }|                    | |          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_placer0   s       r   apply_patchr9   r   sW    B %$$ :%%e%EE%[999;;sH%%%r   c                 <    t                               | ||          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/   )r3   	from_diff)srcdstr0   s      r   
make_patchr>      s    * sC[AAAr   c                       e Zd ZdZefdZd Zd Zd Zd Z	e
d             Ze
d             Zej        d	             Zd
S )PatchOperationz'A single operation inside a JSON Patch.c                 ~   || _         |                    d          st          d          t          |d         | j                   r |d         j        | _        |d         | _        nO|d         | _        	 |                      | j                  | _        n!# t          $ r}t          d          d }~ww xY w|| _        d S )Npathz#Operation must have a 'path' memberzInvalid 'path')	r0   __contains__r   r1   rB   locationpointer	TypeError	operation)selfrG   r0   exs       r   __init__zPatchOperation.__init__   s    &%%f-- 	J"#HIIIi')9:: 	9%f-2DM$V,DLL%f-DM9#//>> 9 9 9&'78889 #s   5B 
B3B..B3c                      t          d          )zGAbstract method that applies a patch operation to the specified object.z%should implement the patch operation.)NotImplementedError)rH   objs     r   r5   zPatchOperation.apply   s    !"IJJJr   c                 h    t          t          | j                                                            S N)hash	frozensetrG   r(   rH   s    r   __hash__zPatchOperation.__hash__   s&    Idn224455666r   c                 P    t          |t                    sdS | j        |j        k    S NF)r1   r@   rG   rH   others     r   __eq__zPatchOperation.__eq__   s(    %00 	5~00r   c                     | |k     S rO   r   rV   s     r   __ne__zPatchOperation.__ne__       5=!!r   c                 P    d                     | j        j        d d                   S )N/)joinrE   partsrR   s    r   rB   zPatchOperation.path   s"    xx*3B3/000r   c                     	 t          | j        j        d                   S # t          $ r | j        j        d         cY S w xY w)Nr^   )intrE   r`   
ValueErrorrR   s    r   r    zPatchOperation.key   sP    	*t|)"-... 	* 	* 	*<%b))))	*s   ! A A c                 ~    t          |          | j        j        d<   | j        j        | _        | j        | j        d<   d S )Nr^   rB   )strrE   r`   rB   rD   rG   )rH   r+   s     r   r    zPatchOperation.key   s7    !$U2)!%vr   N)r   r   r   r   r   rJ   r5   rS   rX   rZ   propertyrB   r    setterr   r   r   r@   r@      s        11.9 # # # #$K K K7 7 71 1 1
" " " 1 1 X1 * * X* 	Z/ / Z/ / /r   r@   c                   $    e Zd ZdZd Zd Zd ZdS )RemoveOperationz/Removes an object property or an array element.c                     | j                             |          \  }}	 ||= n=# t          t          f$ r)}d                    |          }t          |          d }~ww xY w|S )Nz(can't remove a non-existent object '{0}')rE   to_lastKeyError
IndexErrorformatr   )rH   rM   subobjpartrI   msgs         r   r5   zRemoveOperation.apply   su    |++C00	)t*% 	) 	) 	)<CCDIIC#C(((	) 
s   # A$AAc                 ^    | j         |k    r!| j        |k    r| xj        dz  c_        n|dz  }|S Nr   rB   r    rH   rB   r    s      r   _on_undo_removezRemoveOperation._on_undo_remove   s9    9x3Aq
r   c                 ^    | j         |k    r!| j        |k    r| xj        dz  c_        n|dz  }|S rs   rt   ru   s      r   _on_undo_addzRemoveOperation._on_undo_add   9    9x#~~Aq
r   Nr   r   r   r   r5   rv   rx   r   r   r   ri   ri      sG        99        r   ri   c                   $    e Zd ZdZd Zd Zd ZdS )AddOperationz,Adds an object property or an array element.c                 r   	 | j         d         }n!# t          $ r}t          d          d }~ww xY w| j                            |          \  }}t          |t                    r[|dk    r|                    |           n|t          |          k    s|dk     rt          d          |
                    ||           nyt          |t                    r||}n_|||<   nY|/t          d                    t          |                              t          d                    | j        |                    |S )Nr+   /The operation does not contain a 'value' member-r   zcan't insert outside of listinvalid document type {0}2unable to fully resolve json pointer {0}, part {1})rG   rl   r   rE   rk   r1   r	   r&   r   r   insertr   rF   rn   typerD   )rH   rM   r+   rI   ro   rp   s         r   r5   zAddOperation.apply	  s[   	CN7+EE 	C 	C 	C"AC C C	C |++C00fo.. 	zs{{e$$$$F##taxx'(FGGG dE****// 
	z|$t | ; B B4<< P PQQQ'(\(c(cdhdqsw(x(xyyy
    
.).c                 ^    | j         |k    r!| j        |k    r| xj        dz  c_        n|dz  }|S rs   rt   ru   s      r   rv   zAddOperation._on_undo_remove)  ry   r   c                 ^    | j         |k    r!| j        |k    r| xj        dz  c_        n|dz  }|S rs   rt   ru   s      r   rx   zAddOperation._on_undo_add1  ry   r   Nrz   r   r   r   r|   r|     sH        66  @      r   r|   c                   $    e Zd ZdZd Zd Zd ZdS )ReplaceOperationz?Replaces an object property or an array element by a new value.c                    	 | j         d         }n!# t          $ r}t          d          d }~ww xY w| j                            |          \  }}||S |dk    rt          d          t          |t                    r)|t          |          k    s|dk     rt          d          nt          |t                    r)||vr$d
                    |          }t          |          nY|/t          d
                    t          |                              t          d	
                    | j        |                    |||<   |S )
Nr+   r~   r   z7'path' with '-' can't be applied to 'replace' operationr   zcan't replace outside of listz)can't replace a non-existent object '{0}'r   r   )rG   rl   r   rE   rk   r1   r	   r   r   r   rn   rF   r   rD   )rH   rM   r+   rI   ro   rp   rq   s          r   r5   zReplaceOperation.apply=  sp   	CN7+EE 	C 	C 	C"AC C C	C |++C00<L3;;"#\]]]fo.. 	zs6{{""dQhh'(GHHH '/ // 	z6!!AHHNN',,, " | ; B B4<< P PQQQ'(\(c(cdhdqsw(x(xyyyt
r   c                     |S rO   r   ru   s      r   rv   z ReplaceOperation._on_undo_remove]      
r   c                     |S rO   r   ru   s      r   rx   zReplaceOperation._on_undo_add`  r   r   Nrz   r   r   r   r   r   :  sH        II  @      r   r   c                   p    e Zd ZdZd Zed             Zed             Zej        d             Zd Z	d Z
dS )	MoveOperationz?Moves an object property or an array element to a new location.c                    	 t          | j        d         | j                  r| j        d         }n |                     | j        d                   }n!# t          $ r}t	          d          d }~ww xY w|                    |          \  }}	 ||         }n5# t          t          f$ r!}t          t          |                    d }~ww xY w| j	        |k    r|S t          |t                    r)| j	                            |          rt          d          t          d| j        d         d| j                                      |          }t          d| j        |d| j                                      |          }|S )	Nfrom.The operation does not contain a 'from' memberz*Cannot move values into their own childrenremoveoprB   r/   addr   rB   r+   )r1   rG   r0   rl   r   rk   rm   r   re   rE   r   containsri   r5   r|   rD   rH   rM   from_ptrrI   ro   rp   r+   s          r   r5   zMoveOperation.applyg  s   	B$.0$2BCC D>&1++DN6,BCC 	B 	B 	B"@B B B	B  '',,	-4LEE*% 	- 	- 	-#CGG,,,	- <8##Jfn-- 	R%%h//	R#$PQQQN6*
 
 ') ) ) */s 	
 M
 
 '	) ) ) */s	 	 
s0   AA 
A/A**A/B C%CCc                     |                      | j        d                   }d                    |j        d d                   S )Nr   r]   r^   )r0   rG   r_   r`   rH   r   s     r   	from_pathzMoveOperation.from_path  s9    ##DN6$:;;xxss+,,,r   c                     |                      | j        d                   }	 t          |j        d                   S # t          $ r |j        d         cY S w xY wNr   r^   )r0   rG   rb   r`   rF   r   s     r   from_keyzMoveOperation.from_key  sd    ##DN6$:;;	&x~b)*** 	& 	& 	&>"%%%%	&s   < AAc                     |                      | j        d                   }t          |          |j        d<   |j        | j        d<   d S r   )r0   rG   re   r`   rB   )rH   r+   r   s      r   r   zMoveOperation.from_key  sB    ##DN6$:;; ZZr!)vr   c                     | j         |k    r!| j        |k    r| xj        dz  c_        n|dz  }| j        |k    r!| j        |k    r| xj        dz  c_        n|dz  }|S rs   r   r   rB   r    ru   s      r   rv   zMoveOperation._on_undo_remove  sn    >T!!}##"q9x#~~Aq
r   c                     | j         |k    r!| j        |k    r| xj        dz  c_        n|dz  }| j        |k    r!| j        |k    r| xj        dz  c_        n|dz  }|S rs   r   ru   s      r   rx   zMoveOperation._on_undo_add  sn    >T!!}s"""q9x#~~Aq
r   N)r   r   r   r   r5   rf   r   r   rg   rv   rx   r   r   r   r   r   d  s        II# # #J - - X- & & X& _/ / _/
      r   r   c                       e Zd ZdZd ZdS )TestOperationz!Test value by specified location.c           
         	 | j                             |          \  }}||}n| j                             ||          }n.# t          $ r!}t	          t          |                    d }~ww xY w	 | j        d         }n!# t          $ r}t          d          d }~ww xY w||k    rAd}t	          |	                    |t          |          |t          |                              |S )Nr+   r~   z0{0} ({1}) is not equal to tested value {2} ({3}))rE   rk   walkr   r   re   rG   rl   r   rn   r   )rH   rM   ro   rp   valrI   r+   rq   s           r   r5   zTestOperation.apply  s   	/<//44LFD|l''55# 	/ 	/ 	/%c"gg...	/	CN7+EE 	C 	C 	C"AC C C	C %<<DC%cjjd3ii16U'E 'E F F F 
s/   =A   
A+
A&&A+/A= =
BBBNr   r   r   r   r5   r   r   r   r   r     s)        ++    r   r   c                       e Zd ZdZd ZdS )CopyOperationzA Copies an object property or an array element to a new location c                    	 |                      | j        d                   }n!# t          $ r}t          d          d }~ww xY w|                    |          \  }}	 t          j        ||                   }n5# t          t          f$ r!}t          t          |                    d }~ww xY wt          d| j        |d| j                                       |          }|S )Nr   r   r   r   r/   )r0   rG   rl   r   rk   copydeepcopyrm   r   re   r|   rD   r5   r   s          r   r5   zCopyOperation.apply  s   	B''v(>??HH 	B 	B 	B"@B B B	B  '',,	-M&,//EE*% 	- 	- 	-#CGG,,,	- M
 
 '	) ) ) */s	 	 
s*    # 
A<AA8 8B*	B%%B*Nr   r   r   r   r   r     s)        KK    r   r   c            	          e Zd Z eej                  Z ee          Z e	e
eeeeed          Z	 efdZd Zd ZeZd Zd Zd Zd Zed	efd
            Zedd	efd            ZddZed             ZddZ d Z!d	S )r3   )r   r   replacemovetestr   c                 `    || _         || _        | j         D ]}|                     |           d S rO   )r7   r0   _get_operation)rH   r7   r0   r   s       r   rJ   zJsonPatch.__init__(  sE    
& * 	$ 	$B####	$ 	$r   c                 *    |                                  S )zstr(self) -> self.to_string())	to_stringrR   s    r   __str__zJsonPatch.__str__3  s    ~~r   c                 *    t          | j                  S rO   )boolr7   rR   s    r   __bool__zJsonPatch.__bool__7      DJr   c                 *    t          | j                  S rO   )iterr7   rR   s    r   __iter__zJsonPatch.__iter__<  r   r   c                 D    t          t          | j                            S rO   )rP   tuple_opsrR   s    r   rS   zJsonPatch.__hash__?  s    E$)$$%%%r   c                 P    t          |t                    sdS | j        |j        k    S rU   )r1   r3   r   rV   s     r   rX   zJsonPatch.__eq__B  s(    %++ 	5yEJ&&r   c                     | |k     S rO   r   rV   s     r   rZ   zJsonPatch.__ne__G  r[   r   Nc                 D    |p| j         } ||          } | ||          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loadsr0   r   r7   s         r   r4   zJsonPatch.from_stringJ  s4      .sI&&s5k2222r   Tc                     |p| j         }t          ||||          }|                    dd||           t          |                                          } | ||          S )aC  Creates 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   r<   r=   optimizationdumpsr0   r   builderopss	            r   r;   zJsonPatch.from_diff^  sl    > .sc3MMMD#s3337??$$%%s3K0000r   c                 4    |p| j         } || j                  S )z!Returns patch set as JSON string.)r   r7   )rH   r   r   s      r   r   zJsonPatch.to_string  s!    /t/{4:&&&r   c                 P    t          t          | j        | j                            S rO   )r   mapr   r7   rR   s    r   r   zJsonPatch._ops  s    S,dj99:::r   Fc                 p    |st          j        |          }| j        D ]}|                    |          }|S )a5  Applies 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   r5   )rH   rM   r8   rG   s       r   r5   zJsonPatch.apply  sD      	%-$$C 	' 	'I//#&&CC
r   c                    d|vrt          d          |d         }t          |t                    st          d          || j        vr"t          d                    |                    | j        |         } ||| j                  S )Nr   z&Operation does not contain 'op' memberzOperation must be a stringzUnknown operation {0!r}r/   )r   r1   r2   
operationsrn   r0   )rH   rG   r   r   s       r   r   zJsonPatch._get_operation  s    y  "#KLLLt_"j)) 	A"#?@@@T_$$"#<#C#CB#G#GHHHob!s9$*:;;;;r   rO   )F)"r   r   r   staticmethodjsonr   r   
_jsonloadsr   r   ri   r|   r   r   r   r   r   r   rJ   r   r   __nonzero__r   rS   rX   rZ   classmethodr4   r;   r   rf   r   r5   r   r   r   r   r3   r3     s       ,tz**K,z**K!!!## #  J,Z +6 	$ 	$ 	$ 	$           K     & & &' ' '
" " " *.K 3 3 3 [3& (,D#"1 "1 "1 ["1H' ' ' '
 ; ; X;   *< < < < <r   r3   c                   r    e Zd Zej        efdZd Zd Zd Z	d Z
d Zd Zd Zd	 Zd
 Zd Zd Zd Zd ZdS )r   c                     || _         || _        i i g| _        g g g| _        g x| _        }|| _        || _        ||d g|d d <   d S rO   )r   r0   index_storageindex_storage2_DiffBuilder__rootsrc_docdst_doc)rH   r   r   r   r0   roots         r   rJ   zDiffBuilder.__init__  s[    
& "X!2hdt$QQQr   c                    |t          |          f}	 | j        |         }|                    |          }||g||<   d S ||                             |           d S # t          $ r& | j        |                             ||f           Y d S w xY wrO   )r   r   getr&   rF   r   )rH   r+   indexst	typed_keystoragestoreds          r   store_indexzDiffBuilder.store_index  s    DKK(			?(,G[[++F~&+W	"""	"))%00000 	? 	? 	?#**Iu+=>>>>>>	?s   *A A ,BBc                 |   |t          |          f}	 | j        |                             |          }|r|                                S d S # t          $ rf | j        |         }t          t          |          dz
  dd          D ]3}||         d         |k    r|                    |          d         c cY S 4Y d S w xY w)Nr   r^   r   )r   r   r   poprF   r   ranger   )rH   r+   r   r   r   r   is          r   
take_indexzDiffBuilder.take_index  s    DKK(			-'+//	::F $zz||#$ $  	- 	- 	-)"-G3w<<>2r22 - -1:a=I--";;q>>!,,,,,, .- - -	-s   5A A)B;6B;:B;c                 J    | j         }|d         }|||gx|d<   |d<   |d         S )Nr   r   r   )rH   r   r   lasts       r   r   zDiffBuilder.insert  s4    {Aw!4,,Q$q'Awr   c                 4    |\  }}}||d<   ||d<   g |d d <   d S )Nr   r   r   )rH   r   	link_prev	link_next_s        r   r   zDiffBuilder.remove  s1    "'	9a 	! 	!aaar   c              #   `   K   | j         }|d         }||ur|d         V  |d         }||ud S d S Nr      r   )rH   startr   currs       r   	iter_fromzDiffBuilder.iter_from  sP      {Qx$q'MMM7D $r   c              #   `   K   | j         }|d         }||ur|d         V  |d         }||ud S d S r   r   )rH   r   r   s      r   r   zDiffBuilder.__iter__  sP      {Aw$q'MMM7D $r   c              #     K   | j         }|d         }||ur|d         |ur|d         |d         d         }}|j        |j        k    rpt          |          t          k    rXt          |          t          k    r@t          d|j        |j        d         d| j                  j        V  |d         d         }|d         j        V  |d         }||ud S d S )Nr   r   r   r+   r   r/   )r   rD   r   ri   r|   r   rG   r0   )rH   r   r   op_first	op_seconds        r   r   zDiffBuilder.execute  s     {Aw$Awd""&*1gtAwqz)$	(:::X/99Y<77*' ) 2!*!4W!=, , $(#3	5 5 5 6?	? ? ?
  71:Dq'####7D $r   c                    |                      |t                    }||d         }t          |j                  t          k    rUt          |          t          k    r=|                     |          D ]'}|                    |j        |j                  |_        (|                     |           |j	        t          ||          k    rDt          d|j	        t          ||          d| j                  }|                     |           d S d S t          dt          ||          |d| j                  }|                     |          }|                     ||t                      d S )Nr   r   r   r   rB   r/   r   r   )r   
_ST_REMOVEr   r    rb   r   rv   rB   r   rD   
_path_joinr   r0   r   r|   r   _ST_ADD)	rH   rB   r    itemr   r   vnew_op	new_indexs	            r   _item_addedzDiffBuilder._item_added  ss   j11qBBF||s""tCyyC'7'7.. @ @A..rw??BFFKK{js3333& K&tS11( (  $/	1 1 1
 F##### 43 ""4--# #  +	- - -F
 F++IT9g66666r   c                    t          dt          ||          d| j                  }|                     |t                    }|                     |          }||d         }|j                            | j                  d         }t          |          t          k    r=|                     |          D ]'}	|	                    |j        |j                  |_        (|                     |           |j        |j        k    r+t#          d|j        |j        d| j                  }||d<   d S |                     |           d S |                     ||t&                     d S )Nr   r   r/   r   r   r   r  )ri   r  r0   r   r  r   rE   rk   r   r   r%   r   rx   rB   r    r   rD   r   r   r  )
rH   rB   r    r	  r  r   r  r   
added_itemr
  s
             r   _item_removedzDiffBuilder._item_removed  sq    tS))"
 "
 ') ) ) g..KK''	qB
 ++DL99!<JJ4''.. = =A^^BGRV<<BFFKK"+--& "OK( (  $/	1 1 1
  &	! I&&&&& T9j99999r   c           	      |    |                      t          dt          ||          |d| j                             d S )Nr   r   r/   )r   r   r  r0   )rH   rB   r    r	  s       r   _item_replacedzDiffBuilder._item_replaced?  sY    $tS))&
 &
 '	) ) ) 	* 	* 	* 	* 	*r   c                    t          |                                          }t          |                                          }||z
  }||z
  }|D ],}|                     |t          |          ||                    -|D ],}|                     |t          |          ||                    -||z  D ]&}|                     ||||         ||                    'd S rO   )setkeysr  re   r  r   )	rH   rB   r<   r=   src_keysdst_keys
added_keysremoved_keysr    s	            r   _compare_dictszDiffBuilder._compare_dictsF  s    sxxzz??sxxzz??(
(* 	9 	9CtSXXs3x8888 	7 	7CT3s88SX6666h& 	@ 	@C  sCHc#h????	@ 	@r   c                    t          |          t          |          }}t          ||          }t          ||          }t          |          D ]1}||k     r||         ||         }
}	|	|
k    r t	          |	t
                    r;t	          |
t
                    r&|                     t          ||          |	|
           pt	          |	t                    r;t	          |
t                    r&| 	                    t          ||          |	|
           | 
                    |||	           |                     |||
           ||k    r| 
                    ||||                    |                     ||||                    3d S rO   )r   maxminr   r1   r   r  r  r	   _compare_listsr  r  )rH   rB   r<   r=   len_srclen_dstmax_lenmin_lenr    oldnews              r   r  zDiffBuilder._compare_listsU  s   s88SXXgw''gw''>> 	6 	6CW}}s8SXS#::^44 
5sN33
5''
4(=(=sCHHHH_55 5"3885''
4(=(=sCHHHH &&tS#666$$T344447""""4#c(;;;;   sCH5555-	6 	6r   c                    t          |t                    r<t          |t                    r'|                     t          ||          ||           d S t          |t                    r<t          |t                    r'|                     t          ||          ||           d S |                     |          |                     |          k    rd S |                     |||           d S rO   )r1   r   r  r  r	   r  r   r  )rH   rB   r    r<   r=   s        r   r   zDiffBuilder._compare_valuesq  s    c>** 	03//	0
4 5 5sC@@@@@_-- 	0300	0
4 5 5sC@@@@@ ZZ__

3//F c3/////r   N)r   r   r   r   r   r   rJ   r   r   r   r   r   r   r   r  r  r  r  r  r   r   r   r   r   r     s        /3z{ % % % %? ? ?- - -          (7 7 72: : :B* * *@ @ @6 6 680 0 0 0 0r   r   c                     || S | dz   t          |                              dd                              dd          z   S )Nr]   ~z~0z~1)re   r   rt   s     r   r  r    sA    
{#:C((d33;;CFFFFr   )4r   
__future__r   r#   r   	functoolsr   systypesr   ImportErrorr'   jsonpointerr   r   r  r  collections.abcr   r	   unicodere   
__author____version____website____license__version_infobytesr2   	Exceptionr   r   r   AssertionErrorr   r,   partialr   r   r9   r>   objectr@   ri   r|   r   r   r   r   r3   r   r  r   r   r   <module>r:     s  B & % ' ' ' ' ' '           



&&&&&&&    : 9 9 9 9 9 9 9 
?????????   ;;;;;;;;
CCC
 0
@$ vJ$ $ $ $ $ $ $ $7 7 7 7 7) 7 7 7    *   $ $ $ $ $,n $ $ $    YtzYGGG
 &+ %& %& %& %&P &1 B B B B03/ 3/ 3/ 3/ 3/V 3/ 3/ 3/l    n   <1 1 1 1 1> 1 1 1h' ' ' ' '~ ' ' 'TS S S S SN S S Sl    N   6    N   2@< @< @< @< @< @< @< @<FT0 T0 T0 T0 T0& T0 T0 T0nG G G G Gs   % //A AA