
    M`p                     l   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	 ddlmZmZ dZdZ	 ddlmZmZ dZd	Zd
ZdZej4                  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jH                  ejJ                  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, Z3y# e
$ r eZ	Y w xY w# e
$ r ddlmZmZ eZY w xY w)-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y)JsonPatchExceptionzBase Json Patch exceptionN__name__
__module____qualname____doc__     +/usr/lib/python3/dist-packages/jsonpatch.pyr   r   J       #r   r   c                       e Zd ZdZy)InvalidJsonPatchz, Raised if an invalid JSON Patch is created Nr   r   r   r   r   r   N   s    6r   r   c                       e Zd ZdZy)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y)JsonPatchTestFailedz A Test operation failed Nr   r   r   r   r   r   [   r   r   r   c                     t        j                  t              }| D ]  \  }}||   j                  |        t	        d |j                         D              S )z'Convert duplicate keys values to lists.c              3   P   K   | ]  \  }}|t        |      d k(  r|d   n|f   yw)r   r   N)len).0keyvaluess      r   	<genexpr>zmultidict.<locals>.<genexpr>f   s4       C 
3v;!+fQi8s   $&)collectionsdefaultdictlistappenddictitems)ordered_pairsmdictr    values       r   	multidictr,   _   s]     ##D)E# !
Uc
% !   !;;=  r   )object_pairs_hookFc                     t        |t              rt        j                  ||      }nt        ||      }|j	                  | |      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   sA    B %$%%e%E%[9;;sH%%r   c                 2    t         j                  | ||      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Ar   c                   v    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y
)PatchOperationz'A single operation inside a JSON Patch.c                 d   || _         |j                  d      st        d      t        |d   | j                         r&|d   j                  | _        |d   | _        || _        y |d   | _        	 | j                  | j
                        | _        || _        y # t        $ r}t        d      d }~ww xY w)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-"#HIIi')9)9:%f-22DM$V,DL # &f-DM9#//> #  9&'7889s   . B 	B/B**B/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Jr   c                 Z    t        t        | j                  j                                     S N)hash	frozensetrG   r(   rH   s    r   __hash__zPatchOperation.__hash__   s    Idnn224566r   c                 V    t        |t              sy| j                  |j                  k(  S NF)r1   r@   rG   rH   others     r   __eq__zPatchOperation.__eq__   s"    %0~~00r   c                     | |k(   S rO   r   rV   s     r   __ne__zPatchOperation.__ne__       5=!!r   c                 R    dj                  | j                  j                  d d       S )N/)joinrE   partsrR   s    r   rB   zPatchOperation.path   s"    xx**3B/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   sE    	*t||))"-.. 	*<<%%b))	*s   !$ "A	A	c                     t        |      | j                  j                  d<   | j                  j                  | _        | j                  | j
                  d<   y )Nr^   rB   )strrE   r`   rB   rD   rG   )rH   r+   s     r   r    zPatchOperation.key   s=    !$U2))!%vr   N)r   r   r   r   r   rJ   r5   rS   rX   rZ   propertyrB   r    setterr   r   r   r@   r@      sb    1.9 #$K71
" 1 1 * * 	ZZ/ /r   r@   c                   "    e Zd ZdZd Zd Zd Zy)RemoveOperationz/Removes an object property or an array element.c                     | j                   j                  |      \  }}	 ||= |S # t        t        f$ r!}dj	                  |      }t        |      d }~ww xY w)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   s_    ||++C0	)t
 
	 *% 	)<CCDIC#C((	)s   % AAAc                 z    | j                   |k(  r+| j                  |k\  r| xj                  dz  c_        |S |dz  }|S Nr   rB   r    rH   rB   r    s      r   _on_undo_removezRemoveOperation._on_undo_remove   s=    99xx3A 
 q
r   c                 z    | j                   |k(  r+| j                  |kD  r| xj                  dz  c_        |S |dz  }|S rs   rt   ru   s      r   _on_undo_addzRemoveOperation._on_undo_add   =    99xx#~A 
 q
