509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
d�GZ–_  ã               @   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ddlZddl	Z	ddl
mZmZ dZdZyddlmZmZ W n( ek
rœ   ddlmZmZ eZY nX dZdZd	Zd
Ze	jd0krÀe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%d1dd„Z&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*ƒZ/G d*d+„ d+e*ƒZ0G d,d-„ d-e(ƒZ1d.d/„ Z2dS )2z Apply JSON-Patches (RFC 6902) é    )Úunicode_literalsN)ÚJsonPointerÚJsonPointerExceptioné   )ÚMutableMappingÚMutableSequenceu    Stefan KÃ¶gl <stefan@skoegl.net>z1.21z0https://github.com/stefankoegl/python-json-patchzModified BSD Licenseé   c               @   s   e Zd ZdZdS )ÚJsonPatchExceptionzBase Json Patch exceptionN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   ú/usr/lib/python3.6/jsonpatch.pyr	   G   s   r	   c               @   s   e Zd ZdZdS )ÚInvalidJsonPatchz, Raised if an invalid JSON Patch is created N)r
   r   r   r   r   r   r   r   r   K   s   r   c               @   s   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 then it already exists;
    - attempt to operate with nonexistence object key;
    - attempt to insert value to array at position beyond of it size;
    - etc.
    N)r
   r   r   r   r   r   r   r   r   O   s   r   c               @   s   e Zd ZdZdS )ÚJsonPatchTestFailedz A Test operation failed N)r
   r   r   r   r   r   r   r   r   X   s   r   c             C   s@   t jtƒ}x| D ]\}}|| j|ƒ qW tdd„ |jƒ D ƒƒS )z'Convert duplicate keys values to lists.c             s   s.   | ]&\}}|t |ƒd kr |d n|fV  qdS )r   r   N)Úlen)Ú.0ÚkeyÚvaluesr   r   r   ú	<genexpr>e   s   zmultidict.<locals>.<genexpr>)ÚcollectionsÚdefaultdictÚlistÚappendÚdictÚitems)Zordered_pairsZmdictr   Úvaluer   r   r   Ú	multidict\   s    
r   )Zobject_pairs_hookFc             C   s*   t |tƒrtj|ƒ}nt|ƒ}|j| |ƒS )aO  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

    :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
    )Ú
isinstanceÚ
basestringÚ	JsonPatchÚfrom_stringÚapply)ÚdocÚpatchÚin_placer   r   r   Úapply_patcho   s    
r(   c             C   s   t j| |ƒS )aÇ  Generates patch by comparing of 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

    >>> 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"   Ú	from_diff)ÚsrcÚdstr   r   r   Ú
make_patch”   s    r,   c               @   sŒ   e Zd ZdZ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d„ ƒZeddd„ƒZdd„ Zedd„ ƒZd dd„Zdd„ ZdS )!r"   ag  A JSON Patch is a list of Patch Operations.

    >>> patch = JsonPatch([
    ...     {'op': 'add', 'path': '/foo', 'value': 'bar'},
    ...     {'op': 'add', 'path': '/baz', 'value': [1, 2, 3]},
    ...     {'op': 'remove', 'path': '/baz/1'},
    ...     {'op': 'test', 'path': '/baz', 'value': [1, 3]},
    ...     {'op': 'replace', 'path': '/baz/0', 'value': 42},
    ...     {'op': 'remove', 'path': '/baz/1'},
    ... ])
    >>> doc = {}
    >>> result = patch.apply(doc)
    >>> expected = {'foo': 'bar', 'baz': [42]}
    >>> result == expected
    True

    JsonPatch object is iterable, so you could easily access to each patch
    statement in loop:

    >>> lpatch = list(patch)
    >>> expected = {'op': 'add', 'path': '/foo', 'value': 'bar'}
    >>> lpatch[0] == expected
    True
    >>> lpatch == patch.patch
    True

    Also JsonPatch could be converted directly to :class:`bool` if it contains
    any operation statements:

    >>> bool(patch)
    True
    >>> bool(JsonPatch([]))
    False

    This behavior is very handy with :func:`make_patch` to write more readable
    code:

    >>> old = {'foo': 'bar', 'numbers': [1, 3, 4, 8]}
    >>> new = {'baz': 'qux', 'numbers': [1, 4, 7]}
    >>> patch = make_patch(old, new)
    >>> if patch:
    ...     # document have changed, do something useful
    ...     patch.apply(old)    #doctest: +ELLIPSIS
    {...}
    c             C   s   || _ ttttttdœ| _d S )N)ÚremoveÚaddÚreplaceÚmoveZtestÚcopy)r&   ÚRemoveOperationÚAddOperationÚReplaceOperationÚMoveOperationÚTestOperationÚCopyOperationÚ
