object-tracker
--------------
A pure python object state tracker. Monitor all changes in your object's lifecycle, query the history changelog, and trigger callback functions to capture them.
View the `Github repository <https://github.com/saurabh0719/object-tracker>`__ and the `official docs <https://github.com/saurabh0719/object-tracker#README>`__.
.. code:: sh
$ pip install object-tracker
Tested for python 3.6, 3.7 and above.
Key Features
------------
- Determine if a python object has changed state during it's lifecycle.
- Investigate change history by querying a structured changelog.
- Trigger callback functions whenever an (or any) attribute has changed.
- Use it as a decorator, a class mixin or on its own.
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 :
~~~~~~~~~~~~~
Use the `@track` decorator to track an object's attributes.
.. code:: python
from object_tracker import track
def observer(attr, old, new):
print(f"Observer : {attr} -> {old} - {new}")
@track('name', 'age', observers=[observer,])
class User:
def __init__(self, name, age):
self.name = name
self.age = age
user = User(name='Alice', age=30)
user.name = 'Bob'
# Observer : name -> Alice - Bob
print(user.tracker.has_changed())
# True
print(user.tracker.has_attribute_changed('name'))
# True
Or use the `Tracker` class
.. code:: python
class MyClass:
pass
obj = MyClass()
tracker = Tracker(obj)
obj.attribute = 'new_value'
print(tracker.has_changed(obj))
# True
Or use it with the mixin class `TrackerMixin`:
.. code:: python
from object_tracker import TrackerMixin, Tracker
class User(TrackerMixin):
def __init__(self, name, age):
self.name = name
self.age = age
self.tracker = Tracker()
Raw data
{
"_id": null,
"home_page": "https://github.com/saurabh0719/object-tracker",
"name": "object-tracker",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "object_tracker, object-tracker, changelog, object history, tracker, change tracker, history, state, state tracker",
"author": "Saurabh Pujari",
"author_email": "saurabhpuj99@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/3a/6c/55e5f7a3cc83216578b3893a13f9cb6d4154c8a234033d7762d346a69d11/object-tracker-2.0.0.tar.gz",
"platform": null,
"description": "object-tracker\n--------------\n\nA pure python object state tracker. Monitor all changes in your object's lifecycle, query the history changelog, and trigger callback functions to capture them.\n\nView the `Github repository <https://github.com/saurabh0719/object-tracker>`__ and the `official docs <https://github.com/saurabh0719/object-tracker#README>`__.\n\n.. code:: sh\n\n $ pip install object-tracker\n\nTested for python 3.6, 3.7 and above.\n\nKey Features\n------------\n\n- Determine if a python object has changed state during it's lifecycle.\n- Investigate change history by querying a structured changelog.\n- Trigger callback functions whenever an (or any) attribute has changed.\n- Use it as a decorator, a class mixin or on its own.\n\nLicense\n-------\n\n::\n\n Copyright (c) Saurabh Pujari\n All rights reserved.\n\n This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree.\n\n\nUsage :\n~~~~~~~~~~~~~\n\nUse the `@track` decorator to track an object's attributes.\n\n.. code:: python\n\n from object_tracker import track\n\n def observer(attr, old, new):\n print(f\"Observer : {attr} -> {old} - {new}\")\n\n @track('name', 'age', observers=[observer,])\n class User:\n def __init__(self, name, age):\n self.name = name\n self.age = age\n\n user = User(name='Alice', age=30)\n user.name = 'Bob'\n # Observer : name -> Alice - Bob\n print(user.tracker.has_changed()) \n # True\n print(user.tracker.has_attribute_changed('name'))\n # True\n\nOr use the `Tracker` class \n\n.. code:: python\n\n class MyClass:\n pass\n \n obj = MyClass()\n tracker = Tracker(obj)\n obj.attribute = 'new_value'\n print(tracker.has_changed(obj))\n # True\n\n\nOr use it with the mixin class `TrackerMixin`:\n\n\n.. code:: python\n\n from object_tracker import TrackerMixin, Tracker\n \n class User(TrackerMixin):\n def __init__(self, name, age):\n self.name = name\n self.age = age\n self.tracker = Tracker()\n",
"bugtrack_url": null,
"license": "three-clause BSD",
"summary": "A pure python object change and history tracker. Monitor all changes in your objects lifecycle and trigger callback functions to capture them.",
"version": "2.0.0",
"project_urls": {
"Documentation": "https://github.com/saurabh0719/object-tracker#README",
"Homepage": "https://github.com/saurabh0719/object-tracker",
"Source": "https://github.com/saurabh0719/object-tracker"
},
"split_keywords": [
"object_tracker",
" object-tracker",
" changelog",
" object history",
" tracker",
" change tracker",
" history",
" state",
" state tracker"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0d3371b54d414e904df31f72be3a16391f254deee0633488a22c24cec912099d",
"md5": "1f1095e91f84808754de1e0b3a857dfc",
"sha256": "409d5d6ea7bb8c363382d4391f6606e747d144499af3d2f9dcdd8daa82ffb906"
},
"downloads": -1,
"filename": "object_tracker-2.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1f1095e91f84808754de1e0b3a857dfc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 10335,
"upload_time": "2024-04-11T15:28:55",
"upload_time_iso_8601": "2024-04-11T15:28:55.479716Z",
"url": "https://files.pythonhosted.org/packages/0d/33/71b54d414e904df31f72be3a16391f254deee0633488a22c24cec912099d/object_tracker-2.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3a6c55e5f7a3cc83216578b3893a13f9cb6d4154c8a234033d7762d346a69d11",
"md5": "f4599418114747dcd0b5e06717a37ae1",
"sha256": "4c87c9ffddff9d2434f122446b9ca60c87f210d1c7e210043091ce3f97cc7f8f"
},
"downloads": -1,
"filename": "object-tracker-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "f4599418114747dcd0b5e06717a37ae1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9672,
"upload_time": "2024-04-11T15:28:58",
"upload_time_iso_8601": "2024-04-11T15:28:58.767553Z",
"url": "https://files.pythonhosted.org/packages/3a/6c/55e5f7a3cc83216578b3893a13f9cb6d4154c8a234033d7762d346a69d11/object-tracker-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-11 15:28:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "saurabh0719",
"github_project": "object-tracker",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "object-tracker"
}