o
    M`�p  ã                   @   sæ  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zddlm	Z	 W n e
y/   eZ	Y nw ddlmZmZ dZdZz
ddlmZmZ W n e
yY   ddlmZmZ eZY nw dZd	Zd
ZdZejdkrkeefZG dd„ deƒZG dd„ deƒZG dd„ deƒZ G dd„ dee!ƒZ"dd„ Z#ej$ej%e#d�Z&defdd„Z'efdd„Z(G dd„ de)ƒZ*G dd „ d e*ƒZ+G d!d"„ d"e*ƒZ,G d#d$„ d$e*ƒZ-G d%d&„ d&e*ƒZ.G d'd(„ d(e*ƒZ/G d)d*„ d*e*ƒZ0G d+d,„ d,e)ƒZ1G d-d.„ d.e)ƒZ2d/d0„ Z3dS )1z 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__© r   r   ú+/usr/lib/python3/dist-packages/jsonpatch.pyr   J   ó    r   c                   @   r
   )ÚInvalidJsonPatchz, Raised if an invalid JSON Patch is created Nr   r   r   r   r   r   N   r   r   c                   @   r
   )ÚJsonPatchConflicta
  Raised if patch could not be applied due to conflict situation such as:
    - attempt to add object key when it already exists;
    - attempt to operate with nonexistence object key;
    - attempt to insert value to array at position beyond its size;
    - etc.
    Nr   r   r   r   r   r   R   r   r   c                   @   r
   )ÚJsonPatchTestFailedz A Test operation failed Nr   r   r   r   r   r   [   r   r   c                 C   s<   t  t¡}| D ]\}}||  |¡ qtdd„ | ¡ D ƒƒS )z'Convert duplicate keys values to lists.c                 s   s0   � | ]\}}|t |ƒd kr|d n|fV  qdS )r   r   N)Úlen)Ú.0ÚkeyÚvaluesr   r   r   Ú	<genexpr>f   s
   € ÿ
þzmultidict.<locals>.<genexpr>)ÚcollectionsÚdefaultdictÚlistÚappendÚdictÚitems)Úordered_pairsÚmdictr   Úvaluer   r   r   Ú	multidict_   s   
ýr%   )Úobject_pairs_hookFc                 C   s2   t |tƒrtj||d�}nt||d�}| | |¡S )a¬  Apply list of patches to specified json document.

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

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

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

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

    :return: Patched document object.
    :rtype: dict

    >>> doc = {'foo': 'bar'}
    >>> patch = [{'op': 'add', 'path': '/baz', 'value': 'qux'}]
    >>> other = apply_patch(doc, patch)
    >>> doc is not other
    True
    >>> other == {'foo': 'bar', 'baz': 'qux'}
    True
    >>> patch = [{'op': 'add', 'path': '/baz', 'value': 'qux'}]
    >>> apply_patch(doc, patch, in_place=True) == {'foo': 'bar', 'baz': 'qux'}
    True
    >>> doc == other
    True
    ©Úpointer_cls)Ú
isinstanceÚ
basestringÚ	JsonPatchÚfrom_stringÚapply)ÚdocÚpatchÚin_placer(   r   r   r   Úapply_patchr   s   
!r1   c                 C   s   t j| ||d�S )a!  Generates patch by comparing two document objects. Actually is
    a proxy to :meth:`JsonPatch.from_diff` method.

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

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

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

    >>> src = {'foo': 'bar', 'numbers': [1, 3, 4, 8]}
    >>> dst = {'baz': 'qux', 'numbers': [1, 4, 7]}
    >>> patch = make_patch(src, dst)
    >>> new = patch.apply(src)
    >>> new == dst
    True
    r'   )r+   Ú	from_diff)ÚsrcÚdstr(   r   r   r   Ú
make_patchš   s   r5   c                   @   sb   e Zd ZdZefdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Z	e
dd„ ƒZe
dd„ ƒZejdd„ ƒZdS )ÚPatchOperationz'A single operation inside a JSON Patch.c              
   C   sˆ   || _ | d¡stdƒ‚t|d | j ƒr |d j| _|d | _n|d | _z	|   | j¡| _W n ty> } ztdƒ‚d }~ww || _d S )NÚpathz#Operation must have a 'path' memberzInvalid 'path')	r(   Ú__contains__r   r)   r7   ÚlocationÚpointerÚ	TypeErrorÚ	operation)Úselfr<   r(   Úexr   r   r   Ú__init__µ   s   

€ÿ
zPatchOperation.__init__c                 C   s   t dƒ‚)zGAbstract method that applies a patch operation to the specified object.z%should implement the patch operation.)ÚNotImplementedError)r=   Úobjr   r   r   r-   Ç   ó   zPatchOperation.applyc                 C   s   t t| j ¡ ƒƒS ©N)ÚhashÚ	frozensetr<   r!   ©r=   r   r   r   Ú__hash__Ë   s   zPatchOperation.__hash__c                 C   ó   t |tƒsdS | j|jkS ©NF)r)   r6   r<   ©r=   Úotherr   r   r   Ú__eq__Î   ó   
zPatchOperation.__eq__c                 C   ó
   | |k S rC   r   rJ   r   r   r   Ú__ne__Ó   ó   
zPatchOperation.__ne__c                 C   s   d  | jjd d… ¡S )Nú/éÿÿÿÿ)Újoinr:   ÚpartsrF   r   r   r   r7   Ö   s   zPatchOperation.pathc                 C   s2   z	t | jjd ƒW S  ty   | jjd  Y S w )NrR   )Úintr:   rT   Ú
ValueErrorrF   r   r   r   r   Ú   s
   ÿzPatchOperation.keyc                 C   s*   t |ƒ| jjd< | jj| _| j| jd< d S )NrR   r7   )Ústrr:   rT   r7   r9   r<   )r=   r$   r   r   r   r   á   s   
N)r   r   r   r   r   r?   r-   rG   rL   rO   Úpropertyr7   r   Úsetterr   r   r   r   r6   ²   s    

r6   c                   @   ó(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚRemoveOperationz/Removes an object property or an array element.c              
   C   sL   | j  |¡\}}z||= W |S  ttfy% } z	d |¡}t|ƒ‚d }~ww )Nz(can't remove a non-existent object '{0}')r:   Úto_lastÚKeyErrorÚ
IndexErrorÚformatr   )r=   rA   ÚsubobjÚpartr>   Úmsgr   r   r   r-   ë   s   ü
€þzRemoveOperation.applyc                 C   s2   | j |kr| j|kr|  jd7  _|S |d8 }|S ©Nr   ©r7   r   ©r=   r7   r   r   r   r   Ú_on_undo_removeõ   ó   

ÿzRemoveOperation._on_undo_removec                 C   s2   | j |kr| j|kr|  jd8  _|S |d8 }|S rc   rd   re   r   r   r   Ú_on_undo_addý   rg   zRemoveOperation._on_undo_addN©r   r   r   r   r-   rf   rh   r   r   r   r   r[   è   s
    
r[   c                   @   rZ   )	ÚAddOperationz,Adds an object property or an array element.c              
   C   sÞ   z| j d }W n ty } ztdƒ‚d }~ww | j |¡\}}t|tƒrF|dkr0| |¡ |S |t|ƒks:|dk r>t	dƒ‚| 
||¡ |S t|tƒrY|d u rS|}|S |||< |S |d u rftd t|ƒ¡ƒ‚t	d | j|¡ƒ‚)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})r<   r]   r   r:   r\   r)   r   r   r   r   Úinsertr   r;   r_   Útyper9   )r=   rA   r$   r>   r`   ra   r   r   r   r-   	  s4   ÿ€ÿ

