You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

unredoable

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unredoable

Object-specific undoing and redoing functionality through wrapper class

0.0.5
pipPyPI
Maintainers
1

unredoable

Python package providing object-specific undoing & redoing functionality through wrapper class

Build codecov Python 3.6 PyPI MIT License

Download

pip install unredoable

Usage

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 = 71

Author

Janek Zangenberg

License

MIT

Keywords

state-management

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts