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

Class JSONPatch

source code


Representation of a JSONPatch task list for RFC6902.

Contains the defined methods from standards:

* add
* remove
* replace
* move
* copy
* test
 
Attributes:
    patch: List of patch items.
    

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__add__(self, x=None)
Creates a copy of 'self' and adds a patch jobs to the task queue.
source code
 
__call__(self, j, x=None)
Evaluates the related task for the provided index.
source code
 
__eq__(self, x)
Compares this pointer with x.
source code
 
__getitem__(self, key)
Support of slices, for 'iterator' refer to self.__iter__.
source code
 
__iadd__(self, x=None)
Adds patch jobs to the task queue in place.
source code
 
__isub__(self, x)
Removes the patch job from the task queue in place.
source code
 
__iter__(self)
Provides an iterator foreseen for large amounts of in-memory patches.
source code
 
__len__(self)
The number of outstanding patches.
source code
 
__ne__(self, x)
Compares this pointer with x.
source code
 
__repr__(self)
Prints the representation format of a JSON patch list.
source code
 
__str__(self)
Prints the display format.
source code
 
__sub__(self, x)
Removes the patch job from the task queue.
source code
 
apply(self, jsondata)
Applies the JSONPatch task.
source code
 
get(self, x=None) source code
 
patch_export(self, patchfile, schema=None, **kargs)
Exports the current task list.
source code
 
patch_import(self, patchfile, schemafile=None, **kargs)
Imports a task list.
source code
 
repr_export(self)
Prints the export representation format of a JSON patch list.
source code

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

Instance Variables [hide private]
  patch
List of patch tasks.
  deep
Defines copy operations, True:=deep, False:=swallow
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__call__(self, j, x=None)
(Call operator)

source code 
Evaluates the related task for the provided index.

Args:
    x: Task index.

    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 slices, for 'iterator' refer to self.__iter__.

#. self[key]

#. self[i:j:k]

#. x in self

#. for x in self

__isub__(self, x)

source code 
Removes the patch job from the task queue in place. 

Removes one of the following type(x) variants:

    int: The patch job with given index.
     
    JSONPatchItem: The first matching entry from 
        the task queue. 

Args:
    x: Item to be removed.

Returns:
    Returns resulting list without x.

Raises:
    JSONPatchException:

__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 representation format of a JSON patch list.

Overrides: object.__repr__

__str__(self)
(Informal representation operator)

source code 

Prints the display format.

Overrides: object.__str__

__sub__(self, x)
(Subtraction operator)

source code 
Removes the patch job from the task queue. 

Removes one of the following type(x) variants:

    int: The patch job with given index.
     
    JSONPatchItem: The first matching entry from 
        the task queue. 

Args:
    x: Item to be removed.

Returns:
    Returns resulting list without x.

Raises:
    JSONPatchException:

apply(self, jsondata)

source code 
Applies the JSONPatch task.

Args:
    jsondata: JSON data the joblist 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:

patch_export(self, patchfile, schema=None, **kargs)

source code 
Exports the current task list.

Provided formats are:
    RFC6902

Supports the formats:
    RFC6902

Args:
    patchfile:
        JSON patch for export.
    schema:
        JSON-Schema for validation of the patch list.
    **kargs:
        validator: [default, draft3, off, ]
            Sets schema validator for the data file.
            The values are: default=validate, draft3=Draft3Validator,
            off=None.
            default:= validate

Returns:
    When successful returns 'True', else raises an exception.

Raises:
    JSONPatchException:

patch_import(self, patchfile, schemafile=None, **kargs)

source code 
Imports a task list.

Supports the formats:
    RFC6902

Args:
    patchfile:
        JSON patch filename containing the list of patch operations.
    schemafile:
        JSON-Schema filename for validation of the patch list.
    **kargs:
        validator: [default, draft3, off, ]
            Sets schema validator for the data file.
            The values are: default=validate, draft3=Draft3Validator,
            off=None.
            default:= validate

Returns:
    When successful returns 'True', else raises an exception.

Raises:
    JSONPatchException: