Package jsondata :: Module JSONPatch :: Class JSONPatchItem
[hide private]
[frames] | no frames]

Class JSONPatchItem

source code


Record entry for list of patch tasks.

Attributes:
    op: operations:
            add, copy, move, remove, replace, test
    
    target: JSONPointer for the modification target, see RFC6902.
    
    value: Value, either a branch, or a leaf of the JSON data structure.
    src:  JSONPointer for the modification source, see RFC6902.
    

Instance Methods [hide private]
 
__init__(self, op, target, param=None)
Create an entry for the patch list.
source code
 
__call__(self, j)
Evaluates the related task for the provided data.
source code
 
__eq__(self, x)
Compares this pointer with x.
source code
 
__getitem__(self, key)
Support of various mappings.
source code
 
__ne__(self, x)
Compares this pointer with x.
source code
 
__repr__(self)
Prints the patch string in accordance to RFC6901.
source code
 
__str__(self)
Prints the patch string in accordance to RFC6901.
source code
 
apply(self, jsondata)
Applies the present patch list on the provided JSON document.
source code
 
repr_export(self)
Prints the patch string for export in accordance to RFC6901.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, op, target, param=None)
(Constructor)

source code 
Create an entry for the patch list.

Args:
    op: Operation: add, copy, move, remove, replace, test

    target: Target node.
            
    param: Parameter specific for the operation:
        value: add,replace, test
        src: copy, move
        param:=None for 'remove'

Returns:
    When successful returns 'True', else returns either 'False', or
    raises an exception.
    Success is the complete addition only, thus one failure returns
    False.

Raises:
    JSONDataSerializerError:

Overrides: object.__init__

__call__(self, j)
(Call operator)

source code 
Evaluates the related task for the provided data.

Args:
    j: JSON data the task has to be 
        applied on.

Returns:
    Returns a tuple of:
        0: len of the job list
        1: list of the execution status for 
            the tasks

Raises:
    JSONPatchException:

__eq__(self, x)
(Equality operator)

source code 
Compares this pointer with x.

Args:
    x: A valid Pointer.

Returns:
    True or False

Raises:
    JSONPointerException

__getitem__(self, key)
(Indexing operator)

source code 

Support of various mappings.

#. self[key]

#. self[i:j:k]

#. x in self

#. for x in self

__ne__(self, x)

source code 
Compares this pointer with x.

Args:
    x: A valid Pointer.

Returns:
    True or False

Raises:
    JSONPointerException

__repr__(self)
(Representation operator)

source code 

Prints the patch string in accordance to RFC6901.

Overrides: object.__repr__

__str__(self)
(Informal representation operator)

source code 

Prints the patch string in accordance to RFC6901.

Overrides: object.__str__

apply(self, jsondata)

source code 
Applies the present patch list on the provided JSON document.

Args:
    jsondata: Document to be patched.
Returns:
    When successful returns 'True', else raises an exception.
    Or returns a tuple:
      (n,lerr): n:    number of present active entries
                lerr: list of failed entries
Raises:
    JSONPatchException: