You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lexonomy_custom_editor/src/model/editable.py

28 lines
740 B

class Editable:
def make_copy(self):
# makes an internal copy of self
# delete old copy
if hasattr(self, "_copy"):
if self._copy is not None:
self._copy = None
# make new copy
self._copy = JSON.parse(JSON.stringify(self))
def copy(self):
# return internal copy of self
# check if even initialized
if hasattr(self, "_copy"):
return self._copy
else:
return None
def overwrite_with_copy(self):
for key, value in dict(self._copy).items():
if key == "_copy":
continue
setattr(self, key, value)
self._copy = None