Skip to content

Commit 9e4d423

Browse files
authored
Merge pull request #109 from vavanade/patch-1
Fixed some typos and wording
2 parents 91f6124 + 8fbed9b commit 9e4d423

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

jsonpatch.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ class InvalidJsonPatch(JsonPatchException):
7676

7777
class JsonPatchConflict(JsonPatchException):
7878
"""Raised if patch could not be applied due to conflict situation such as:
79-
- attempt to add object key then it already exists;
79+
- attempt to add object key when it already exists;
8080
- attempt to operate with nonexistence object key;
81-
- attempt to insert value to array at position beyond of it size;
81+
- attempt to insert value to array at position beyond its size;
8282
- etc.
8383
"""
8484

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

145145

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

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

295295
def apply(self, obj, in_place=False):
296-
"""Applies the patch to given object.
296+
"""Applies the patch to a given object.
297297
298298
:param obj: Document object.
299299
:type obj: dict
300300
301-
:param in_place: Tweaks way how patch would be applied - directly to
302-
specified `obj` or to his copy.
301+
:param in_place: Tweaks the way how patch would be applied - directly to
302+
specified `obj` or to its copy.
303303
:type in_place: bool
304304
305305
:return: Modified `obj`.
@@ -344,8 +344,8 @@ def __init__(self, operation):
344344
self.operation = operation
345345

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

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

390390
return obj
@@ -459,7 +459,7 @@ def _on_undo_add(self, path, key):
459459

460460

461461
class ReplaceOperation(PatchOperation):
462-
"""Replaces an object property or an array element by new value."""
462+
"""Replaces an object property or an array element by a new value."""
463463

464464
def apply(self, obj):
465465
try:
@@ -479,7 +479,7 @@ def apply(self, obj):
479479

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

499499

500500
class MoveOperation(PatchOperation):
501-
"""Moves an object property or an array element to new location."""
501+
"""Moves an object property or an array element to a new location."""
502502

503503
def apply(self, obj):
504504
try:
@@ -522,7 +522,7 @@ def apply(self, obj):
522522

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

527527
obj = RemoveOperation({
528528
'op': 'remove',
@@ -826,7 +826,7 @@ def _compare_values(self, path, key, src, dst):
826826
self._compare_lists(_path_join(path, key), src, dst)
827827

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

0 commit comments

Comments
 (0)