python-dispatch 0.2.2__tar.gz → 0.2.41__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {python-dispatch-0.2.2/python_dispatch.egg-info → python_dispatch-0.2.41}/PKG-INFO +21 -25
  2. {python-dispatch-0.2.2 → python_dispatch-0.2.41}/README.md +7 -7
  3. {python-dispatch-0.2.2 → python_dispatch-0.2.41}/pydispatch/aioutils.py +21 -3
  4. {python-dispatch-0.2.2 → python_dispatch-0.2.41}/pydispatch/decorators.py +8 -9
  5. {python-dispatch-0.2.2 → python_dispatch-0.2.41}/pydispatch/dispatch.py +10 -8
  6. {python-dispatch-0.2.2 → python_dispatch-0.2.41}/pydispatch/properties.py +6 -2
  7. {python-dispatch-0.2.2 → python_dispatch-0.2.41}/pydispatch/utils.py +10 -3
  8. python_dispatch-0.2.41/pyproject.toml +86 -0
  9. python_dispatch-0.2.41/pyproject.toml.orig +81 -0
  10. python-dispatch-0.2.2/LICENSE.txt +0 -21
  11. python-dispatch-0.2.2/MANIFEST.in +0 -2
  12. python-dispatch-0.2.2/PKG-INFO +0 -157
  13. python-dispatch-0.2.2/python_dispatch.egg-info/SOURCES.txt +0 -22
  14. python-dispatch-0.2.2/python_dispatch.egg-info/dependency_links.txt +0 -1
  15. python-dispatch-0.2.2/python_dispatch.egg-info/top_level.txt +0 -1
  16. python-dispatch-0.2.2/setup.cfg +0 -56
  17. python-dispatch-0.2.2/setup.py +0 -4
  18. python-dispatch-0.2.2/tests/test_aio_listeners.py +0 -433
  19. python-dispatch-0.2.2/tests/test_aio_lock.py +0 -322
  20. python-dispatch-0.2.2/tests/test_events.py +0 -231
  21. python-dispatch-0.2.2/tests/test_global_dispatcher.py +0 -151
  22. python-dispatch-0.2.2/tests/test_properties.py +0 -436
  23. python-dispatch-0.2.2/tests/test_subclass_init.py +0 -98
  24. python-dispatch-0.2.2/tests/test_version_attribute.py +0 -18
  25. {python-dispatch-0.2.2 → python_dispatch-0.2.41}/pydispatch/__init__.py +0 -0
@@ -1,42 +1,38 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: python-dispatch
3
- Version: 0.2.2
4
- Summary: Lightweight Event Handling
5
- Home-page: https://github.com/nocarryr/python-dispatch
3
+ Version: 0.2.41
4
+ Summary: Lightweight Event Handling Library for Python
5
+ Keywords: event,properties,dispatch
6
6
  Author: Matthew Reid
7
- Author-email: matt@nomadic-recording.com
8
- License: MIT
9
- Project-URL: Documentation, https://python-dispatch.readthedocs.io
10
- Project-URL: Source, https://github.com/nocarryr/python-dispatch
11
- Project-URL: Tracker, https://github.com/nocarryr/python-dispatch/issues
12
- Keywords: event properties dispatch
13
- Platform: any
7
+ Author-email: Matthew Reid <matt@nomadic-recording.com>
8
+ License-Expression: MIT
14
9
  Classifier: Development Status :: 3 - Alpha
15
10
  Classifier: Intended Audience :: Developers
16
- Classifier: License :: OSI Approved :: MIT License
17
11
  Classifier: Operating System :: OS Independent
18
12
  Classifier: Programming Language :: Python
19
13
  Classifier: Topic :: Software Development
20
14
  Classifier: Programming Language :: Python :: 3
21
- Classifier: Programming Language :: Python :: 3.6
22
- Classifier: Programming Language :: Python :: 3.7
23
- Classifier: Programming Language :: Python :: 3.8
24
- Classifier: Programming Language :: Python :: 3.9
25
- Classifier: Programming Language :: Python :: 3.10
26
15
  Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
27
19
  Classifier: Topic :: Software Development :: Libraries
28
20
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.11
22
+ Project-URL: Documentation, https://python-dispatch.readthedocs.io/
23
+ Project-URL: Source, https://github.com/nocarryr/python-dispatch
24
+ Project-URL: Download, https://pypi.org/project/python-dispatch/
25
+ Project-URL: Tracker, https://github.com/nocarryr/python-dispatch/issues
29
26
  Description-Content-Type: text/markdown