operations)Úselfr&   r   r   r   Ú__init__×   s    zJsonPatch.__init__c             C   s   | j ƒ S )zstr(self) -> self.to_string())Ú	to_string)r9   r   r   r   Ú__str__ã   s    zJsonPatch.__str__c             C   s
   t | jƒS )N)Úboolr&   )r9   r   r   r   Ú__bool__ç   s    zJsonPatch.__bool__c             C   s
   t | jƒS )N)Úiterr&   )r9   r   r   r   Ú__iter__ì   s    zJsonPatch.__iter__c             C   s   t t| jƒƒS )N)ÚhashÚtupleÚ_ops)r9   r   r   r   Ú__hash__ï   s    zJsonPatch.__hash__c             C   s   t |tƒsdS | j|jkS )NF)r    r"   rC   )r9   Úotherr   r   r   Ú__eq__ò   s    
zJsonPatch.__eq__c             C   s
   | |k S )Nr   )r9   rE   r   r   r   Ú__ne__÷   s    zJsonPatch.__ne__c             C   s   t |ƒ}| |ƒS )z¸Creates JsonPatch instance from string source.

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

        :return: :class:`JsonPatch` instance.
        )Ú
_jsonloads)ÚclsZ	patch_strr&   r   r   r   r#   ú   s    	zJsonPatch.from_stringTc             C   s*   t ƒ }|jdd||ƒ t|jƒ ƒ}| |ƒS )aO  Creates JsonPatch instance based on comparing 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

        :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
        Ú N)ÚDiffBuilderÚ_compare_valuesr   Úexecute)rI   r*   r+   ÚoptimizationZbuilderZopsr   r   r   r)     s    zJsonPatch.from_diffc             C   s   t j| jƒS )z!Returns patch set as JSON string.)ÚjsonÚdumpsr&   )r9   r   r   r   r;   !  s    zJsonPatch.to_stringc             C   s   t t| j| jƒƒS )N)rB   ÚmapÚ_get_operationr&   )r9   r   r   r   rC   %  s    zJsonPatch._opsFc             C   s,   |st j|ƒ}x| jD ]}|j|ƒ}qW |S )a/  Applies the patch to given object.

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

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

        :return: Modified `obj`.
        )r1   ÚdeepcopyrC   r$   )r9   Úobjr'   Ú	operationr   r   r   r$   )  s
    
zJsonPatch.applyc             C   sT   d|krt dƒ‚|d }t|tƒs*t dƒ‚|| jkrBt dj|ƒƒ‚| j| }||ƒS )NÚopz&Operation does not contain 'op' memberzOperation must be a stringzUnknown operation {0!r})r   r    r!   r8   Úformat)r9   rU   rV   rI   r   r   r   rR   >  s    


zJsonPatch._get_operationN)T)F)r
   r   r   r   r:   r<   r>   Z__nonzero__r@   rD   rF   rG   Úclassmethodr#   r)   r;   ÚpropertyrC   r$   rR   r   r   r   r   r"   ©   s    -
