{ "info": { "author": "Victor Moura", "author_email": "victor_cmoura@hotmail.com", "bugtrack_url": null, "classifiers": [], "description": "# notifyr - *Create observers in runtime*\nPyPi: https://pypi.org/project/notifyr/\n\n## Description\n Notifyr is a package that enables simple class observed-observer schema at runtime. Instead of building the whole observation and notification toolchain, just use python decorators and notifyr will take care of the rest.\n\n Inspired by the Observer Design Pattern, notifyr adds the necessary methods to your classes without inheritance.\n\n## Decorators\nFunction decorators:\n- `@target`\n - Indicates that the decorated function is targeted and will trigger the observers `update()` everytime it runs.\n\nClass decorators:\n- `@observed`\n - Adds `.observers` list attribute.\n - Adds `.attach(obj)` method that appends `obj` to the observers list.\n - Adds `.notify()` method that notifies the observers everytime the targeted functions are called\n- `@observer('function_name')`\n - Adds `update()` method that executes class's `function_name()` passing, as arguments, `self` and everything that the targeted function received (including the `self` argument). \n\n## Usage\nOriginal Code:\n\n\n``` python\nclass Dog(object):\n def __init__(self, name):\n self.name = name\n\n def bark(self):\n print('Woof')\n\n def sleep(self):\n print(self.name, 'is now asleep: ZZzzzzZzzZ...')\n\nclass Person(object):\n def __init__(self, name):\n self.name = name\n\n def educate_dog(self, dog):\n print(self.name + ':','Sleep,', dog.name)\n dog.sleep()\n```\n\nSuppose we want a person to educate a dog every time the animal barks:\n\n``` python\nfrom notifyr.agents import observed, observer\nfrom notifyr.functions import target\n\n@observed\nclass Dog(object):\n def __init__(self, name):\n self.name = name\n\n @target\n def bark(self):\n print('Woof')\n\n def sleep(self):\n print(self.name, 'is now asleep: ZZzzzzZzzZ...')\n\n@observer('educate_dog')\nclass Person(object):\n def __init__(self, name):\n self.name = name\n\n def educate_dog(self, dog):\n print(self.name + ':','Sleep,', dog.name)\n dog.sleep()\n```\n\nAnd now, it is possible to archieve this by magically calling `bark()` after attaching a person to a dog:\n\n```python\nd = Dog('Tobby')\np = Person('Victor')\n\nd.attach(p) # Victor is now observing Tobby\n\nd.bark()\n# Woof\n# Victor: Sleep, Tobby\n# Tobby is now asleep: ZZzzzzZzzZ...\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/victorcmoura/notifyr", "keywords": "", "license": "GPL-3.0", "maintainer": "", "maintainer_email": "", "name": "notifyr", "package_url": "https://pypi.org/project/notifyr/", "platform": "", "project_url": "https://pypi.org/project/notifyr/", "project_urls": { "Homepage": "https://github.com/victorcmoura/notifyr" }, "release_url": "https://pypi.org/project/notifyr/1.1/", "requires_dist": null, "requires_python": "", "summary": "Object notification tool that implements observer design pattern at runtime", "version": "1.1" }, "last_serial": 4490373, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "d07d02aa9897cf8c3da41ad0bbb761f2", "sha256": "843b6ab80cbd12a7ec7cab332d4d010b4eb89ec7d775e508f27dafedee057b72" }, "downloads": -1, "filename": "notifyr-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "d07d02aa9897cf8c3da41ad0bbb761f2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14278, "upload_time": "2018-11-15T15:25:23", "url": "https://files.pythonhosted.org/packages/d8/bd/ecb39a8f175b4307888995f3af1f57882c3b3b8970e7eacb2838cb12ab5d/notifyr-1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "10f0fcb2260072264d27a6384444d161", "sha256": "ca3c5034674343099a343c20d933917552a17c4835f385219be7064f1cd47b34" }, "downloads": -1, "filename": "notifyr-1.0.tar.gz", "has_sig": false, "md5_digest": "10f0fcb2260072264d27a6384444d161", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1310, "upload_time": "2018-11-15T15:25:25", "url": "https://files.pythonhosted.org/packages/22/ff/8fa71646db625f5fc7a35c83404dc8a6457aacfaadf0d6838703d860fa17/notifyr-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "bf23c46d1b3cde4f78fd3983280e021a", "sha256": "4ab83ec7a42e3d7eef567c6a9997da8616cb04fc7c61cb7507fe57b1a338f9ce" }, "downloads": -1, "filename": "notifyr-1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "bf23c46d1b3cde4f78fd3983280e021a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15139, "upload_time": "2018-11-15T16:22:50", "url": "https://files.pythonhosted.org/packages/c0/2f/4f033d42529f502fbdf49a0d6e90c4e8dac5e708d0efcd49a48ed742579f/notifyr-1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "94ebc49e95e3ddce144d66bf26546fb3", "sha256": "5c189dfdca2976ebfe4f5e80903f8c7d7e7cbb397d0821ef0f550221f2c14e34" }, "downloads": -1, "filename": "notifyr-1.1.tar.gz", "has_sig": false, "md5_digest": "94ebc49e95e3ddce144d66bf26546fb3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2458, "upload_time": "2018-11-15T16:22:52", "url": "https://files.pythonhosted.org/packages/2c/26/45ec3a162795fddebd4463cd4ec4c92dcf0b1172bf1cc4eeba82e107563b/notifyr-1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bf23c46d1b3cde4f78fd3983280e021a", "sha256": "4ab83ec7a42e3d7eef567c6a9997da8616cb04fc7c61cb7507fe57b1a338f9ce" }, "downloads": -1, "filename": "notifyr-1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "bf23c46d1b3cde4f78fd3983280e021a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15139, "upload_time": "2018-11-15T16:22:50", "url": "https://files.pythonhosted.org/packages/c0/2f/4f033d42529f502fbdf49a0d6e90c4e8dac5e708d0efcd49a48ed742579f/notifyr-1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "94ebc49e95e3ddce144d66bf26546fb3", "sha256": "5c189dfdca2976ebfe4f5e80903f8c7d7e7cbb397d0821ef0f550221f2c14e34" }, "downloads": -1, "filename": "notifyr-1.1.tar.gz", "has_sig": false, "md5_digest": "94ebc49e95e3ddce144d66bf26546fb3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2458, "upload_time": "2018-11-15T16:22:52", "url": "https://files.pythonhosted.org/packages/2c/26/45ec3a162795fddebd4463cd4ec4c92dcf0b1172bf1cc4eeba82e107563b/notifyr-1.1.tar.gz" } ] }