30
- License-File: LICENSE.txt
31
27
 
32
28
  # python-dispatch
33
29
  Lightweight event handling for Python
34
30
 
35
- [![Build Status](https://travis-ci.org/nocarryr/python-dispatch.svg?branch=master)](https://travis-ci.org/nocarryr/python-dispatch)[![Coverage Status](https://coveralls.io/repos/github/nocarryr/python-dispatch/badge.svg?branch=master)](https://coveralls.io/github/nocarryr/python-dispatch?branch=master)[![PyPI version](https://badge.fury.io/py/python-dispatch.svg)](https://badge.fury.io/py/python-dispatch)[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nocarryr/python-dispatch/master/LICENSE.txt)
31
+ [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/nocarryr/python-dispatch/ci.yml)[![Coverage Status](https://coveralls.io/repos/github/nocarryr/python-dispatch/badge.svg?branch=master)](https://coveralls.io/github/nocarryr/python-dispatch?branch=master)[![PyPI version](https://badge.fury.io/py/python-dispatch.svg)](https://badge.fury.io/py/python-dispatch)[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nocarryr/python-dispatch/master/LICENSE.txt)
36
32
 
37
33
  ## Description
38
34
  This is an implementation of the "Observer Pattern" with inspiration from the
39
- [Kivy](kivy.org) framework. Many of the features though are intentionally
35
+ [Kivy](https://kivy.org) framework. Many of the features though are intentionally
40
36
  stripped down and more generalized. The goal is to have a simple drop-in
41
37
  library with no dependencies that stays out of the programmer's way.
42
38
 
@@ -68,9 +64,9 @@ pip install python-dispatch<0.2
68
64
 
69
65
  | | |
70
66
  | -------------:|:-------------------------------------------- |
71
- | Project Home | https://github.com/nocarryr/python-dispatch |
72
- | PyPI | https://pypi.python.org/pypi/python-dispatch |
73
- | Documentation | https://python-dispatch.readthedocs.io |
67
+ | Project Home | [https://github.com/nocarryr/python-dispatch](https://github.com/nocarryr/python-dispatch) |
68
+ | PyPI | [https://pypi.python.org/pypi/python-dispatch](https://pypi.python.org/pypi/python-dispatch) |
69
+ | Documentation | [https://python-dispatch.readthedocs.io](https://python-dispatch.readthedocs.io) |
74
70
 
75
71
 
76
72
  ## Usage
@@ -149,9 +145,9 @@ emitter value is 42
149
145
  Contributions are welcome!
150
146
 
151
147
  If you want to contribute through code or documentation, please see the
152
- [Contributing Guide](CONTRIBUTING.md) for information.
148
+ [Contributing Guide](https://github.com/nocarryr/python-dispatch/blob/master/CONTRIBUTING.md) for information.
153
149
 
154
150
  ## License
155
151
 
156
- This project is released under the MIT License. See the [LICENSE](LICENSE.txt) file
152
+ This project is released under the MIT License. See the [LICENSE](https://github.com/nocarryr/python-dispatch/blob/master/LICENSE.txt) file
157
153
  for more information.
@@ -1,11 +1,11 @@
1
1
  # python-dispatch
2
2
  Lightweight event handling for Python
3
3
 
4
- [![Build Status](https://travis-ci.org/nocarryr/python-dispatch.svg?branch=master)](https://travis-ci.org/nocarryr/python-dispatch)[![Coverage Status](https://coveralls.io/repos/github/nocarryr/python-dispatch/badge.svg?branch=master)](https://coveralls.io/github/nocarryr/python-dispatch?branch=master)[![PyPI version](https://badge.fury.io/py/python-dispatch.svg)](https://badge.fury.io/py/python-dispatch)[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nocarryr/python-dispatch/master/LICENSE.txt)
4
+ [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/nocarryr/python-dispatch/ci.yml)[![Coverage Status](https://coveralls.io/repos/github/nocarryr/python-dispatch/badge.svg?branch=master)](https://coveralls.io/github/nocarryr/python-dispatch?branch=master)[![PyPI version](https://badge.fury.io/py/python-dispatch.svg)](https://badge.fury.io/py/python-dispatch)[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nocarryr/python-dispatch/master/LICENSE.txt)
5
5
 
6
6
  ## Description
7
7
  This is an implementation of the "Observer Pattern" with inspiration from the
8
- [Kivy](kivy.org) framework. Many of the features though are intentionally
8
+ [Kivy](https://kivy.org) framework. Many of the features though are intentionally
9
9
  stripped down and more generalized. The goal is to have a simple drop-in
10
10
  library with no dependencies that stays out of the programmer's way.
11
11
 
@@ -37,9 +37,9 @@ pip install python-dispatch<0.2
37
37
 
38
38
  | | |
39
39
  | -------------:|:-------------------------------------------- |
40
- | Project Home | https://github.com/nocarryr/python-dispatch |
41
- | PyPI | https://pypi.python.org/pypi/python-dispatch |
42
- | Documentation | https://python-dispatch.readthedocs.io |
40
+ | Project Home | [https://github.com/nocarryr/python-dispatch](https://github.com/nocarryr/python-dispatch) |
41
+ | PyPI | [https://pypi.python.org/pypi/python-dispatch](https://pypi.python.org/pypi/python-dispatch) |
42
+ | Documentation | [https://python-dispatch.readthedocs.io](https://python-dispatch.readthedocs.io) |
43
43
 
44
44
 
45
45
  ## Usage
@@ -118,9 +118,9 @@ emitter value is 42
118
118
  Contributions are welcome!
119
119
 
120
120
  If you want to contribute through code or documentation, please see the
121
- [Contributing Guide](CONTRIBUTING.md) for information.
121
+ [Contributing Guide](https://github.com/nocarryr/python-dispatch/blob/master/CONTRIBUTING.md) for information.
122
122
 
123
123
  ## License
124
124
 
125
- This project is released under the MIT License. See the [LICENSE](LICENSE.txt) file
125
+ This project is released under the MIT License. See the [LICENSE](https://github.com/nocarryr/python-dispatch/blob/master/LICENSE.txt) file
126
126
  for more information.
@@ -1,13 +1,25 @@
1
+ import sys
1
2
  import asyncio
2
3
  import threading
3
- from _weakref import ref
4
- from _weakrefset import _IterationGuard
4
+ from weakref import ref
5
+ from _weakref import _remove_dead_weakref # type: ignore[import]
6
+ if sys.version_info < (3, 14):
7
+ from _weakrefset import _IterationGuard
8
+ else:
9
+ # _IterationGuard was removed in Python 3.14. We define a no-op version here
10
+ class _IterationGuard:
11
+ def __init__(self, obj):
12
+ pass
13
+ def __enter__(self):
14
+ pass
15
+ def __exit__(self, *args):
16
+ pass
17
+
5
18
 
6
19
  from pydispatch.utils import (
7
20
  WeakMethodContainer,
8
21
  isfunction,
9
22
  get_method_vars,
10
- _remove_dead_weakref,
11
23
  )
12
24
 
13
25
 
@@ -192,6 +204,12 @@ class AioWeakMethodContainer(WeakMethodContainer):
192
204
  _remove_dead_weakref(self.data, wr.key)
193
205
  self._on_weakref_fin(wr.key)
194
206
  self._remove = remove
207
+
208
+ # `_pending_removals` and `_iterating` were removed in Python 3.14.
209
+ # To maintain compatibility with earlier versions, we reintroduce them here.
210
+ self._pending_removals = []
211
+ self._iterating = set()
212
+
195
213
  self.event_loop_map = {}
196
214
  def add_method(self, loop, callback):
197
215
  """Add a coroutine function
@@ -124,12 +124,11 @@ def _post_register_hook(*names):
124
124
  """Called in :func:`pydispatch.register_event` to search for cached callbacks
125
125
  """
126
126
  for name in names:
127
- if name not in _CACHED_CALLBACKS:
128
- continue
129
- bind_kwargs = {name:cb for cb in _CACHED_CALLBACKS.get(name)}
130
- is_async = any((iscoroutinefunction(cb) for cb in bind_kwargs.values()))
131
- if is_async:
132
- loop = asyncio.get_event_loop()
133
- pydispatch.bind_async(loop, **bind_kwargs)
134
- else:
135
- pydispatch.bind(**bind_kwargs)
127
+ loop = None
128
+ for callback in _CACHED_CALLBACKS.get(name):
129
+ if iscoroutinefunction(callback):
130
+ if loop is None:
131
+ loop = asyncio.get_event_loop()
132
+ pydispatch.bind_async(loop, **{name: callback})
133
+ else:
134
+ pydispatch.bind(**{name: callback})
@@ -209,14 +209,16 @@ class Dispatcher(object):
209
209
  ... async def on_foo_test_event(self, *args, **kwargs):
210
210
  ... self.got_foo_event.set()
211
211
 
212
- >>> loop = asyncio.get_event_loop()
213
- >>> foo = Foo()
214
- >>> bar = Bar()
215
- >>> foo.bind(test_event=bar.on_foo_test_event, __aio_loop__=loop)
216
- >>> fut = asyncio.ensure_future(bar.wait_for_foo())
217
-
218
- >>> foo.emit('test_event')
219
- >>> loop.run_until_complete(fut)
212
+ >>> async def main():
213
+ ... loop = asyncio.get_running_loop()
214
+ ... foo = Foo()
215
+ ... bar = Bar()
216
+ ... foo.bind(test_event=bar.on_foo_test_event, __aio_loop__=loop)
217
+ ... fut = asyncio.create_task(bar.wait_for_foo())
218
+ ... foo.emit('test_event')
219
+ ... await fut
220
+
221
+ >>> asyncio.run(main())
220
222
  got foo!
221
223
 
222
224
  This can also be done using :meth:`bind_async`.
@@ -331,10 +331,14 @@ class ObservableDict(dict, Observable):
331
331
  super(ObservableDict, self).clear()
332
332
  self._emit_change(old=old)
333
333
  def pop(self, *args):
334
+ """Return the removed value or default after emitting a change event."""
334
335
  old = self._get_copy_or_none()
335
- super(ObservableDict, self).pop(*args)
336
+ value = super(ObservableDict, self).pop(*args)
336
337
  self._emit_change(old=old)
338
+ return value
337
339
  def setdefault(self, *args):
340
+ """Return the existing or inserted value and notify on successful calls."""
338
341
  old = self._get_copy_or_none()
339
- super(ObservableDict, self).setdefault(*args)
342
+ value = super(ObservableDict, self).setdefault(*args)
340
343
  self._emit_change(old=old)
344
+ return value
@@ -1,8 +1,9 @@
1
1
  import weakref
2
- from weakref import ref, _remove_dead_weakref
3
- from _weakref import ref
2
+ from weakref import ref
3
+ from _weakref import _remove_dead_weakref # type: ignore[import]
4
4
  import types
5
5
  import asyncio
6
+ import inspect
6
7
 
7
8
  def get_method_vars(m):
8
9
  f = m.__func__
@@ -13,7 +14,7 @@ def isfunction(m):
13
14
  return isinstance(m, types.FunctionType)
14
15
 
15
16
  def iscoroutinefunction(obj):
16
- return asyncio.iscoroutinefunction(obj)
17
+ return inspect.iscoroutinefunction(obj)
17
18
 
18
19
  class WeakMethodContainer(weakref.WeakValueDictionary):
19
20
  """Container to store weak references to callbacks
@@ -114,6 +115,12 @@ class InformativeWVDict(weakref.WeakValueDictionary):
114
115
  _remove_dead_weakref(self.data, wr.key)
115
116
  self._data_del_callback(wr.key)
116
117
  self._remove = remove
118
+
119
+ # `_pending_removals` and `_iterating` were removed in Python 3.14.
120
+ # To maintain compatibility with earlier versions, we reintroduce them here.
121
+ self._pending_removals = []
122
+ self._iterating = set()
123
+
117
124
  self.data = InformativeDict()
118
125
  self.data.del_callback = self._data_del_callback
119
126
  def _data_del_callback(self, key):
@@ -0,0 +1,86 @@
1
+ [project]
2
+ name = "python-dispatch"
3
+ version = "0.2.41"
4
+ description = "Lightweight Event Handling Library for Python"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ keywords = [
8
+ "event",
9
+ "properties",
10
+ "dispatch",
11
+ ]
12
+ requires-python = ">=3.11"
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Intended Audience :: Developers",
16
+ "Operating System :: OS Independent",
17
+ "Programming Language :: Python",
18
+ "Topic :: Software Development",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Programming Language :: Python :: 3.14",
24
+ "Topic :: Software Development :: Libraries",
25
+ "Topic :: Software Development :: Libraries :: Python Modules",
26
+ ]
27
+
28
+ [[project.authors]]
29
+ name = "Matthew Reid"
30
+ email = "matt@nomadic-recording.com"
31
+
32
+ [project.urls]
33
+ Documentation = "https://python-dispatch.readthedocs.io/"
34
+ Source = "https://github.com/nocarryr/python-dispatch"
35
+ Download = "https://pypi.org/project/python-dispatch/"
36
+ Tracker = "https://github.com/nocarryr/python-dispatch/issues"
37
+
38
+ [build-system]
39
+ requires = ["uv_build>=0.13.0,<0.14.0"]
40
+ build-backend = "uv_build"
41
+
42
+ [tool.uv.build-backend]
43
+ module-root = ""
44
+ module-name = "pydispatch"
45
+
46
+ [tool.uv.sources.python-dispatch]
47
+ workspace = true
48
+
49
+ [tool.uv.sources.python-dispatch-sphinx]
50
+ workspace = true
51
+
52
+ [tool.uv.workspace]
53
+ members = ["sphinx-plugin"]
54
+
55
+ [tool.pytest.ini_options]
56
+ testpaths = [
57
+ "tests",
58
+ "doc",
59
+ "pydispatch",
60
+ ]
61
+ addopts = "--doctest-modules --doctest-glob='*.rst' --doctest-glob='*.md'"
62
+ doctest_plus = "enabled"
63
+ asyncio_mode = "auto"
64
+
65
+ [dependency-groups]
66
+ doc = [
67
+ "docutils>=0.17",
68
+ "furo>=2024.8.6",
69
+ "myst-parser>=4.0.0",
70
+ "sphinx>=8.2,<9",
71
+ "sphinx-design>=0.6.1",
72
+ "sphinxcontrib-restbuilder>=0.3",
73
+ "sphinx-rtd-theme>=1.3.0",
74
+ ]
75
+ test = [
76
+ { include-group = "doc" },
77
+ "coveralls>=3.3.1",
78
+ "pytest>=7.0.1",
79
+ "pytest-asyncio>=0.16.0",
80
+ "pytest-cov>=4.0.0",
81
+ "pytest-doctestplus>=0.9.0",
82
+ ]
83
+ dev = [
84
+ { include-group = "test" },
85
+ "python-dispatch-sphinx",
86
+ ]
@@ -0,0 +1,81 @@
1
+
2
+ [project]
3
+ name = "python-dispatch"
4
+ version = "0.2.41"
5
+ description = "Lightweight Event Handling Library for Python"
6
+ authors = [
7
+ { name = "Matthew Reid", email = "matt@nomadic-recording.com" }
8
+ ]
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ keywords = ["event", "properties", "dispatch"]
12
+ requires-python = ">=3.11"
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Intended Audience :: Developers",
16
+ "Operating System :: OS Independent",
17
+ "Programming Language :: Python",
18
+ "Topic :: Software Development",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Programming Language :: Python :: 3.14",
24
+ "Topic :: Software Development :: Libraries",
25
+ "Topic :: Software Development :: Libraries :: Python Modules"
26
+ ]
27
+ [project.urls]
28
+ Documentation = "https://python-dispatch.readthedocs.io/"
29
+ Source = "https://github.com/nocarryr/python-dispatch"
30
+ Download = "https://pypi.org/project/python-dispatch/"
31
+ Tracker = "https://github.com/nocarryr/python-dispatch/issues"
32
+
33
+
34
+ [build-system]
35
+ requires = ["uv_build>=0.13.0,<0.14.0"]
36
+ build-backend = "uv_build"
37
+
38
+ [tool.uv.build-backend]
39
+ module-root = ""
40
+ module-name = "pydispatch"
41
+
42
+ [tool.uv.sources]
43
+ python-dispatch = { workspace = true }
44
+ python-dispatch-sphinx = { workspace = true }
45
+
46
+ [tool.uv.workspace]
47
+ members = [
48
+ "sphinx-plugin",
49
+ ]
50
+
51
+
52
+ [tool.pytest.ini_options]
53
+ testpaths = ["tests", "doc", "pydispatch"]
54
+ addopts = "--doctest-modules --doctest-glob='*.rst' --doctest-glob='*.md'"
55
+ doctest_plus = "enabled"
56
+ asyncio_mode = "auto"
57
+
58
+
59
+ [dependency-groups]
60
+ doc = [
61
+ "docutils>=0.17",
62
+ "furo>=2024.8.6",
63
+ "myst-parser>=4.0.0",
64
+ "sphinx>=8.2,<9",
65
+ "sphinx-design>=0.6.1",
66
+ "sphinxcontrib-restbuilder>=0.3",
67
+ "sphinx-rtd-theme>=1.3.0",
68
+ ]
69
+ test = [
70
+ {include-group = "doc"},
71
+ "coveralls>=3.3.1",
72
+ "pytest>=7.0.1",
73
+ "pytest-asyncio>=0.16.0",
74
+ "pytest-cov>=4.0.0",
75
+ "pytest-doctestplus>=0.9.0",
76
+ ]
77
+
78
+ dev = [
79
+ {include-group = "test"},
80
+ "python-dispatch-sphinx",
81
+ ]
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2016 Matthew Reid
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,2 +0,0 @@
1
- include LICENSE*
2
- include README*
@@ -1,157 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: python-dispatch
3
- Version: 0.2.2
4
- Summary: Lightweight Event Handling
5
- Home-page: https://github.com/nocarryr/python-dispatch
6
- Author: Matthew Reid
7
- Author-email: matt@nomadic-recording.com
8
- License: MIT
9
- Project-URL: Documentation, https://python-dispatch.readthedocs.io
10
- Project-URL: Source, https://github.com/nocarryr/python-dispatch
11
- Project-URL: Tracker, https://github.com/nocarryr/python-dispatch/issues
12
- Keywords: event properties dispatch
13
- Platform: any
14
- Classifier: Development Status :: 3 - Alpha
15
- Classifier: Intended Audience :: Developers
16
- Classifier: License :: OSI Approved :: MIT License
17
- Classifier: Operating System :: OS Independent
18
- Classifier: Programming Language :: Python
19
- Classifier: Topic :: Software Development
20
- Classifier: Programming Language :: Python :: 3
21
- Classifier: Programming Language :: Python :: 3.6
22
- Classifier: Programming Language :: Python :: 3.7
23
- Classifier: Programming Language :: Python :: 3.8
24
- Classifier: Programming Language :: Python :: 3.9
25
- Classifier: Programming Language :: Python :: 3.10
26
- Classifier: Programming Language :: Python :: 3.11
27
- Classifier: Topic :: Software Development :: Libraries
28
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
29
- Description-Content-Type: text/markdown
30
- License-File: LICENSE.txt
31
-
32
- # python-dispatch
33
- Lightweight event handling for Python
34
-
35
- [![Build Status](https://travis-ci.org/nocarryr/python-dispatch.svg?branch=master)](https://travis-ci.org/nocarryr/python-dispatch)[![Coverage Status](https://coveralls.io/repos/github/nocarryr/python-dispatch/badge.svg?branch=master)](https://coveralls.io/github/nocarryr/python-dispatch?branch=master)[![PyPI version](https://badge.fury.io/py/python-dispatch.svg)](https://badge.fury.io/py/python-dispatch)[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nocarryr/python-dispatch/master/LICENSE.txt)
36
-
37
- ## Description
38
- This is an implementation of the "Observer Pattern" with inspiration from the
39
- [Kivy](kivy.org) framework. Many of the features though are intentionally
40
- stripped down and more generalized. The goal is to have a simple drop-in
41
- library with no dependencies that stays out of the programmer's way.
42
-
43
- ## Installation
44
- "python-dispatch" is available on [PyPI](https://pypi.org/project/python-dispatch/)
45
- and can be installed using pip:
46
-
47
- ```bash
48
- pip install python-dispatch
49
- ```
50
-
51
- ### Python Requirements
52
- After version `0.1` of this project, only Python 3.6 and above will be supported.
53
- If using an older Python version, the older releases should still be available
54
- on PyPI and the correct package should be chosen automatically by `pip`.
55
- If not, either upgrade `pip` and `setuptools`:
56
-
57
- ```bash
58
- pip install -U pip setuptools
59
- ```
60
-
61
- Or specify the version manually:
62
-
63
- ```bash
64
- pip install python-dispatch<0.2
65
- ```
66
-
67
- ## Links
68
-
69
- | | |
70
- | -------------:|:-------------------------------------------- |
71
- | Project Home | https://github.com/nocarryr/python-dispatch |
72
- | PyPI | https://pypi.python.org/pypi/python-dispatch |
73
- | Documentation | https://python-dispatch.readthedocs.io |
74
-
75
-
76
- ## Usage
77
-
78
- ### Events
79
-
80
- ```python
81
- >>> from pydispatch import Dispatcher
82
-
83
- >>> class MyEmitter(Dispatcher):
84
- ... # Events are defined in classes and subclasses with the '_events_' attribute
85
- ... _events_ = ['on_state', 'new_data']
86
- ... def do_some_stuff(self):
87
- ... # do stuff that makes new data
88
- ... data = {'foo':'bar'}
89
- ... # Then emit the change with optional positional and keyword arguments
90
- ... self.emit('new_data', data=data)
91
-
92
- >>> # An observer - could inherit from Dispatcher or any other class
93
- >>> class MyListener(object):
94
- ... def on_new_data(self, *args, **kwargs):
95
- ... data = kwargs.get('data')
96
- ... print('I got data: {}'.format(data))
97
- ... def on_emitter_state(self, *args, **kwargs):
98
- ... print('emitter state changed')
99
-
100
- >>> emitter = MyEmitter()
101
- >>> listener = MyListener()
102
-
103
- >>> # Bind to the "on_state" and "new_data" events of emitter
104
- >>> emitter.bind(on_state=listener.on_emitter_state)
105
- >>> emitter.bind(new_data=listener.on_new_data)
106
-
107
- >>> emitter.do_some_stuff()
108
- I got data: {'foo': 'bar'}
109
- >>> emitter.emit('on_state')
110
- emitter state changed
111
-
112
- ```
113
-
114
- ### Properties
115
-
116
- ```python
117
- >>> from pydispatch import Dispatcher, Property
118
-
119
- >>> class MyEmitter(Dispatcher):
120
- ... # Property objects are defined and named at the class level.
121
- ... # They will become instance attributes that will emit events when their values change
122
- ... name = Property()
123
- ... value = Property()
124
-
125
- >>> class MyListener(object):
126
- ... def on_name(self, instance, value, **kwargs):
127
- ... print('emitter name is {}'.format(value))
128
- ... def on_value(self, instance, value, **kwargs):
129
- ... print('emitter value is {}'.format(value))
130
-
131
- >>> emitter = MyEmitter()
132
- >>> listener = MyListener()
133
-
134
- >>> # Bind to the "name" and "value" properties of emitter
135
- >>> emitter.bind(name=listener.on_name, value=listener.on_value)
136
-
137
- >>> # Set emitter.name property (triggering the on_name callback)
138
- >>> emitter.name = 'foo'
139
- emitter name is foo
140
-
141
- >>> # Set emitter.value (triggering the on_value callback)
142
- >>> emitter.value = 42
143
- emitter value is 42
144
-
145
- ```
146
-
147
- ## Contributing
148
-
149
- Contributions are welcome!
150
-
151
- If you want to contribute through code or documentation, please see the
152
- [Contributing Guide](CONTRIBUTING.md) for information.
153
-
154
- ## License
155
-
156
- This project is released under the MIT License. See the [LICENSE](LICENSE.txt) file
157
- for more information.
@@ -1,22 +0,0 @@
1
- LICENSE.txt
2
- MANIFEST.in
3
- README.md
4
- setup.cfg
5
- setup.py
6
- pydispatch/__init__.py
7
- pydispatch/aioutils.py
8
- pydispatch/decorators.py
9
- pydispatch/dispatch.py
10
- pydispatch/properties.py
11
- pydispatch/utils.py
12
- python_dispatch.egg-info/PKG-INFO
13
- python_dispatch.egg-info/SOURCES.txt
14
- python_dispatch.egg-info/dependency_links.txt
15
- python_dispatch.egg-info/top_level.txt
16
- tests/test_aio_listeners.py
17
- tests/test_aio_lock.py
18
- tests/test_events.py
19
- tests/test_global_dispatcher.py
20
- tests/test_properties.py
21
- tests/test_subclass_init.py
22
- tests/test_version_attribute.py
@@ -1 +0,0 @@
1
- pydispatch