r"   c               @   s^   e Zd ZdZ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 | _ t| j ƒ| _|| _d S )NÚpath)Úlocationr   ÚpointerrU   )r9   rU   r   r   r   r:   Q  s    
zPatchOperation.__init__c             C   s   t dƒ‚dS )zAAbstract method that applies patch operation to specified object.z!should implement patch operation.N)ÚNotImplementedError)r9   rT   r   r   r   r$   V  s    zPatchOperation.applyc             C   s   t t| jjƒ ƒƒS )N)rA   Ú	frozensetrU   r   )r9   r   r   r   rD   Z  s    zPatchOperation.__hash__c             C   s   t |tƒsdS | j|jkS )NF)r    rZ   rU   )r9   rE   r   r   r   rF   ]  s    
zPatchOperation.__eq__c             C   s
   | |k S )Nr   )r9   rE   r   r   r   rG   b  s    zPatchOperation.__ne__c             C   s   dj | jjd d… ƒS )Nú/r   éÿÿÿÿ)Újoinr]   Úparts)r9   r   r   r   r[   e  s    zPatchOperation.pathc             C   s2   yt | jjd ƒS  tk
r,   | jjd S X d S )Nr   ra   ra   )Úintr]   rc   Ú
ValueError)r9   r   r   r   r   i  s    zPatchOperation.keyc             C   s*   t |ƒ| jjd< | jj| _| j| jd< d S )Nr   r[   ra   )Ústrr]   rc   r[   r\   rU   )r9   r   r   r   r   r   p  s    
N)r
   r   r   r   r:   r$   rD   rF   rG   rY   r[   r   Úsetterr   r   r   r   rZ   N  s   rZ   c               @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	r2   z/Removes an object property or an array element.c             C   sX   | j j|ƒ\}}y
||= W n8 ttfk
rR } zdj|ƒ}t|ƒ‚W Y d d }~X nX |S )Nz&can't remove non-existent object '{0}')r]   Úto_lastÚKeyErrorÚ
IndexErrorrW   r   )r9   rT   ÚsubobjÚpartÚexÚmsgr   r   r   r$   z  s    

zRemoveOperation.applyc             C   s0   | j |kr,| j|kr$|  jd7  _n|d8 }|S )Nr   )r[   r   )r9   r[   r   r   r   r   Ú_on_undo_remove„  s
    

zRemoveOperation._on_undo_removec             C   s0   | j |kr,| j|kr$|  jd8  _n|d8 }|S )Nr   )r[   r   )r9   r[   r   r   r   r   Ú_on_undo_addŒ  s
    

zRemoveOperation._on_undo_addN)r
   r   r   r   r$   ro   rp   r   r   r   r   r2   w  s   
r2   c               @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	r3   z,Adds an object property or an array element.c             C   sÌ   y| j d }W n* tk
r8 } ztdƒ‚W Y d d }~X nX | jj|ƒ\}}t|tƒr”|dkrh|j|ƒ qÈ|t|ƒks||dk r†t	dƒ‚qÈ|j
||ƒ n4t|tƒr¶|d kr¬|}qÈ|||< ntdjt|ƒƒƒ‚|S )Nr   z/The operation does not contain a 'value' memberú-r   zcan't insert outside of listzinvalid document type {0})rU   ri   r   r]   rh   r    r   r   r   r   Úinsertr   Ú	TypeErrorrW   Útype)r9   rT   r   rm   rk   rl   r   r   r   r$   ˜  s$    



zAddOperation.applyc             C   s0   | j |kr,| j|kr$|  jd7  _n|d7 }|S )Nr   )r[   r   )r9   r[   r   r   r   r   ro   ¶  s
    

zAddOperation._on_undo_removec             C   s0   | j |kr,| j|kr$|  jd8  _n|d7 }|S )Nr   )r[   r   )r9   r[   r   r   r   r   rp   ¾  s
    

zAddOperation._on_undo_addN)r
   r   r   r   r$   ro   rp   r   r   r   r   r3   •  s   r3   c               @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	r4   z=Replaces an object property or an array element by new value.c             C   sÂ   y| j d }W n* tk
