Skip to main content

Object-specific undoing and redoing functionality through wrapper class

Project description

unredoable

Build codecov Python 3.6 PyPI MIT License

Download

pip install unredoable

Usage

from unredoable import Unredoable

class StateManager:
    def __init__(self, state_variable):
        """ 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 """
        
        self.unredoable_state_variable = Unredoable(state_variable, max_stack_depths=10, craft_deep_copies=False)
        
    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.3.tar.gz (3.6 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.3-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: unredoable-0.0.3.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.7.4 Linux/5.4.0-109-generic

File hashes

Hashes for unredoable-0.0.3.tar.gz
Algorithm Hash digest
SHA256 acce329747075dbbddf030805cb6f5ba287a758f64314e35f56aba21efb09ff3
MD5 219d9c56b70936fc934ccd483a907d71
BLAKE2b-256 c24b692092303f990b0f716cd9e21a28691188f38b84740df27a6ae3189a7a4f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: unredoable-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.7.4 Linux/5.4.0-109-generic

File hashes

Hashes for unredoable-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f90d58c62f94c260329e2727300518d877b9dd6a2bcd17c42b93c62a37a7985e
MD5 dc8e1fdb0af68ab7084c7b94a3803903
BLAKE2b-256 901b0fd24a8a636787bfb434c39fe75a559c20908026e167485c0bd09e268fa8

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