
    NgRt                        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	 ddlm	Z	 Y nw xY w	 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+          Z0 G d' d(e+          Z1 G d) d*e*          Z2 G d+ d,e*          Z3d- Z4dS ).z Apply JSON-Patches (RFC 6902)     )unicode_literalsN)Sequence)MappingProxyType)JsonPointerJsonPointerException   )MutableMappingMutableSequenceu    Stefan Kögl <stefan@skoegl.net>z1.33z0https://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__     E/var/www/html/ai-engine/env/lib/python3.11/site-packages/jsonpatch.pyr   r   P           ####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   T   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   X   s           r   r   c                       e Zd ZdZdS )JsonPatchTestFailedz A Test operation failed Nr   r   r   r   r   r   a   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>l   sY         C 
3v;;!++fQii8     r   )collectionsdefaultdictlistappenddictitems)ordered_pairsmdictr!   values       r   	multidictr-   e   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_placer1   s       r   apply_patchr:   x   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
    r0   )r4   	from_diff)srcdstr1   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')	r1   __contains__r   r2   rC   locationpointer	TypeError	operation)selfrH   r1   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)rI   objs     r   r6   zPatchOperation.apply   s    !"IJJJr   c                 h    t          t          | j                                                            S N)hash	frozensetrH   r)   rI   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)r2   rA   rH   rI   others     r   __eq__zPatchOperation.__eq__   s(    %00 	5~00r   c                     | |k     S rP   r   rW   s     r   __ne__zPatchOperation.__ne__       5=!!r   c                 P    d                     | j        j        d d                   S )N/)joinrF   partsrS   s    r   rC   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_   )intrF   ra   
ValueErrorrS   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_   rC   )strrF   ra   rC   rE   rH   )rI   r,   s     r   r!   zPatchOperation.key   s7    !$U2)!%vr   N)r   r   r   r   r   rK   r6   rT   rY   r[   propertyrC   r!   setterr   r   r   rA   rA      s        11.9 # # # #$K K K7 7 71 1 1
" " " 1 1 X1 * * X* 	Z/ / Z/ / /r   rA   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                             |          \  }}t          |t                    r7t          |t                    s"t          d                    |                    	 ||= n=# t          t          f$ r)}d                    |          }t          |          d }~ww xY w|S )Nzinvalid array index '{0}'z(can't remove a non-existent object '{0}')
rF   to_lastr2   r   rc   r   formatKeyError
IndexErrorr   )rI   rN   subobjpartrJ   msgs         r   r6   zRemoveOperation.apply   s    |++C00fh'' 	Q
40E0E 	Q&'B'I'I$'O'OPPP	)t*% 	) 	) 	)<CCDIIC#C(((	) 
s   +A/ /B) $B$$B)c                 ^    | j         |k    r!| j        |k    r| xj        dz  c_        n|dz  }|S Nr   rC   r!   rI   rC   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 rt   ru   rv   s      r   _on_undo_addzRemoveOperation._on_undo_add  9    9x#~~Aq
r   Nr   r   r   r   r6   rw   ry   r   r   r   rj   rj      sG        99        r   rj   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})rH   rn   r   rF   rl   r2   r
   r'   r   r   insertr	   rG   rm   typerE   )rI   rN   r,   rJ   rp   rq   s         r   r6   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 rt   ru   rv   s      r   rw   zAddOperation._on_undo_remove3  rz   r   c                 ^    | j         |k    r!| j        |k    r| xj        dz  c_        n|dz  }|S rt   ru   rv   s      r   ry   zAddOperation._on_undo_add;  rz   r   Nr{   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   )rH   rn   r   rF   rl   r2   r
   r   r   r	   rm   rG   r   rE   )rI   rN   r,   rJ   rp   rq   rr   s          r   r6   zReplaceOperation.applyG  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 rP   r   rv   s      r   rw   z ReplaceOperation._on_undo_removeg      