ï
õ	ùüzAddOperation.applyc                 C   s2   | j |kr| j|kr|  jd7  _|S |d7 }|S rc   rd   re   r   r   r   rf   )  rg   zAddOperation._on_undo_removec                 C   s2   | j |kr| j|kr|  jd8  _|S |d7 }|S rc   rd   re   r   r   r   rh   1  rg   zAddOperation._on_undo_addNri   r   r   r   r   rj     s
     rj   c                   @   rZ   )	ÚReplaceOperationz?Replaces an object property or an array element by a new value.c              
   C   sâ   z| j d }W n ty } ztdƒ‚d }~ww | j |¡\}}|d u r&|S |dkr.tdƒ‚t|tƒrB|t|ƒks=|dk rAtdƒ‚n)t|t	ƒrU||vrTd 
|¡}t|ƒ‚n|d u rbtd 
t|ƒ¡ƒ‚td	 
| j|¡ƒ‚|||< |S )
Nr$   rk   rl   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}'rm   rn   )r<   r]   r   r:   r\   r)   r   r   r   r   r_   r;   rp   r9   )r=   rA   r$   r>   r`   ra   rb   r   r   r   r-   =  s6   ÿ€ÿ
ÿ

þzReplaceOperation.applyc                 C   ó   |S rC   r   re   r   r   r   rf   ]  ó   z ReplaceOperation._on_undo_removec                 C   rr   rC   r   re   r   r   r   rh   `  rs   zReplaceOperation._on_undo_addNri   r   r   r   r   rq   :  s
     rq   c                   @   sN   e Zd ZdZdd„ Zedd„ ƒZedd„ ƒZejdd„ ƒZd	d
„ Z	dd„ Z
dS )ÚMoveOperationz?Moves an object property or an array element to a new location.c              
   C   s  zt | jd | jƒr| jd }n|  | jd ¡}W n ty) } ztdƒ‚d }~ww | |¡\}}z|| }W n ttfyK } ztt|ƒƒ‚d }~ww | j	|krS|S t |t
ƒrb| j	 |¡rbtdƒ‚td| jd dœ| jd� |¡}td| j|dœ| jd� |¡}|S )	NÚfromú.The operation does not contain a 'from' memberz*Cannot move values into their own childrenÚremove©Úopr7   r'   Úadd©ry   r7   r$   )r)   r<   r(   r]   r   r\   r^   r   rW   r:   r   Úcontainsr[   r-   rj   r9   ©r=   rA   Úfrom_ptrr>   r`   ra   r$   r   r   r   r-   g  sT   €ÿ€ÿ€ÿ


