Skip to content

Commit 2d9a565

Browse files
committed
Rename old{path,key} to from_{path,key}
1 parent 7387d20 commit 2d9a565

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

jsonpatch.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -540,28 +540,28 @@ def apply(self, obj):
540540
return obj
541541

542542
@property
543-
def oldpath(self):
544-
oldptr = JsonPointer(self.operation['from'])
545-
return '/'.join(oldptr.parts[:-1])
543+
def from_path(self):
544+
from_ptr = JsonPointer(self.operation['from'])
545+
return '/'.join(from_ptr.parts[:-1])
546546

547547
@property
548-
def oldkey(self):
549-
oldptr = JsonPointer(self.operation['from'])
548+
def from_key(self):
549+
from_ptr = JsonPointer(self.operation['from'])
550550
try:
551-
return int(oldptr.parts[-1])
551+
return int(from_ptr.parts[-1])
552552
except TypeError:
553-
return oldptr.parts[-1]
553+
return from_ptr.parts[-1]
554554

555-
@oldkey.setter
556-
def oldkey(self, value):
557-
oldptr = JsonPointer(self.operation['from'])
558-
oldptr.parts[-1] = str(value)
559-
self.operation['from'] = oldptr.path
555+
@from_key.setter
556+
def from_key(self, value):
557+
from_ptr = JsonPointer(self.operation['from'])
558+
from_ptr.parts[-1] = str(value)
559+
self.operation['from'] = from_ptr.path
560560

561561
def _on_undo_remove(self, path, key):
562-
if self.oldpath == path:
563-
if self.oldkey >= key:
564-
self.oldkey += 1
562+
if self.from_path == path:
563+
if self.from_key >= key:
564+
self.from_key += 1
565565
else:
566566
key -= 1
567567
if self.path == path:
@@ -572,9 +572,9 @@ def _on_undo_remove(self, path, key):
572572
return key
573573

574574
def _on_undo_add(self, path, key):
575-
if self.oldpath == path:
576-
if self.oldkey > key:
577-
self.oldkey -= 1
575+
if self.from_path == path:
576+
if self.from_key > key:
577+
self.from_key -= 1
578578
else:
579579
key -= 1
580580
if self.path == path:

0 commit comments

Comments
 (0)