Skip to main content

Object-specific undoing and redoing functionality through wrapper class

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unredoable-0.0.4.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unredoable-0.0.4-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file unredoable-0.0.4.tar.gz.

File metadata

  • Download URL: unredoable-0.0.4.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.8.13 Linux/5.15.0-46-generic

File hashes

Hashes for unredoable-0.0.4.tar.gz
Algorithm Hash digest
SHA256 6ca365773a83d6acedfc06fd00a661f9eb39e1ae1fb3b227c1b6a2ced2e260a7
MD5 c94b2fca4a5b6d46a0b13d0e6e9a58cf
BLAKE2b-256 96ac71a0328049ff3aab473351e9d60812e1d30a9d11bfc5a41271db2848b94f

See more details on using hashes here.

File details

Details for the file unredoable-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: unredoable-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.8.13 Linux/5.15.0-46-generic

File hashes

Hashes for unredoable-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2ad93146d96e3e9a2cfc20fd2cc54c246b5fa8da11b147fca64dc7d4d8fd72e5
MD5 ae5028c4c94b2fa7767d2a0b32f1e3b5
BLAKE2b-256 c1642306caaa3638e579eb372566b4f6a3124360f1ad04f23272294e4d289fe7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page