forked from axel-events/axel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
89 lines (71 loc) · 2.98 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# setup.py
#
# Copyright (C) 2016 Adrian Cristea adrian dot cristea at gmail dotcom
#
# This module is part of axel and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
from setuptools import setup, find_packages
version = '0.0.5'
setup(name='axel',
version=version,
description="Python events handling",
long_description="""\
*Axel* is a very small Python library inspired by C#
events that allows an easy and elegant events handling.
Examples::
from axel import Event
event = Event()
def on_event(*args, **kwargs):
return (args, kwargs)
event += on_event #handler registration
print(event(10, 20, y=30))
>> ((True, ((10, 20), {'y': 30}), <function on_event at 0x00BAA270>),)
event -= on_event #handler is unregistered
print(event(10, 20, y=30))
>> None
class Mouse(object):
def __init__(self):
self.click = Event(self)
self.click += self.on_click #handler registration
def on_click(self, sender, *args, **kwargs):
assert isinstance(sender, Mouse), 'Wrong sender'
return (args, kwargs)
mouse = Mouse()
print(mouse.click(10, 20))
>> ((True, ((10, 20), {}),
>> <bound method Mouse.on_click of <__main__.Mouse object at ...>>),)
mouse.click -= mouse.on_click #handler is unregistered
print(mouse.click(10, 20))
>> None
Features::
- handlers can receive the sender as their first argument
- handlers can be executed in the same or separate threads
- handlers may be executed synchronous or asynchronous
- handlers execution may be synchronized on a lock
- the time allocated for the execution of a handler is controllable
- the number of actively executed handlers at one time is controllable
- the execution result of a handler can be cached
- the result of the execution is provided as a tuple ((flag, result, handler),)
- in case of error, the traceback may be provided for each handler in error
Contributors::
Erwin Mayer <traderwin at gmail dot com>
Rob van der Most <Rob at rmsoft dot nl>
Please see the documentation: https://pythonhosted.org/axel
""",
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Utilities',
],
keywords='event raise handle',
author='Adrian Cristea',
author_email='[email protected] ',
license='MIT',
packages=find_packages('.', exclude=['doc*', 'example*', 'test*']),
zip_safe=False,
)