r   Nr   r   r   r   r5   rv   rx   r   r   r   ri   ri      s    9r   ri   c                   "    e Zd ZdZd Zd Zd Zy)AddOperationz,Adds an object property or an array element.c                    	 | j                   d   }| j                  j	                  |      \  }}t        |t              rJ|dk(  r|j                  |       |S |t        |      kD  s|dk  rt        d      |j                  ||       |S t        |t              r||}|S |||<   |S |#t        dj                  t        |                  t        dj                  | j                  |            # t        $ r}t        d      d }~ww xY w)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NN7+E
 ||++C0fo.s{e$& 
# F#tax'(FGG dE* 
 /| 
  %t 
	 | ; B B4< PQQ'(\(c(cdhdqdqsw(xyy5  	C"AC C	Cs   C0 0	D	9DD	c                 z    | j                   |k(  r+| j                  |kD  r| xj                  dz  c_        |S |dz  }|S rs   rt   ru   s      r   rv   zAddOperation._on_undo_remove)  ry   r   c                 z    | j                   |k(  r+| j                  |kD  r| xj                  dz  c_        |S |dz  }|S rs   rt   ru   s      r   rx   zAddOperation._on_undo_add1  ry   r   Nrz   r   r   r   r|   r|     s    6@r   r|   c                   "    e Zd ZdZd Zd Zd Zy)ReplaceOperationz?Replaces an object property or an array element by a new value.c                    	 | j                   d   }| j                  j	                  |      \  }}||S |dk(  rt        d      t        |t              r|t        |      k\  s|dk  rt        d      t        |t              r ||vrfdj                  |      }t        |      |#t        dj                  t        |                  t        d	j                  | j                  |            |||<   |S # t        $ r}t        d      d }~ww xY w)
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=  s   	CNN7+E
 ||++C0<L3;"#\]]fo.s6{"dQh'(GHH/6!AHHN',,| ; B B4< PQQ'(\(c(cdhdqdqsw(xyyt
7  	C"AC C	Cs   C2 2	D;DD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   :  s    I@r   r   c                   f    e Zd ZdZd Zed        Zed        Zej                  d        Zd Z	d Z
y)	MoveOperationz?Moves an object property or an array element to a new location.c                    	 t        | j                  d   | j                        r| j                  d   }n| j                  | j                  d         }|j                  |      \  }}	 ||   }| j                  |k(  r|S t        |t              r&| j                  j                  |      rt        d      t        d| j                  d   d| j                        j                  |      }t        d| j                  |d| j                        j                  |      }|S # t        $ r}t	        d      d }~ww xY w# t        t        f$ r}t        t        |            d }~ww xY w)	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  sg   	B$..0$2B2BC>>&1++DNN6,BC
  '',	-4LE
 <<8#Jfn-%%h/#$PQQNN6*
 '') */s 	
 MM
 ''	) */s	 	 
