A pure python object change and history tracker. Monitor all changes in your objects lifecycle and trigger callback functions to capture them.
Project description
object-tracker
A pure python object change and history tracker. Monitor all changes in your objects lifecycle and trigger callback functions to capture them.
View the Github repository and the official docs.
$ pip install object-tracker
Tested for python 3.6, 3.7 and above.
Key Features
Determine if a python object has changed.
Investigate change history through the changelog.
Trigger callback functions whenever the object or an attribute has changed.
Simple and structured API.
Queryable change history log.
License
Copyright (c) Saurabh Pujari All rights reserved. This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree.
Usage :
from object_tracker import ObjectTracker
def observer(attr, old, new):
print(f"Observer : {attr} -> {old} - {new}")
class User(ObjectTracker):
def __init__(self, name) -> None:
ObjectTracker.__init__(self, observers=[observer,])
self.name = name
user = User("A")
print(user.tracker.changed())
# False
user.name = "B" # observers will be triggered
# Observer : name -> A - B
print(user.tracker.changed())
# True
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
object-tracker-1.0.0.tar.gz
(6.5 kB
view hashes)
Built Distribution
Close
Hashes for object_tracker-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb356e5f1c263d8d1395abee93d24523500058e47138e0a03e46c2cd8f08d9af |
|
MD5 | 7367fcecabf9f445b061560888527cb8 |
|
BLAKE2b-256 | 2bf151ef8e39ebc0bdb0c976030a2a328a7f633cd0f9625f14a0cfc59b380de7 |