r8 } ztdƒ‚W Y d d }~X nX | jj|ƒ\}}|d krV|S t|tƒr~|t|ƒkst|dk r¶tdƒ‚n8t|t	ƒr¤||kr¶dj
|ƒ}t|ƒ‚ntdj
t|ƒƒƒ‚|||< |S )Nr   z/The operation does not contain a 'value' memberr   zcan't replace outside of listz'can't replace non-existent object '{0}'zinvalid document type {0})rU   ri   r   r]   rh   r    r   r   r   r   rW   rs   rt   )r9   rT   r   rm   rk   rl   rn   r   r   r   r$   Ê  s$    




zReplaceOperation.applyc             C   s   |S )Nr   )r9   r[   r   r   r   r   ro   ä  s    z ReplaceOperation._on_undo_removec             C   s   |S )Nr   )r9   r[   r   r   r   r   rp   ç  s    zReplaceOperation._on_undo_addN)r
   r   r   r   r$   ro   rp   r   r   r   r   r4   Ç  s   r4   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 )r5   z=Moves an object property or an array element to new location.c          !   C   sî   yt | jd ƒ}W n* tk
r< } ztdƒ‚W Y d d }~X nX |j|ƒ\}}y|| }W n2 ttfk
rŠ } ztt|ƒƒ‚W Y d d }~X nX | j|krš|S t	|t
ƒr¸| jj|ƒr¸tdƒ‚td| jd dœƒj|ƒ}td| j|dœƒj|ƒ}|S )NÚfromz.The operation does not contain a 'from' memberz(Cannot move values into its own childrenr-   )rV   r[   r.   )rV   r[   r   )r   rU   ri   r   rh   rj   r   rf   r]   r    r   Úcontainsr2   r$   r3   r\   )r9   rT   Úfrom_ptrrm   rk   rl   r   r   r   r   r$   î  s2    


zMoveOperation.applyc             C   s"   t | jd ƒ}dj|jd d… ƒS )Nru   r`   r   ra   )r   rU   rb   rc   )r9   rw   r   r   r   Ú	from_path  s    zMoveOperation.from_pathc             C   s<   t | jd ƒ}yt|jd ƒS  tk
r6   |jd S X d S )Nru   r   ra   ra   )r   rU   rd   rc   rs   )r9   rw   r   r   r   Úfrom_key  s
    zMoveOperation.from_keyc             C   s,   t | jd ƒ}t|ƒ|jd< |j| jd< d S )Nru   r   ra   )r   rU   rf   rc   r[   )r9   r   rw   r   r   r   ry     s    c             C   s\   | j |kr,| j|kr$|  jd7  _n|d8 }| j|krX| j|krP|  jd7  _n|d7 }|S )Nr   )rx   ry   r[   r   )r9   r[   r   r   r   r   ro   #  s    



zMoveOperation._on_undo_removec             C   s\   | j |kr,| j|kr$|  jd8  _n|d8 }| j|krX| j|krP|  jd8  _n|d7 }|S )Nr   )rx   ry   r[   r   )r9   r[   r   r   r   r   rp   0  s    



zMoveOperation._on_undo_addN)r
   r   r   r   r$   rY   rx   ry   rg   ro   rp   r   r   r   r   r5   ë  s   "r5   c               @   s   e Zd ZdZdd„ ZdS )r6   z!Test value by specified location.c          #   C   sÆ   y0| j j|ƒ\}}|d kr |}n| j j||ƒ}W n. tk