;  	B"@B B	B *% 	-#CG,,	-s0   AD  (D<  	D9)D44D9<E$EE$c                 z    | j                  | j                  d         }dj                  |j                  d d       S )Nr   r]   r^   )r0   rG   r_   r`   rH   r   s     r   	from_pathzMoveOperation.from_path  s5    ##DNN6$:;xxs+,,r   c                     | j                  | 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  sR    ##DNN6$:;	&x~~b)** 	&>>"%%	&s   8 AAc                     | j                  | j                  d         }t        |      |j                  d<   |j                  | j                  d<   y r   )r0   rG   re   r`   rB   )rH   r+   r   s      r   r   zMoveOperation.from_key  s?    ##DNN6$:; Zr!)vr   c                     | j                   |k(  r*| j                  |k\  r| xj                  dz  c_        n|dz  }| j                  |k(  r+| j                  |kD  r| xj                  dz  c_        |S |dz  }|S rs   r   r   rB   r    ru   s      r   rv   zMoveOperation._on_undo_remove  sl    >>T!}}#"q99xx#~A 
 q
r   c                     | j                   |k(  r*| j                  |kD  r| xj                  dz  c_        n|dz  }| j                  |k(  r+| j                  |kD  r| xj                  dz  c_        |S |dz  }|S rs   r   ru   s      r   rx   zMoveOperation._on_undo_add  sl    >>T!}}s""q99xx#~A 
 q
r   N)r   r   r   r   r5   rf   r   r   rg   rv   rx   r   r   r   r   r   d  sU    I#J - - & & __/ /
r   r   c                       e Zd ZdZd Zy)TestOperationz!Test value by specified location.c           
         	 | j                   j                  |      \  }}||}n| j                   j                  ||      }	 | j                  d   }||k7  r1d}t	        |j                  |t        |      |t        |                  |S # t        $ r}t	        t        |            d }~ww xY w# t        $ r}t        d      d }~ww xY w)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    	/<<//4LFD|ll''5	CNN7+E
 %<DC%cjjd3i16U'E F F 
 $ 	/%c"g..	/
  	C"AC C	Cs/   ?B	 B. 		B+B&&B+.	C7CCNr   r   r   r   r5   r   r   r   r   r     s
    +r   r   c                       e Zd ZdZd Zy)CopyOperationzA Copies an object property or an array element to a new location c                    	 | j                  | j                  d         }|j	                  |      \  }}	 t        j                  ||         }t        d| j                  |d| j                         j                  |      }|S # t        $ r}t        d      d }~ww xY w# t        t        f$ r}t        t        |            d }~ww xY w)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(>?H
  '',	-MM&,/E MM
 ''	) */s	 	 
!  	B"@B B	B *% 	-#CG,,	-s.   B B 	BBBC.CCNr   r   r   r   r   r     s
    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!y	)r3   )r   r   replacemovetestr   c                 d    || _         || _        | j                   D ]  }| j                  |        y rO   )r7   r0   _get_operation)rH   r7   r0   r   s       r   rJ   zJsonPatch.__init__(  s4    
& ** 	$B#	$r   c                 "    | j                         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      DJJr   c                 ,    t        | j                        S rO   )iterr7   rR   s    r   __iter__zJsonPatch.__iter__<  r   r   c                 >    t        t        | j                              S rO   )rP   tuple_opsrR   s    r   rS   zJsonPatch.__hash__?  s    E$))$%%r   c                 V    t        |t              sy| j                  |j                  k(  S rU   )r1   r3   r   rV   s     r   rX   zJsonPatch.__eq__B  s"    %+yyEJJ&&r   c                     | |k(   S rO   r   rV   s     r   rZ   zJsonPatch.__ne__G  r[   r   Nc                 F    |xs | 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  s)      .sI&5k22r   Tc                     |xs | j                   }t        ||||      }|j                  dd||       t        |j	                               } | ||      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^  sT    > .sc3MD#s37??$%3K00r   c                 F    |xs | 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                 T    t        t        | j                  | j                              S rO   )r   mapr   r7   rR   s    r   r   zJsonPatch._ops  s    S,,djj9::r   c                 x    |st        j                  |      }| j                  D ]  }|j                  |      } |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  s=     --$C 	'I//#&C	' 
r   c                     d|vrt        d      |d   }t        |t              st        d      || j                  vrt        dj	                  |            | 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  sy    y "#KLLt_"j)"#?@@T__$"#<#C#CB#GHHoob!9$*:*:;;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    tzz*Kz*K!!## J,Z +6 	$   K &'
" *.K 3 3& (,D#"1 "1H'
 ; ;*<r   r3   c                   z    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y)r   c                     || _         || _        i i g| _        g g g| _        g x| _        }|| _        || _        ||d g|d d  y rO   )r   r0   index_storageindex_storage2_DiffBuilder__rootsrc_docdst_doc)rH   r   r   r   r0   roots         r   rJ   zDiffBuilder.__init__  sS    
& "X!2hdt$Qr   c                     |t        |      f}	 | j                  |   }|j                  |      }||g||<   y ||   j                  |       y # t        $ r# | j
                  |   j                  ||f       Y y 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K(			?((,G[[+F~&+W	"	"))%0 	?#**Iu+=>	?s   (A A )A98A9c                 >   |t        |      f}	 | j                  |   j                  |      }|r|j                         S y # t        $ rS | j
                  |   }t        t        |      dz
  dd      D ]%  }||   d   |k(  s|j                  |      d   c cY S  Y y 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K(			-''+//	:Fzz|#   	-))"-G3w<>2r2 -1:a=I-";;q>!,,-	-s   /A   ?B BBBc                 H    | j                   }|d   }|||gx|d<   |d<   |d   S )Nr   r   r   )rH   r   r   lasts       r   r   zDiffBuilder.insert  s6    {{Aw!4,,Q$q'Awr   c                 .    |\  }}}||d<   ||d<   g |d d  y )Nr   r   r   )rH   r   	link_prev	link_next_s        r   r   zDiffBuilder.remove  s)    "'	9a 	! 	!ar   c              #   Z   K   | j                   }|d   }||ur|d    |d   }||ury y wNr      r   )rH   startr   currs       r   	iter_fromzDiffBuilder.iter_from  s<     {{Qx$q'M7D $   &++c              #   Z   K   | j                   }|d   }||ur|d    |d   }||ury y wr   r   )rH   r   r   s      r   r   zDiffBuilder.__iter__  s<     {{Aw$q'M7D $r   c              #     K   | j                   }|d   }||ur|d   |ur|d   |d   d   }}|j                  |j                  k(  rkt        |      t        k(  rYt        |      t        k(  rGt        d|j                  |j                  d   d| j                        j                   |d   d   }|d   j                   |d   }||ury y w)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Y<7*' ) 2 2!*!4!4W!=, $(#3#3	5 6?Y	?
  71:Dq'###7D $s   CCCc                    | j                  |t              }||d   }t        |j                        t        k(  rSt        |      t        k(  rA| j                  |      D ]-  }|j                  |j                  |j                        |_        / | j                  |       |j                  t        ||      k7  rAt        d|j                  t        ||      d| j                        }| j                  |       y y t        dt        ||      |d| j                        }| j                  |      }| j                  ||t                y )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  s"   j1qBBFF|s"tCyC'7. @A..rww?BF@ KK{{js33& KK&tS1(  $//	1
 F# 4 ""4-#  ++	-F
 F+IT9g6r   c                    t        dt        ||      d| j                        }| j                  |t              }| j                  |      }||d   }|j                  j                  | j                        d   }t        |      t        k(  rA| j                  |      D ]-  }	|	j                  |j                  |j                        |_        / | j                  |       |j                   |j                   k7  r5t#        d|j                   |j                   d| j                        }||d<   y | j                  |       y | j%                  ||t&               y )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  s,    tS)"
 '') g.KK'	qB
 ++DLL9!<JJ4'. =A^^BGGRVV<BF= KK"++-& "OOKK(  $//	1
  &	! I& T9j9r   c           	      l    | j                  t        dt        ||      |d| j                               y )Nr   r   r/   )r   r   r  r0   )rH   rB   r    r	  s       r   _item_replacedzDiffBuilder._item_replaced?  s6    $tS)&
 ''	) 	*r   c                 \   t        |j                               }t        |j                               }||z
  }||z
  }|D ]!  }| j                  |t        |      ||          # |D ]!  }| j	                  |t        |      ||          # ||z  D ]  }| j                  ||||   ||           y 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    sxxz?sxxz?(
(* 	9CtSXs3x8	9  	7CT3s8SX6	7 h& 	@C  sCHc#h?	@r   c                 T   t        |      t        |      }}t        ||      }t        ||      }t        |      D ]  }||k  r||   ||   }
}	|	|
k(  rt	        |	t
              r.t	        |
t
              r| j                  t        ||      |	|
       Vt	        |	t              r.t	        |
t              r| j                  t        ||      |	|
       | j                  |||	       | j                  |||
       ||kD  r| j                  ||||          | j                  ||||           y 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   s8SXgw'gw'> 	6CW}s8SXS#:^4sN3''
4(=sCH_5"38''
4(=sCH &&tS#6$$T347"""4#c(;   sCH5-	6r   c                 j   t        |t              r.t        |t              r| j                  t        ||      ||       y t        |t              r.t        |t              r| j                  t        ||      ||       y | j                  |      | j                  |      k(  ry | j                  |||       y rO   )r1   r   r  r  r	   r  r   r  )rH   rB   r    r<   r=   s        r   r   zDiffBuilder._compare_valuesq  s    c>*3/
4 5sC@_-30
4 5sC@ ZZ_

3/ 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     sS    /3zz{ %?-(72:B*@680r   r   c                 l    || S | dz   t        |      j                  dd      j                  dd      z   S )Nr]   ~z~0z~1)re   r   rt   s     r   r  r    s9    
{#:C((d3;;C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 & '     
&
 : 
? 0
@$ vJ$ $7) 7* $,n $  YtzzYG
 &+ %&P &1 B03/V 3/ln <1> 1h'~ 'TSN SlN 6N 2@< @<FT0& T0nGy    ;
Cs"   D D! DD!D32D3