Skip to content

Commit

Permalink
Fixed some typos and wording
Browse files Browse the repository at this point in the history
  • Loading branch information
vavanade committed Feb 27, 2020
1 parent 91f6124 commit 8fbed9b
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions jsonpatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ class InvalidJsonPatch(JsonPatchException):

class JsonPatchConflict(JsonPatchException):
"""Raised if patch could not be applied due to conflict situation such as:
- attempt to add object key then it already exists;
- 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 of it size;
- attempt to insert value to array at position beyond its size;
- etc.
"""

Expand Down Expand Up @@ -144,7 +144,7 @@ def apply_patch(doc, patch, in_place=False):


def make_patch(src, dst):
"""Generates patch by comparing of two document objects. Actually is
"""Generates patch by comparing two document objects. Actually is
a proxy to :meth:`JsonPatch.from_diff` method.
:param src: Data source document object.
Expand Down Expand Up @@ -181,8 +181,8 @@ class JsonPatch(object):
>>> result == expected
True
JsonPatch object is iterable, so you could easily access to each patch
statement in loop:
JsonPatch object is iterable, so you can easily access each patch
statement in a loop:
>>> lpatch = list(patch)
>>> expected = {'op': 'add', 'path': '/foo', 'value': 'bar'}
Expand Down Expand Up @@ -259,7 +259,7 @@ def from_string(cls, patch_str):

@classmethod
def from_diff(cls, src, dst, optimization=True):
"""Creates JsonPatch instance based on comparing of two document
"""Creates JsonPatch instance based on comparison of two document
objects. Json patch would be created for `src` argument against `dst`
one.
Expand Down Expand Up @@ -293,13 +293,13 @@ def _ops(self):
return tuple(map(self._get_operation, self.patch))

def apply(self, obj, in_place=False):
"""Applies the patch to given object.
"""Applies the patch to a 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.
: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`.
Expand Down Expand Up @@ -344,8 +344,8 @@ def __init__(self, operation):
self.operation = operation

def apply(self, obj):
"""Abstract method that applies patch operation to specified object."""
raise NotImplementedError('should implement patch operation.')
"""Abstract method that applies a patch operation to the specified object."""
raise NotImplementedError('should implement the patch operation.')

def __hash__(self):
return hash(frozenset(self.operation.items()))
Expand Down Expand Up @@ -384,7 +384,7 @@ def apply(self, obj):
try:
del subobj[part]
except (KeyError, IndexError) as ex:
msg = "can't remove non-existent object '{0}'".format(part)
msg = "can't remove a non-existent object '{0}'".format(part)
raise JsonPatchConflict(msg)

return obj
Expand Down Expand Up @@ -459,7 +459,7 @@ def _on_undo_add(self, path, key):


class ReplaceOperation(PatchOperation):
"""Replaces an object property or an array element by new value."""
"""Replaces an object property or an array element by a new value."""

def apply(self, obj):
try:
Expand All @@ -479,7 +479,7 @@ def apply(self, obj):

elif isinstance(subobj, MutableMapping):
if part not in subobj:
msg = "can't replace non-existent object '{0}'".format(part)
msg = "can't replace a non-existent object '{0}'".format(part)
raise JsonPatchConflict(msg)
else:
if part is None:
Expand All @@ -498,7 +498,7 @@ def _on_undo_add(self, path, key):


class MoveOperation(PatchOperation):
"""Moves an object property or an array element to new location."""
"""Moves an object property or an array element to a new location."""

def apply(self, obj):
try:
Expand All @@ -522,7 +522,7 @@ def apply(self, obj):

if isinstance(subobj, MutableMapping) and \
self.pointer.contains(from_ptr):
raise JsonPatchConflict('Cannot move values into its own children')
raise JsonPatchConflict('Cannot move values into their own children')

obj = RemoveOperation({
'op': 'remove',
Expand Down Expand Up @@ -826,7 +826,7 @@ def _compare_values(self, path, key, src, dst):
self._compare_lists(_path_join(path, key), src, dst)

# To ensure we catch changes to JSON, we can't rely on a simple
# src == dst, or it would not recognize the difference between
# src == dst, because it would not recognize the difference between
# 1 and True, among other things. Using json.dumps is the most
# fool-proof way to ensure we catch type changes that matter to JSON
# and ignore those that don't. The performance of this could be
Expand Down

0 comments on commit 8fbed9b

Please sign in to comment.