r^ } ztt|ƒƒ‚W Y d d }~X nX y| jd }W n* tk
r˜ } ztdƒ‚W Y d d }~X nX ||krÂd}t|j	|t
|ƒ|t
|ƒƒƒ‚|S )Nr   z/The operation does not contain a 'value' memberz0{0} ({1}) is not equal to tested value {2} ({3}))r]   rh   Úwalkr   r   rf   rU   ri   r   rW   rt   )r9   rT   rk   rl   Úvalrm   r   rn   r   r   r   r$   A  s"    zTestOperation.applyN)r
   r   r   r   r$   r   r   r   r   r6   >  s   r6   c               @   s   e Zd ZdZdd„ ZdS )r7   zA Copies an object property or an array element to a new location c          !   C   s®   yt | jd ƒ}W n* tk
r< } ztdƒ‚W Y d d }~X nX |j|ƒ\}}ytj|| ƒ}W n2 ttfk
r� } ztt	|ƒƒ‚W Y d d }~X nX t
d| j|dœƒj|ƒ}|S )Nru   z.The operation does not contain a 'from' memberr.   )rV   r[   r   )r   rU   ri   r   rh   r1   rS   rj   r   rf   r3   r\   r$   )r9   rT   rw   rm   rk   rl   r   r   r   r   r$   \  s     
zCopyOperation.applyN)r
   r   r   r   r$   r   r   r   r   r7   Y  s   r7   c               @   s|   e Z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d„ ZdS )rK   c             C   s4   i i g| _ g g g| _g  | _}||d g|d d …< d S )N)Úindex_storageÚindex_storage2Ú_DiffBuilder__root)r9   Úrootr   r   r   r:   t  s    


zDiffBuilder.__init__c             C   sh   y:| j | }|j|ƒ}|d kr*|g||< n|| j|ƒ W n( tk
rb   | j| j||fƒ Y nX d S )N)r|   Úgetr   rs   r}   )r9   r   ÚindexÚstÚstorageÚstoredr   r   r   Ústore_indexz  s    

zDiffBuilder.store_indexc             C   s€   y | j | j|ƒ}|r|jƒ S W nZ tk
rz   | j| }x:tt|ƒd ddƒD ]"}|| d |krP|j|ƒd S qPW Y nX d S )Nr   r   ra   ra   )r|   r€   Úpoprs   r}   Úranger   )r9   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~   )r9   rV   r   Zlastr   r   r   rr   ’  s    zDiffBuilder.insertc             C   s*   |\}}}||d< ||d< g |d d …< d S )Nr   r   r   )r9   r�   Z	link_prevZ	link_nextÚ_r   r   r   r-   ˜  s    
zDiffBuilder.removec             c   s2   | j }|d }x||k	r,|d V  |d }qW d S )Nr   é   )r~   )r9   Ústartr   Úcurrr   r   r   Ú	iter_fromž  s
    

zDiffBuilder.iter_fromc             c   s2   | j }|d }x||k	r,|d V  |d }qW d S )Nr   r‹   )r~   )r9   r   r�   r   r   r   r@   ¥  s
    