ÿþýýýüüzMoveOperation.applyc                 C   s$   |   | jd ¡}d |jd d… ¡S )Nru   rQ   rR   )r(   r<   rS   rT   ©r=   r~   r   r   r   Ú	from_pathŒ  s   zMoveOperation.from_pathc                 C   s>   |   | jd ¡}zt|jd ƒW S  ty   |jd  Y S w ©Nru   rR   )r(   r<   rU   rT   r;   r   r   r   r   Úfrom_key‘  s   ÿzMoveOperation.from_keyc                 C   s.   |   | jd ¡}t|ƒ|jd< |j| jd< d S r�   )r(   r<   rW   rT   r7   )r=   r$   r~   r   r   r   r‚   ™  s   c                 C   s^   | j |kr| j|kr|  jd7  _n|d8 }| j|kr-| j|kr)|  jd7  _|S |d7 }|S rc   ©r€   r‚   r7   r   re   r   r   r   rf   Ÿ  ó   



ÿzMoveOperation._on_undo_removec                 C   s^   | j |kr| j|kr|  jd8  _n|d8 }| j|kr-| j|kr)|  jd8  _|S |d7 }|S rc   rƒ   re   r   r   r   rh   ¬  r„   zMoveOperation._on_undo_addN)r   r   r   r   r-   rX   r€   r‚   rY   rf   rh   r   r   r   r   rt   d  s    %


rt   c                   @   ó   e Zd ZdZdd„ ZdS )ÚTestOperationz!Test value by specified location.c              
   C   s²   z| j  |¡\}}|d u r|}n| j  ||¡}W n ty* } ztt|ƒƒ‚d }~ww z| jd }W n tyB } ztdƒ‚d }~ww ||krWd}t| 	|t
