Sindbad~EG File Manager
3
!��c�p � @ s� d Z ddlmZ ddlZddlZddlZddlZddlZyddlm Z W n e
k
r` eZ Y nX ddlm
Z
mZ dZdZyddlmZmZ W n( e
k
r� ddlmZmZ eZY nX dZd Zd
ZdZejd1kr�eefZG d
d� de�ZG dd� de�ZG dd� de�Z G dd� dee!�Z"dd� Z#ej$ej%e#d�Z&de
fdd�Z'e
fdd�Z(G dd� de)�Z*G dd � 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� Z3dS )2z Apply JSON-Patches (RFC 6902) � )�unicode_literalsN)�MappingProxyType)�JsonPointer�JsonPointerException� )�MutableMapping�MutableSequenceu Stefan Kögl <stefan@skoegl.net>z1.32z0https://github.com/stefankoegl/python-json-patchzModified BSD License� c @ s e Zd ZdZdS )�JsonPatchExceptionzBase Json Patch exceptionN)�__name__�
__module__�__qualname__�__doc__� r r �./tmp/pip-build-_uu8ur7s/jsonpatch/jsonpatch.pyr
J s r
c @ s e Zd ZdZdS )�InvalidJsonPatchz, Raised if an invalid JSON Patch is created N)r r r
r r r r r r N s r c @ s e Zd ZdZdS )�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.
N)r r r
r r r r r r R s r c @ s e Zd ZdZdS )�JsonPatchTestFailedz A Test operation failed N)r r r
r r r r r r [ s r c C s@ t jt�}x| D ]\}}|| j|� qW tdd� |j� D ��S )z'Convert duplicate keys values to lists.c s s. | ]&\}}|t |�d kr |d n|fV qdS )r r N)�len)�.0�key�valuesr r r � <genexpr>h s zmultidict.<locals>.<genexpr>)�collections�defaultdict�list�append�dict�items)Z
ordered_pairsZmdictr �valuer r r � multidict_ s
r )�object_pairs_hookFc C s2 t |t�rtj||d�}nt||d�}|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_placer"