A super simple history tracking class / mixin.
Project description
py_simple_history 0.0.1
A super basic python History Tracking object
About^
In this instance "History" means the state of an object at any given time. This module aims to provide a simple interface for tracking and moving through histories.
Installation^
Available on pip - pip install py_simple_history
Usage^
history_mixin^
Abstract mixin to add simple history-tracking to an object.
class history_mixin(object): def __init__(self, start_data): ... def add_history(self, data): """Add a history point. Clears any undone data history points.""" def clear_history(self, data=None): """Clears history. Sets a new history point, if no data specified uses the current data point.""" def redo(self): """Redoes history one step if possible.""" def undo(self): """Undoes history one step if possible."""
Example^
from py_simple_history import history_mixin class demo_object(history_mixin): def __init__(self, initial_data): history_mixin.__init__(self, initial_data) self.load(self.data:=initial_data) ... def on_update(self, new_data): self.add_history(new_data) self.load(data) def load(self, data): self.data = data def step_back(self): self.load(self.undo()) def step_forward(self): self.load(self.redo())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for py_simple_history-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46d27c15edfe7c8e4d9e55f928e97575783f80ded0d9708d74ec5b43ba324b9d |
|
MD5 | 9ed5fe711bda9811db4e7da43fc40d62 |
|
BLAKE2b-256 | a928523245be7ff6d605391975edcd69d33638e5a85db059239ad2ba111caf69 |