|ƒ|t
|ƒ¡ƒ‚|S )Nr$   rk   z0{0} ({1}) is not equal to tested value {2} ({3}))r:   r\   Úwalkr   r   rW   r<   r]   r   r_   rp   )r=   rA   r`   ra   Úvalr>   r$   rb   r   r   r   r-   ½  s0   €€ÿÿ€ÿÿzTestOperation.applyN©r   r   r   r   r-   r   r   r   r   r†   º  ó    r†   c                   @   r…   )ÚCopyOperationzA Copies an object property or an array element to a new location c              
   C   s¢   z
|   | jd ¡}W n ty } ztdƒ‚d }~ww | |¡\}}z	t || ¡}W n ttfy? } ztt	|ƒƒ‚d }~ww t
d| j|dœ| j d� |¡}|S )Nru   rv   rz   r{   r'   )r(   r<   r]   r   r\   ÚcopyÚdeepcopyr^   r   rW   rj   r9   r-   r}   r   r   r   r-   Ø  s2   ÿ€ÿ€ÿýüüzCopyOperation.applyNr‰   r   r   r   r   r‹   Õ  rŠ   r‹   c                   @   sÄ   e Zd ZeejƒZeeƒZe	e
eeeeedœƒZ	 efdd„Zdd„ Zdd„ ZeZdd	„ Zd
d„ Zdd„ Zdd„ Zedefdd„ƒZeddefdd„ƒZddd„Zedd„ ƒZd dd„Z dd„ Z!dS )!r+   )rw   rz   ÚreplaceÚmoveÚtestrŒ   c                 C   s&   || _ || _| j D ]}|  |¡ q	d S rC   )r/   r(   Ú_get_operation)r=   r/   r(   ry   r   r   r   r?   (  s
   
ÿzJsonPatch.__init__c                 C   s   |   ¡ S )zstr(self) -> self.to_string())Ú	to_stringrF   r   r   r   Ú__str__3  rB   zJsonPatch.__str__c                 C   ó
   t | jƒS rC   )Úboolr/   rF   r   r   r   Ú__bool__7  rP   zJsonPatch.__bool__c                 C   r”   rC   )Úiterr/   rF   r   r   r   Ú__iter__<  rP   zJsonPatch.__iter__c                 C   s   t t| jƒƒS rC   )rD   ÚtupleÚ_opsrF   r   r   r   rG   ?  s   zJsonPatch.__hash__c                 C   rH   rI   )r)   r+   rš   rJ   r   r   r   rL   B  rM   zJsonPatch.__eq__c                 C   rN   rC   r   rJ   r   r   r   rO   G  rP   zJsonPatch.__ne__Nc                 C   s   |p| j }||ƒ}| ||d�S )a¨  Creates JsonPatch instance from string source.

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

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

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

        :return: :class:`JsonPatch` instance.
        r'   )Újson_loader)ÚclsÚ	patch_strÚloadsr(   r›   r/   r   r   r   r,   J  s   
zJsonPatch.from_stringTc           	      C   sB   |p| j }t||||d�}| dd||¡ t| ¡ ƒ}| ||d�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œ   r3   r4   ÚoptimizationÚdumpsr(   r    ÚbuilderÚopsr   r   r   r2   ^  s
   
zJsonPatch.from_diffc                 C   s   |p| j }|| jƒS )z!Returns patch set as JSON string.)r    r/   )r=   r¥   r    r   r   r   r’   ƒ  s   

zJsonPatch.to_stringc                 C   s   t t| j| jƒƒS rC   )r™   Úmapr‘   r/   rF   r   r   r   rš   ˆ  s   zJsonPatch._opsFc                 C   s(   |st  |¡}| jD ]}| |¡}q
|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š   r-   )r=   rA   r0   r<   r   r   r   r-   Œ  s
   

zJsonPatch.applyc                 C   sZ   d|vrt dƒ‚|d }t|tƒst dƒ‚|| jvr!t d |¡ƒ‚| j| }||| jd�S )Nry   z&Operation does not contain 'op' memberzOperation must be a stringzUnknown operation {0!r}r'   )r   r)   r*   Ú
operationsr_   r(   )r=   r<   ry   rœ   r   r   r   r‘   ¡  s   


zJsonPatch._get_operationrC   )F)"r   r   r   ÚstaticmethodÚjsonr¥   r    Ú
_jsonloadsr›   r   r[   rj   rq   rt   r†   r‹   r©   r   r?   r“   r–   Ú__nonzero__r˜   rG   rL   rO   Úclassmethodr,   r2   r’   rX   rš   r-   r‘   r   r   r   r   r+   î  s>    
ú	-þ
$

r+   c                   @   s„   e Zd Zejefdd„Zdd„ Zdd„ Zdd„ Z	d	d
„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )r¡   c                 C   sL   || _ || _i i g| _g g g| _g  | _}|| _|| _||d g|d d …< d S rC   )r¥   r(   Úindex_storageÚindex_storage2Ú_DiffBuilder__rootÚsrc_docÚdst_doc)r=   r²   r³   r¥   r(   Úrootr   r   r   r?   ³  s   


zDiffBuilder.__init__c                 C   sv   |t |ƒf}z | j| }| |¡}|d u r|g||< W d S ||  |¡ W d S  ty:   | j|  ||f¡ Y d S w rC   )rp   r¯   Úgetr   r;   r°   )r=   r$   ÚindexÚstÚ	typed_keyÚstorageÚstoredr   r   r   Ústore_index½  s   

ÿzDiffBuilder.store_indexc                 C   s�   |t |ƒf}z| j|  |¡}|r| ¡ W S W d S  tyG   | j| }tt|ƒd ddƒD ]}|| d |krC| |¡d    Y S q.Y d S w )Nr   rR   r   )rp   r¯   rµ   Úpopr;   r°   Úranger   )r=   r$   r·   r¸   rº   r¹   Úir   r   r   Ú
take_indexÊ  s   
ÿ
ÿÿþzDiffBuilder.take_indexc                 C   s,   | j }|d }|||g |d< |d< |d S )Nr   r   ©r±   )r=   ry   r´   Úlastr   r   r   ro   ×  s   zDiffBuilder.insertc                 C   s*   |\}}}||d< ||d< g |d d …< d S )Nr   r   r   )r=   r¶   Ú	link_prevÚ	link_nextÚ_r   r   r   rw   Ý  s   
zDiffBuilder.removec                 c   s:   � | j }|d }||ur|d V  |d }||usd S d S ©Nr   é   rÀ   )r=   Ústartr´   Úcurrr   r   r   Ú	iter_fromã  ó   €
þzDiffBuilder.iter_fromc                 c   s:   � | j }|d }||ur|d V  |d }||usd S d S rÅ   rÀ   )r=   r´   rÈ   r   r   r   r˜   ê  rÊ   zDiffBuilder.__iter__c                 c   s²   � | j }|d }||urW|d |urG|d |d d }}|j|jkrGt|ƒtkrGt|ƒtkrGtd|j|jd dœ| jd�jV  |d d }q|d jV  |d }||usd S d S )Nr   rÆ   rŽ   r$   r{   r'   )r±   r9   rp   r[   rj   rq   r<   r(   )r=   r´   rÈ   Úop_firstÚ	op_secondr   r   r   r£   ñ  s.   €ýüüñzDiffBuilder.executec           	      C   sÚ   |   |t¡}|d urQ|d }t|jƒtkr,t|ƒtkr,|  |¡D ]}| |j|j¡|_q |  |¡ |j	t
||ƒkrOtd|j	t
||ƒdœ| jd�}|  |¡ d S d S tdt
||ƒ|dœ| jd�}|  |¡}|  ||t¡ d S )NrÆ   r�   ©ry   ru   r7   r'   rz   r{   )r¿   Ú
_ST_REMOVErp   r   rU   rÉ   rf   r7   rw   r9   Ú
_path_joinrt   r(   ro   rj   r»   Ú_ST_ADD)	r=   r7   r   Úitemr¶   ry   ÚvÚnew_opÚ	new_indexr   r   r   Ú_item_added  s4   
ýüúýü
zDiffBuilder._item_addedc           
      C   sÜ   t dt||ƒdœ| jd�}|  |t¡}|  |¡}|d ure|d }|j | j¡d }t	|ƒt
kr@|  |¡D ]}	|	 |j|j¡|_q4|  |¡ |j|jkr^td|j|jdœ| jd�}||d< d S |  |¡ d S |  ||t¡ d S )Nrw   rx   r'   rÆ   r   r�   rÍ   )r[   rÏ   r(   r¿   rÐ   ro   r:   r\   r³   rp   r   rÉ   rh   r7   r   rw   r9   rt   r»   rÎ   )
r=   r7   r   rÑ   rÓ   r¶   rÔ   ry   Ú
added_itemrÒ   r   r   r   Ú_item_removed  s4   þý

ýüzDiffBuilder._item_removedc                 C   s&   |   tdt||ƒ|dœ| jd�¡ d S )NrŽ   r{   r'   )ro   rq   rÏ   r(   )r=   r7   r   rÑ   r   r   r   Ú_item_replaced?  s   ýüzDiffBuilder._item_replacedc           	      C   s’   t | ¡ ƒ}t | ¡ ƒ}|| }|| }|D ]}|  |t|ƒ|| ¡ q|D ]}|  |t|ƒ|| ¡ q&||@ D ]}|  |||| || ¡ q8d S rC   )ÚsetÚkeysr×   rW   rÕ   r¢   )	r=   r7   r3   r4   Úsrc_keysÚdst_keysÚ
added_keysÚremoved_keysr   r   r   r   Ú_compare_dictsF  s   ÿzDiffBuilder._compare_dictsc                 C   sü   t |ƒt |ƒ}}t||ƒ}t||ƒ}t|ƒD ]d}||k rd|| || }	}
|	|
kr+qt|	tƒr@t|
tƒr@|  t||ƒ|	|
¡ qt|	tƒrUt|
tƒrU|  	t||ƒ|	|
¡ q|  
|||	¡ |  |||
¡ q||krr|  
|||| ¡ q|  |||| ¡ qd S rC   )r   ÚmaxÚminr½   r)   r   rß   rÏ   r   Ú_compare_listsr×   rÕ   )r=   r7   r3   r4   Úlen_srcÚlen_dstÚmax_lenÚmin_lenr   ÚoldÚnewr   r   r   râ   U  s,   


ÿ
ÿêzDiffBuilder._compare_listsc                 C   s‚   t |tƒrt |tƒr|  t||ƒ||¡ d S t |tƒr,t |tƒr,|  t||ƒ||¡ d S |  |¡|  |¡kr8d S |  |||¡ d S rC   )r)   r   rß   rÏ   r   râ   r¥   rØ   )r=   r7   r   r3   r4   r   r   r   r¢   q  s   
ÿ
ÿ	zDiffBuilder._compare_valuesN)r   r   r   r«   r¥   r   r?   r»   r¿   ro   rw   rÉ   r˜   r£   rÕ   r×   rØ   rß   râ   r¢   r   r   r   r   r¡   ±  s    
!r¡   c                 C   s,   |d u r| S | d t |ƒ dd¡ dd¡ S )NrQ   ú~z~0z~1)rW   rŽ   rd   r   r   r   rÏ   ˆ  s    rÏ   )4r   Ú
__future__r   r   rŒ   Ú	functoolsr«   ÚsysÚtypesr   ÚImportErrorr    Újsonpointerr   r   rÐ   rÎ   Úcollections.abcr   r   ÚunicoderW   Ú
__author__Ú__version__Ú__website__Ú__license__Úversion_infoÚbytesr*   Ú	Exceptionr   r   r   ÚAssertionErrorr   r%   Úpartialrž   r¬   r1   r5   Úobjectr6   r[   rj   rq   rt   r†   r‹   r+   r¡   rÏ   r   r   r   r   Ú<module>   s^    þþ
	(64*V D X