zDiffBuilder.__iter__c             c   s¤   | j }|d }x�||k	rž|d |k	rˆ|d |d d  }}|j|jkrˆt|ƒtkrˆt|ƒtkrˆtd|j|jd dœƒjV  |d d }q|d jV  |d }qW d S )Nr   r‹   r/   r   )rV   r[   r   )r~   r\   rt   r2   r3   r4   rU   )r9   r   r�   Zop_firstZ	op_secondr   r   r   rM   ¬  s     
zDiffBuilder.executec       	      C   sÀ   | j |tƒ}|d k	rŽ|d }t|jƒtkrPx$| j|ƒD ]}|j|j|jƒ|_q6W | j|ƒ |j	t
||ƒkr¼td|j	t
||ƒdœƒ}| j|ƒ n.tdt
||ƒ|dœƒ}| j|ƒ}| j||tƒ d S )Nr‹   r0   )rV   ru   r[   r.   )rV   r[   r   )r‰   Ú
_ST_REMOVErt   r   rd   rŽ   ro   r[   r-   r\   Ú
_path_joinr5   rr   r3   r…   Ú_ST_ADD)	r9   r[   r   Úitemr�   rV   ÚvÚnew_opÚ	new_indexr   r   r   Ú_item_addedÀ  s&    


zDiffBuilder._item_addedc       	      C   sÀ   t dt||ƒdœƒ}| j|tƒ}| j|ƒ}|d k	r®|d }t|jƒtkrnx$| j|ƒD ]}|j	|j
|jƒ|_qTW | j|ƒ |j|jkr¢td|j|jdœƒ}||d< q¼| j|ƒ n| j||tƒ d S )Nr-   )rV   r[   r‹   r0   )rV   ru   r[   )r2   r�   r‰   r‘   rr   rt   r   rd   rŽ   rp   r[   r-   r\   r5   r…   r�   )	r9   r[   r   r’   r”   r�   r•   rV   r“   r   r   r   Ú_item_removedÙ  s&    


zDiffBuilder._item_removedc             C   s    | j tdt||ƒ|dœƒƒ d S )Nr/   )rV   r[   r   )rr   r4   r�   )r9   r[   r   r’   r   r   r   Ú_item_replacedõ  s    zDiffBuilder._item_replacedc       	      C   sž   t |jƒ ƒ}t |jƒ ƒ}|| }|| }x"|D ]}| j|t|ƒ|| ƒ q.W x"|D ]}| j|t|ƒ|| ƒ qRW x(||@ D ]}| j|||| || ƒ qzW d S )N)ÚsetÚkeysr—   rf   r–   rL   )	r9   r[   r*   r+   Zsrc_keysZdst_keysZ
added_keysZremoved_keysr   r   r   r   Ú_compare_dictsü  s    

zDiffBuilder._compare_dictsc             C   s  t |ƒt |ƒ }}t||ƒ}t||ƒ}xÖt|ƒD ]Ê}||k rÌ|| ||  }	}
|	|
krZq0qút|	tƒr„t|
tƒr„| jt||ƒ|	|
ƒ qút|	tƒr®t|
tƒr®| j	t||ƒ|	|
ƒ qú| j
|||	ƒ | j|||
ƒ q0||krè| j
|||| ƒ q0| j|||| ƒ q0W d S )N)r   ÚmaxÚminr‡   r    r   r›   r�   r   Ú_compare_listsr—   r–   )r9   r[   r*   r+   Zlen_srcZlen_dstZmax_lenZmin_lenr   ÚoldÚnewr   r   r   rž     s&    





zDiffBuilder._compare_listsc             C   sr   ||krd S t |tƒr6t |tƒr6| jt||ƒ||ƒ n8t |tƒr`t |tƒr`| jt||ƒ||ƒ n| j|||ƒ d S )N)r    r   r›   r�   r   rž   r˜   )r9   r[   r   r*   r+   r   r   r   rL   '  s    



zDiffBuilder._compare_valuesN)r
   r   r   r:   r…   r‰   rr   r-   rŽ   r@   rM   r–   r—   r˜   r›   rž   rL   r   r   r   r   rK   r  s   rK   c             C   s,   |d kr| S | d t |ƒjddƒjddƒ S )Nr`   ú~z~0z~1)rf   r/   )r[   r   r   r   r   r�   7  s    r�   )r   r   )F)3r   Z
__future__r   r   r1   Ú	functoolsÚinspectÚ	itertoolsrO   ÚsysZjsonpointerr   r   r‘   r�   Úcollections.abcr   r   ÚImportErrorZunicoderf   Ú
__author__Ú__version__Z__website__Z__license__Úversion_infoÚbytesr!   Ú	Exceptionr	   r   r   ÚAssertionErrorr   r   ÚpartialÚloadsrH   r(   r,   Úobjectr"   rZ   r2   r3   r4   r5   r6   r7   rK   r�   r   r   r   r   Ú<module>!   sT   

	
% &)2$S F