summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvavanade <vavanade@users.noreply.github.com>2020-02-27 17:08:47 +0100
committerGitHub <noreply@github.com>2020-02-27 17:08:47 +0100
commit8fbed9b38648f922bbbdb6984d0fd87b7227b149 (patch)
tree1cd87722b6d30990e9f3628d4f44258ef4f91434
parent91f61241adc9d104e1811eeaf4d9dc6518d6786e (diff)
downloadpython-json-patch-8fbed9b38648f922bbbdb6984d0fd87b7227b149.tar.gz
Fixed some typos and wording
-rw-r--r--jsonpatch.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/jsonpatch.py b/jsonpatch.py
index 7f31ce5..ca22e34 100644
--- a/jsonpatch.py
+++ b/jsonpatch.py
@@ -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.
"""
@@ -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.
@@ -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'}
@@ -259,7 +259,7 @@ class JsonPatch(object):
@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.
@@ -293,13 +293,13 @@ class JsonPatch(object):
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`.
@@ -344,8 +344,8 @@ class PatchOperation(object):
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()))
@@ -384,7 +384,7 @@ class RemoveOperation(PatchOperation):
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
@@ -459,7 +459,7 @@ class AddOperation(PatchOperation):
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:
@@ -479,7 +479,7 @@ class ReplaceOperation(PatchOperation):
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:
@@ -498,7 +498,7 @@ class ReplaceOperation(PatchOperation):
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:
@@ -522,7 +522,7 @@ class MoveOperation(PatchOperation):
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',
@@ -826,7 +826,7 @@ class DiffBuilder(object):
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