{ "info": { "author": "Reuben Rusk", "author_email": "pythoro@mindquip.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# fastwire\n\nFastwire is a simple package to facilitate communication between objects. It\nprovides similar functionality to several other packages, such as:\n \n* blinker\n* wires\n* wired\n* observable\n* pyDispatcher\n* pymitter\n* py-notify\n* zope-event\n\nFastwire is intended to be elegant to use, fast to implement, and more\nflexible, while maintianing high performance.\n\n## Basic usage\n\nCreate a signal container:\n\n\n```python\n\nimport fastwire as fw\n\nsc = fw.SignalContainer()\n```\n\nThen create a signal...\n\n```python\nsignal = sc.signal('your_name')\n```\n\nWe can connect to that signal like this:\n\n```python\nclass A():\n def __init__(self):\n signal.connect(self.connected)\n\n def connected(self, a):\n print('Class A instance received a: ' + str(a))\n\na = B()\nsignal.connect(a.connected)\t\nsignal.emit(a=5.7)\n# Class A instance received a 5.7\n```\n\nAnd we can connect other signals if we want to:\n\n```python\nsignal_b = sc.signal('new_sig')\nsignal_b.connect(a.connected)\nsignal_b.emit(a=3)\n# Class A instance received a 5.7\n```\n\nConnecting also works with functions. We can connect a function to the same\nsignal.\n\n```python\ndef test_fun(a):\n print('test_fun got a ' + str(a))\n \nsignal.connect(test_fun)\nsignal.emit(a=5.7)\n# Class A instance received a 5.7\n# test_fun got a 5.7\n```\n\nOnly keyword arguments are accepted to ensure the required type of data is \npassed.\n\n\nThe emit method doesn't return anything. But the signal.fetch method does. It\nrequires there to be a single function or method that 'supplies' the return\nvalue. The signal.fetch_all method returns a list of return values from\nall receivers.\n\n## Signal properties\n\n### signal.n\nNumber of recievers.\n\n### signal.receivers_present\nTrue if receivers are present.\n\n### name\nThe name of the signal.\n\n## Decorators\n\nIt can be convenient to use decorators to automatically connect. Do do this,\nthe class needs to inherit fw.Wired.\n\n```python\nsignal_c = sc.signal('C')\n\nclass B(fw.Wired):\n\t@fw.receives(signal_c)\n\tdef connected(self, a):\n\t\tprint('Class B instance got ' + str(a))\n\nb = B()\nsignal_c.emit(a=7)\n# Class B instance got 7\n```\n\nFunctions need to use a different decorator.\n\n```python\n@fw.fn_receives(signal_c)\ndef test_fun_2(a):\n print('test_fun_2 got ' + str(a))\nsignal_c.emit(a=88)\n# Class B instance got 88\n# test_fun_2 got 88\n```\n\nUse the @fastwire.supply decorator for methods that supply data,\nand the @fastwire.fn_supply decorator for functions that supply data.\n\n\n## Conditions\n\nConditions can be added. They need to have a method called 'check', which is\npassed combined keyword arguments from the caller and receiver. It needs to\nreturn a boolean. If it's true, the given receiver gets the signal, if not,\nit doesn't. They also need a class attribute called 'name'.\n\nAdd a signal condition like this:\n\n```python\n\nclass My_Condition():\n name = 'default'\n def check(self, a, **kwargs):\n ''' The main check call - must return a boolean '''\n if a < 10:\n return True\n else:\n return False\n \nsignal.add_condition(My_Condition())\n```\n\nNow, receivers only get the signal when a is less than 10:\n\n```python\nsignal.emit(a=5.7)\n# Class A instance received a 5.7\n# test_fun got a 5.7\n\nsignal.emit(a=15)\n# Nothing happens\n```\n\nTo remove:\n\n```python\nsignal.remove_condition(My_Condition.name)\nsignal.emit(a=15)\n# Class A instance received a 15\n# test_fun got a 15\n```\n\nCondition classes are completely open - they can be as simple as the above\nexample or as complex as a state machine.\n\n## Muting\n\nNo receivers get a muted signal. You can mute and unmute a signal easily...\n\n```python\nsignal.mute()\nsignal.emit(a=3)\n# Nothing mappens\n\nsignal.unmute()\nsignal.emit(a=3)\n# Class A instance received a 3\n# test_fun got a 3\n```\n\n## Documentation\n\nDocumentation is hosted at ReadTheDocs.org.\n\nhttps://fastwire.readthedocs.io/en/latest/", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/pythoro/fastwire/archive/v0.1.5.zip", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/pythoro/fastwire.git", "keywords": "WIRE,CONNECTION,UTILITY", "license": "", "maintainer": "", "maintainer_email": "", "name": "fastwire", "package_url": "https://pypi.org/project/fastwire/", "platform": "", "project_url": "https://pypi.org/project/fastwire/", "project_urls": { "Download": "https://github.com/pythoro/fastwire/archive/v0.1.5.zip", "Homepage": "https://github.com/pythoro/fastwire.git" }, "release_url": "https://pypi.org/project/fastwire/0.1.5/", "requires_dist": null, "requires_python": "", "summary": "Easy data transfer between classes.", "version": "0.1.5" }, "last_serial": 5811270, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "b3e4a572fc1c209299b67fd7ec478f7e", "sha256": "380092ecc45ce29036ea4313b93e65f35e09c8e1b2fe1275470908ebcfbfa9eb" }, "downloads": -1, "filename": "fastwire-0.1.1.tar.gz", "has_sig": false, "md5_digest": "b3e4a572fc1c209299b67fd7ec478f7e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3814, "upload_time": "2019-07-22T01:09:12", "url": "https://files.pythonhosted.org/packages/4d/ad/246c7352f11a558d5dc9e255425367db7fbc67fa9edf9c535ac629e8c438/fastwire-0.1.1.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "b88ba632fbd97b467bb10a4d7401165f", "sha256": "7f209e904b0cd019caf461c12cc580b6f8cb2f6a530f0a975b10d91022ae72ec" }, "downloads": -1, "filename": "fastwire-0.1.3.tar.gz", "has_sig": false, "md5_digest": "b88ba632fbd97b467bb10a4d7401165f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5663, "upload_time": "2019-07-24T02:55:31", "url": "https://files.pythonhosted.org/packages/a6/49/acf1d3ade4bca7ebfeecc885bb75fd93bbfb2a593759ca29b400299d3989/fastwire-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "10eb31b3a6488d4d1f13c2e98c683e33", "sha256": "838a8a6b58af0eacf6d3ed9bd3faab7047ce2214bb2ae88c2a60fc6bfa0f0dad" }, "downloads": -1, "filename": "fastwire-0.1.4.tar.gz", "has_sig": false, "md5_digest": "10eb31b3a6488d4d1f13c2e98c683e33", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11899, "upload_time": "2019-09-02T06:26:48", "url": "https://files.pythonhosted.org/packages/c4/88/9fe9169b1468354303e4dc3f18a561846863dac01354a7b589c0291fd0c5/fastwire-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "c47f8e93065582efc6fef3efefe3205a", "sha256": "456720b413ba36a9583685361b9104c3a39cb51026d2fae697337ccf7b1c62c1" }, "downloads": -1, "filename": "fastwire-0.1.5.tar.gz", "has_sig": false, "md5_digest": "c47f8e93065582efc6fef3efefe3205a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11888, "upload_time": "2019-09-10T21:39:59", "url": "https://files.pythonhosted.org/packages/aa/1b/9686b4e1b5c37d8bf162aa87d56b48ed56eb312c0df197b13fe0f76ab330/fastwire-0.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c47f8e93065582efc6fef3efefe3205a", "sha256": "456720b413ba36a9583685361b9104c3a39cb51026d2fae697337ccf7b1c62c1" }, "downloads": -1, "filename": "fastwire-0.1.5.tar.gz", "has_sig": false, "md5_digest": "c47f8e93065582efc6fef3efefe3205a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11888, "upload_time": "2019-09-10T21:39:59", "url": "https://files.pythonhosted.org/packages/aa/1b/9686b4e1b5c37d8bf162aa87d56b48ed56eb312c0df197b13fe0f76ab330/fastwire-0.1.5.tar.gz" } ] }