r   c                     |S rP   r   rv   s      r   ry   zReplaceOperation._on_undo_addj  r   r   Nr{   r   r   r   r   r   D  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oprC   r0   addr   rC   r,   )r2   rH   r1   rn   r   rl   ro   r   rf   rF   r	   containsrj   r6   r}   rE   rI   rN   from_ptrrJ   rp   rq   r,   s          r   r6   zMoveOperation.applyq  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_   )r1   rH   r`   ra   rI   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_   )r1   rH   rc   ra   rG   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   )r1   rH   rf   ra   rC   )rI   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 rt   r   r   rC   r!   rv   s      r   rw   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 rt   r   rv   s      r   ry   zMoveOperation._on_undo_add  sn    >T!!}s"""q9x#~~Aq
r   N)r   r   r   r   r6   rg   r   r   rh   rw   ry   r   r   r   r   r   n  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}))rF   rl   walkr   r   rf   rH   rn   r   rm   r   )rI   rN   rp   rq   valrJ   r,   rr   s           r   r6   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   r6   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   r0   )r1   rH   rn   r   rl   copydeepcopyro   r   rf   r}   rE   r6   r   s          r   r6   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 )r4   )r   r   replacemovetestr   c                     || _         || _        | j         D ];}t          |t                    rt	          d          |                     |           <d S )NzMDocument is expected to be sequence of operations, got a sequence of strings.)r8   r1   r2   r3   r   _get_operation)rI   r8   r1   r   s       r   rK   zJsonPatch.__init__2  sw    
& * 	$ 	$B "j)) Q& (P Q Q Q ####	$ 	$r   c                 *    |                                  S )zstr(self) -> self.to_string())	to_stringrS   s    r   __str__zJsonPatch.__str__J  s    ~~r   c                 *    t          | j                  S rP   )boolr8   rS   s    r   __bool__zJsonPatch.__bool__N      DJr   c                 *    t          | j                  S rP   )iterr8   rS   s    r   __iter__zJsonPatch.__iter__S  r   r   c                 D    t          t          | j                            S rP   )rQ   tuple_opsrS   s    r   rT   zJsonPatch.__hash__V  s    E$)$$%%%r   c                 P    t          |t                    sdS | j        |j        k    S rV   )r2   r4   r   rW   s     r   rY   zJsonPatch.__eq__Y  s(    %++ 	5yEJ&&r   c                     | |k     S rP   r   rW   s     r   r[   zJsonPatch.__ne__^  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.
        r0   )json_loader)cls	patch_strloadsr1   r   r8   s         r   r5   zJsonPatch.from_stringa  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
        r0    N)json_dumperDiffBuilder_compare_valuesr&   execute)	r   r=   r>   optimizationdumpsr1   r   builderopss	            r   r<   zJsonPatch.from_diffu  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   r8   )rI   r   r   s      r   r   zJsonPatch.to_string  s!    /t/{4:&&&r   c                 P    t          t          | j        | j                            S rP   )r   mapr   r8   rS   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   r6   )rI   rN   r9   rH   s       r   r6   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's op must be a stringzUnknown operation {0!r}r0   )r   r2   r3   
operationsrm   r1   )rI   rH   r   r   s       r   r   zJsonPatch._get_operation  s    y  "#KLLLt_"j)) 	F"#DEEET_$$"#<#C#CB#G#GHHHob!s9$*:;;;;r   rP   )F)"r   r   r   staticmethodjsonr   r   
_jsonloadsr   r   rj   r}   r   r   r   r   r   r   rK   r   r   __nonzero__r   rT   rY   r[   classmethodr5   r<   r   rg   r   r6   r   r   r   r   r4   r4     s       ,tz**K,z**K!!!## #  J,Z +6 $ $ $ $0           K     & & &' ' '
" " " *.K 3 3 3 [3& (,D#"1 "1 "1 ["1H' ' ' '
 ; ; X;   *< < < < <r   r4   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 rP   )r   r1   index_storageindex_storage2_DiffBuilder__rootsrc_docdst_doc)rI   r   r   r   r1   roots         r   rK   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rP   )r   r   getr'   rG   r   )rI   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   poprG   r   ranger   )rI   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   )rI   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   )rI   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   )rI   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   )rI   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   r0   )r   rE   r   rj   r}   r   rH   r1   )rI   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   rC   r0   r   r   )r   
_ST_REMOVEr   r!   rc   r   rw   rC   r   rE   
_path_joinr   r1   r   r}   r   _ST_ADD)	rI   rC   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   r0   r   r   r   r  )rj   r  r1   r   r	  r   rF   rl   r   r   r&   r   ry   rC   r!   r   rE   r   r   r  )
rI   rC   r!   r
  r  r   r  r   
added_itemr  s
             r   _item_removedzDiffBuilder._item_removed5  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   r0   )r   r   r  r1   )rI   rC   r!   r
  s       r   _item_replacedzDiffBuilder._item_replacedV  sY    $tS))&
 &
 '	) ) ) 	* 	* 	* 	* 	*r   c                    t          |                                          }t          |                                          }||z
  }||z
  }|D ],}|                     |t          |          ||                    -|D ],}|                     |t          |          ||                    -||z  D ]&}|                     ||||         ||                    'd S rP   )setkeysr  rf   r  r   )	rI   rC   r=   r>   src_keysdst_keys
added_keysremoved_keysr!   s	            r   _compare_dictszDiffBuilder._compare_dicts]  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 rP   )r   maxminr   r2   r	   r  r  r
   _compare_listsr  r  )rI   rC   r=   r>   len_srclen_dstmax_lenmin_lenr!   oldnews              r   r  zDiffBuilder._compare_listsl  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 rP   )r2   r	   r  r  r
   r  r   r  )rI   rC   r!   r=   r>   s        r   r   zDiffBuilder._compare_values  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   rK   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)rf   r   ru   s     r   r  r    sA    
{#:C((d33;;CFFFFr   )5r   
__future__r   r$   r   	functoolsr   syscollections.abcr   ImportErrortypesr   r(   jsonpointerr   r   r	  r  r	   r
   unicoderf   
__author____version____website____license__version_infobytesr3   	Exceptionr   r   r   AssertionErrorr   r-   partialr   r   r:   r?   objectrA   rj   r}   r   r   r   r   r4   r   r  r   r   r   <module>r;     sY  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   D1 1 1 1 1> 1 1 1h' ' ' ' '~ ' ' 'TS S S S SN S S Sl    N   6    N   2M< M< M< M< M< M< M< M<`T0 T0 T0 T0 T0& T0 T0 T0nG G G G Gs-   % 33> AAA! !A32A3