@@ -76,9 +76,9 @@ class InvalidJsonPatch(JsonPatchException):
76
76
77
77
class JsonPatchConflict (JsonPatchException ):
78
78
"""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;
80
80
- 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;
82
82
- etc.
83
83
"""
84
84
@@ -144,7 +144,7 @@ def apply_patch(doc, patch, in_place=False):
144
144
145
145
146
146
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
148
148
a proxy to :meth:`JsonPatch.from_diff` method.
149
149
150
150
:param src: Data source document object.
@@ -184,8 +184,8 @@ class JsonPatch(object):
184
184
>>> result == expected
185
185
True
186
186
187
- JsonPatch object is iterable, so you could easily access to each patch
188
- statement in loop:
187
+ JsonPatch object is iterable, so you can easily access each patch
188
+ statement in a loop:
189
189
190
190
>>> lpatch = list(patch)
191
191
>>> expected = {'op': 'add', 'path': '/foo', 'value': 'bar'}
@@ -266,7 +266,7 @@ def from_string(cls, patch_str, loads=None):
266
266
267
267
@classmethod
268
268
def from_diff (cls , src , dst , optimization = True , dumps = None ):
269
- """Creates JsonPatch instance based on comparing of two document
269
+ """Creates JsonPatch instance based on comparison of two document
270
270
objects. Json patch would be created for `src` argument against `dst`
271
271
one.
272
272
@@ -305,13 +305,13 @@ def _ops(self):
305
305
return tuple (map (self ._get_operation , self .patch ))
306
306
307
307
def apply (self , obj , in_place = False ):
308
- """Applies the patch to given object.
308
+ """Applies the patch to a given object.
309
309
310
310
:param obj: Document object.
311
311
:type obj: dict
312
312
313
- :param in_place: Tweaks way how patch would be applied - directly to
314
- specified `obj` or to his copy.
313
+ :param in_place: Tweaks the way how patch would be applied - directly to
314
+ specified `obj` or to its copy.
315
315
:type in_place: bool
316
316
317
317
:return: Modified `obj`.
@@ -356,8 +356,8 @@ def __init__(self, operation):
356
356
self .operation = operation
357
357
358
358
def apply (self , obj ):
359
- """Abstract method that applies patch operation to specified object."""
360
- raise NotImplementedError ('should implement patch operation.' )
359
+ """Abstract method that applies a patch operation to the specified object."""
360
+ raise NotImplementedError ('should implement the patch operation.' )
361
361
362
362
def __hash__ (self ):
363
363
return hash (frozenset (self .operation .items ()))
@@ -396,7 +396,7 @@ def apply(self, obj):
396
396
try :
397
397
del subobj [part ]
398
398
except (KeyError , IndexError ) as ex :
399
- msg = "can't remove non-existent object '{0}'" .format (part )
399
+ msg = "can't remove a non-existent object '{0}'" .format (part )
400
400
raise JsonPatchConflict (msg )
401
401
402
402
return obj
@@ -471,7 +471,7 @@ def _on_undo_add(self, path, key):
471
471
472
472
473
473
class ReplaceOperation (PatchOperation ):
474
- """Replaces an object property or an array element by new value."""
474
+ """Replaces an object property or an array element by a new value."""
475
475
476
476
def apply (self , obj ):
477
477
try :
@@ -491,7 +491,7 @@ def apply(self, obj):
491
491
492
492
elif isinstance (subobj , MutableMapping ):
493
493
if part not in subobj :
494
- msg = "can't replace non-existent object '{0}'" .format (part )
494
+ msg = "can't replace a non-existent object '{0}'" .format (part )
495
495
raise JsonPatchConflict (msg )
496
496
else :
497
497
if part is None :
@@ -510,7 +510,7 @@ def _on_undo_add(self, path, key):
510
510
511
511
512
512
class MoveOperation (PatchOperation ):
513
- """Moves an object property or an array element to new location."""
513
+ """Moves an object property or an array element to a new location."""
514
514
515
515
def apply (self , obj ):
516
516
try :
@@ -534,7 +534,7 @@ def apply(self, obj):
534
534
535
535
if isinstance (subobj , MutableMapping ) and \
536
536
self .pointer .contains (from_ptr ):
537
- raise JsonPatchConflict ('Cannot move values into its own children' )
537
+ raise JsonPatchConflict ('Cannot move values into their own children' )
538
538
539
539
obj = RemoveOperation ({
540
540
'op' : 'remove' ,
@@ -839,7 +839,7 @@ def _compare_values(self, path, key, src, dst):
839
839
self ._compare_lists (_path_join (path , key ), src , dst )
840
840
841
841
# To ensure we catch changes to JSON, we can't rely on a simple
842
- # src == dst, or it would not recognize the difference between
842
+ # src == dst, because it would not recognize the difference between
843
843
# 1 and True, among other things. Using json.dumps is the most
844
844
# fool-proof way to ensure we catch type changes that matter to JSON
845
845
# and ignore those that don't. The performance of this could be
0 commit comments