@@ -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.
@@ -181,8 +181,8 @@ class JsonPatch(object):
181
181
>>> result == expected
182
182
True
183
183
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:
186
186
187
187
>>> lpatch = list(patch)
188
188
>>> expected = {'op': 'add', 'path': '/foo', 'value': 'bar'}
@@ -259,7 +259,7 @@ def from_string(cls, patch_str):
259
259
260
260
@classmethod
261
261
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
263
263
objects. Json patch would be created for `src` argument against `dst`
264
264
one.
265
265
@@ -293,13 +293,13 @@ def _ops(self):
293
293
return tuple (map (self ._get_operation , self .patch ))
294
294
295
295
def apply (self , obj , in_place = False ):
296
- """Applies the patch to given object.
296
+ """Applies the patch to a given object.
297
297
298
298
:param obj: Document object.
299
299
:type obj: dict
300
300
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.
303
303
:type in_place: bool
304
304
305
305
:return: Modified `obj`.
@@ -344,8 +344,8 @@ def __init__(self, operation):
344
344
self .operation = operation
345
345
346
346
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.' )
349
349
350
350
def __hash__ (self ):
351
351
return hash (frozenset (self .operation .items ()))
@@ -384,7 +384,7 @@ def apply(self, obj):
384
384
try :
385
385
del subobj [part ]
386
386
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 )
388
388
raise JsonPatchConflict (msg )
389
389
390
390
return obj
@@ -459,7 +459,7 @@ def _on_undo_add(self, path, key):
459
459
460
460
461
461
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."""
463
463
464
464
def apply (self , obj ):
465
465
try :
@@ -479,7 +479,7 @@ def apply(self, obj):
479
479
480
480
elif isinstance (subobj , MutableMapping ):
481
481
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 )
483
483
raise JsonPatchConflict (msg )
484
484
else :
485
485
if part is None :
@@ -498,7 +498,7 @@ def _on_undo_add(self, path, key):
498
498
499
499
500
500
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."""
502
502
503
503
def apply (self , obj ):
504
504
try :
@@ -522,7 +522,7 @@ def apply(self, obj):
522
522
523
523
if isinstance (subobj , MutableMapping ) and \
524
524
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' )
526
526
527
527
obj = RemoveOperation ({
528
528
'op' : 'remove' ,
@@ -826,7 +826,7 @@ def _compare_values(self, path, key, src, dst):
826
826
self ._compare_lists (_path_join (path , key ), src , dst )
827
827
828
828
# 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
830
830
# 1 and True, among other things. Using json.dumps is the most
831
831
# fool-proof way to ensure we catch type changes that matter to JSON
832
832
# and ignore those that don't. The performance of this could be
0 commit comments