unredoable
v.0.0.2
Python package providing object-specific undoing & redoing functionality through wrapper class
pip install unredoable
from unredoable import Unredoable
class StateManager:
def __init__(self, state_variable):
self.unredoable_state_variable = Unredoable(state_variable, max_stack_depths=10, craft_deep_copies=False)
# state_variable may be of whatever type, whether custom or not,
# the sole restraint it's subject to, is that is needs to implement
# either __copy__ or __deepcopy__, depending on the passed
# 'craft_deep_copies' parameter
def alter_state_variable(self):
self.unredoable_state_variable.push_state()
self.unredoable_state_variable.obj += 1
if __name__ == '__main__':
manager = StateManager(69)
manager.alter_state_variable()
manager.alter_state_variable()
manager.unredoable_state_variable.undo() # unredoable_state_variable = 70
manager.unredoable_state_variable.redo() # unredoable_state_variable = 71Janek Zangenberg
MIT