gntplib 0.5__py3-none-any.whl → 0.66__py3-none-any.whl

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.

Potentially problematic release.


This version of gntplib might be problematic. Click here for more details.

gntplib/keys.py CHANGED
@@ -1,79 +1,79 @@
1
- """This module provides the authorization of messages."""
2
-
3
- from __future__ import unicode_literals
4
- import binascii
5
- import hashlib
6
- import random
7
-
8
- from .utils import random_bytes
9
-
10
-
11
- __all__ = ['MD5', 'SHA1', 'SHA256', 'SHA512']
12
-
13
-
14
- class _Algorithm(object):
15
- """The factory class of keys."""
16
-
17
- def __init__(self, algorithm_id, key_size):
18
- self.algorithm_id = algorithm_id
19
- self.key_size = key_size
20
-
21
- def key(self, password):
22
- """Return an instance of :class:`Key`."""
23
- return Key(password, self.algorithm_id)
24
-
25
-
26
- #: (128-bit, 16 byte, 32 character length when hex encoded)
27
- MD5 = _Algorithm('MD5', 16)
28
- #: (160-bit, 20 byte, 40 character length when hex encoded)
29
- SHA1 = _Algorithm('SHA1', 20)
30
- #: (256-bit, 32 byte, 64 character length when hex encoded)
31
- SHA256 = _Algorithm('SHA256', 32)
32
- #: (512-bit, 64 byte, 128 character length when hex encoded)
33
- SHA512 = _Algorithm('SHA512', 64)
34
-
35
- MIN_SALT_BYTES = 4
36
- MAX_SALT_BYTES = 16
37
-
38
-
39
- def random_salt():
40
- """Generate random salt."""
41
- num = random.randint(MIN_SALT_BYTES, MAX_SALT_BYTES)
42
- return random_bytes(num)
43
-
44
-
45
- class Key(object):
46
- """The authorization of messages.
47
-
48
- :param password: the password.
49
- :param salt: the salt of the hashing. If it is `None`, the random salt is
50
- generated. Defaults to `None`.
51
- :param algorithm_id: the algorithm of the hashing. Specify `'MD5'`,
52
- `'SHA1'`, `'SHA256'` or `'SHA512'`.
53
- Defaults to `'SHA256'`.
54
- """
55
-
56
- def __init__(self, password, algorithm_id='SHA256', salt=None):
57
- self.password = password.encode('utf-8')
58
- self.algorithm_id = algorithm_id
59
- self.salt = salt or random_salt()
60
-
61
- algorithm = getattr(hashlib, algorithm_id.lower())
62
- key_basis = self.password + self.salt
63
- self.key = algorithm(key_basis).digest()
64
- self.key_hash = algorithm(self.key).digest()
65
-
66
- @property
67
- def salt_hex(self):
68
- """The hex-encoded hash of the salt."""
69
- return binascii.hexlify(self.salt)
70
-
71
- @property
72
- def key_hex(self):
73
- """The hex-encoded key."""
74
- return binascii.hexlify(self.key)
75
-
76
- @property
77
- def key_hash_hex(self):
78
- """The hex-encoded hash of the key."""
79
- return binascii.hexlify(self.key_hash)
1
+ """This module provides the authorization of messages."""
2
+
3
+ from __future__ import unicode_literals
4
+ import binascii
5
+ import hashlib
6
+ import random
7
+
8
+ from .utils import random_bytes
9
+
10
+
11
+ __all__ = ['MD5', 'SHA1', 'SHA256', 'SHA512']
12
+
13
+
14
+ class _Algorithm(object):
15
+ """The factory class of keys."""
16
+
17
+ def __init__(self, algorithm_id, key_size):
18
+ self.algorithm_id = algorithm_id
19
+ self.key_size = key_size
20
+
21
+ def key(self, password):
22
+ """Return an instance of :class:`Key`."""
23
+ return Key(password, self.algorithm_id)
24
+
25
+
26
+ #: (128-bit, 16 byte, 32 character length when hex encoded)
27
+ MD5 = _Algorithm('MD5', 16)
28
+ #: (160-bit, 20 byte, 40 character length when hex encoded)
29
+ SHA1 = _Algorithm('SHA1', 20)
30
+ #: (256-bit, 32 byte, 64 character length when hex encoded)
31
+ SHA256 = _Algorithm('SHA256', 32)
32
+ #: (512-bit, 64 byte, 128 character length when hex encoded)
33
+ SHA512 = _Algorithm('SHA512', 64)
34
+
35
+ MIN_SALT_BYTES = 4
36
+ MAX_SALT_BYTES = 16
37
+
38
+
39
+ def random_salt():
40
+ """Generate random salt."""
41
+ num = random.randint(MIN_SALT_BYTES, MAX_SALT_BYTES)
42
+ return random_bytes(num)
43
+
44
+
45
+ class Key(object):
46
+ """The authorization of messages.
47
+
48
+ :param password: the password.
49
+ :param salt: the salt of the hashing. If it is `None`, the random salt is
50
+ generated. Defaults to `None`.
51
+ :param algorithm_id: the algorithm of the hashing. Specify `'MD5'`,
52
+ `'SHA1'`, `'SHA256'` or `'SHA512'`.
53
+ Defaults to `'SHA256'`.
54
+ """
55
+
56
+ def __init__(self, password, algorithm_id='SHA256', salt=None):
57
+ self.password = password.encode('utf-8')
58
+ self.algorithm_id = algorithm_id
59
+ self.salt = salt or random_salt()
60
+
61
+ algorithm = getattr(hashlib, algorithm_id.lower())
62
+ key_basis = self.password + self.salt
63
+ self.key = algorithm(key_basis).digest()
64
+ self.key_hash = algorithm(self.key).digest()
65
+
66
+ @property
67
+ def salt_hex(self):
68
+ """The hex-encoded hash of the salt."""
69
+ return binascii.hexlify(self.salt)
70
+
71
+ @property
72
+ def key_hex(self):
73
+ """The hex-encoded key."""
74
+ return binascii.hexlify(self.key)
75
+
76
+ @property
77
+ def key_hash_hex(self):
78
+ """The hex-encoded hash of the key."""
79
+ return binascii.hexlify(self.key_hash)
gntplib/utils.py CHANGED
@@ -1,11 +1,11 @@
1
- """This module provides utilities."""
2
-
3
- from __future__ import unicode_literals
4
- import random
5
- import struct
6
-
7
-
8
- def random_bytes(num):
9
- """Return a bytes containing `n` bytes of random data."""
10
- return struct.pack(b'B' * num,
11
- *[random.randint(0, 255) for _ in range(num)])
1
+ """This module provides utilities."""
2
+
3
+ from __future__ import unicode_literals
4
+ import random
5
+ import struct
6
+
7
+
8
+ def random_bytes(num):
9
+ """Return a bytes containing `n` bytes of random data."""
10
+ return struct.pack(b'B' * num,
11
+ *[random.randint(0, 255) for _ in range(num)])
@@ -1,120 +1,118 @@
1
- Metadata-Version: 2.1
2
- Name: gntplib
3
- Version: 0.5
4
- Summary: A Growl Notification Transport Protocol (GNTP) client library in Python
5
- Home-page: http://github.com/papaeye/gntplib
6
- Author: papaeye
7
- Author-email: papaeye@gmail.com
8
- License: BSD License
9
- Keywords: gntp growl async
10
- Platform: any
11
- Classifier: Development Status :: 3 - Alpha
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: BSD License
14
- Classifier: Operating System :: OS Independent
15
- Classifier: Programming Language :: Python
16
- Classifier: Programming Language :: Python :: 2
17
- Classifier: Programming Language :: Python :: 2.7
18
- Classifier: Programming Language :: Python :: 3
19
- Classifier: Programming Language :: Python :: 3.2
20
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
- Provides-Extra: async
22
- Requires-Dist: tornado ; extra == 'async'
23
- Provides-Extra: ciphers
24
- Requires-Dist: pycrypto ; extra == 'ciphers'
25
-
26
- gntplib
27
- =======
28
-
29
- gntplib is a Growl Notification Transport Protocol (GNTP_) client library in
30
- Python.
31
-
32
- gntplib is tested on Python 2.7/3.2, Growl_ 1.3.3 and
33
- `Growl for Windows`_ 2.0.9.
34
-
35
- .. _GNTP: http://www.growlforwindows.com/gfw/help/gntp.aspx
36
- .. _Growl: http://growl.info/
37
- .. _Growl for Windows: http://www.growlforwindows.com/
38
-
39
- Installation
40
- ------------
41
-
42
- Simply use pip::
43
-
44
- $ pip install gntplib
45
-
46
- There are the following **optional** prerequisites.
47
-
48
- * ``pycrypto`` - to use ``gntplib.ciphers`` module for message encryption
49
- * ``tornado`` - to use ``gntplib.async`` module for asynchronous processing
50
-
51
- Documentation
52
- -------------
53
-
54
- Release version: http://packages.python.org/gntplib/ (`ja
55
- <http://packages.python.org/gntplib/ja/>`_)
56
-
57
- Development version: http://gntplib.readthedocs.org/en/latest/
58
-
59
- History
60
- -------
61
-
62
- 0.5 (2012-04-13)
63
- ~~~~~~~~~~~~~~~~
64
-
65
- * Support ``SUBSCRIBE`` request.
66
-
67
- - Add ``gntplib.subscribe()``, ``gntplib.Subscriber`` and
68
- ``gntplib.async.AsyncSubscriber``.
69
-
70
- * Support Custom Headers and App-Specific Headers.
71
-
72
- * Deprecate ``gntplib.notify()``, ``gntplib.Notifier()`` and
73
- ``gntplib.AsyncNotifier()`` in favor of ``gntplib.publish()``,
74
- ``gntplib.Publisher()`` and ``gntplib.async.AsyncPublisher()``.
75
-
76
- * Deprecate ``gntplib.RawIcon`` and ``gntplib.async.AsyncIcon`` in favor of
77
- ``gntplib.Resource`` and ``gntplib.async.AsyncResource``.
78
-
79
- 0.4 (2012-04-07)
80
- ~~~~~~~~~~~~~~~~
81
-
82
- * Support password and encryption
83
- * Support Growl for Windows
84
-
85
- 0.3 (2012-03-30)
86
- ~~~~~~~~~~~~~~~~
87
-
88
- * Support Python 3
89
-
90
- 0.2 (2012-03-18)
91
- ~~~~~~~~~~~~~~~~
92
-
93
- * Add support for asynchronous processing built on Tornado.
94
-
95
- - Add ``gntplib.async.AsyncNotifier`` and ``gntplib.async.AsyncIcon``.
96
-
97
- * Imporve usability of callback.
98
-
99
- - ``SocketCallback``: Now ``SocketCallback`` is not a abstract class, but
100
- represents a socket callback. Its ``if_clicked``, ``if_closed`` and
101
- ``if_timedout`` methods are replaced with ``on_click``, ``on_close`` and
102
- ``on_timeout`` methods respectively, which can be set at the constructor.
103
-
104
- - ``Notifier.notify()``: Redefine ``callback`` argument as for the callback
105
- to run after closing the connection with the GNTP server.
106
- Add ``gntp_callback`` argument for url callback (as string) and socket
107
- callback (as ``SocketCallback`` instance).
108
- Add ``context``, ``context_type``, ``on_click``, ``on_close`` and
109
- ``on_timeout`` arguments to define a socket callback easily.
110
-
111
- * Remove ``callback`` argument from ``gntplib.notify()``.
112
-
113
- * Rename ``gntplib.Icon`` to ``gntplib.RawIcon``.
114
-
115
- 0.1 (2012-03-12)
116
- ~~~~~~~~~~~~~~~~
117
-
118
- * Initial release.
119
-
120
-
1
+ Metadata-Version: 2.1
2
+ Name: gntplib
3
+ Version: 0.66
4
+ Summary: A Growl Notification Transport Protocol (GNTP) client library in Python
5
+ Home-page: http://github.com/papaeye/gntplib
6
+ Author: papaeye
7
+ Author-email: papaeye@gmail.com
8
+ License: BSD License
9
+ Keywords: gntp growl async
10
+ Platform: any
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: BSD License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 2
17
+ Classifier: Programming Language :: Python :: 2.7
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.2
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Provides-Extra: async
22
+ Requires-Dist: tornado ; extra == 'async'
23
+ Provides-Extra: ciphers
24
+ Requires-Dist: pycrypto ; extra == 'ciphers'
25
+
26
+ gntplib
27
+ =======
28
+
29
+ gntplib is a Growl Notification Transport Protocol (GNTP_) client library in
30
+ Python.
31
+
32
+ gntplib is tested on Python 2.7/3.2, Growl_ 1.3.3 and
33
+ `Growl for Windows`_ 2.0.9.
34
+
35
+ .. _GNTP: http://www.growlforwindows.com/gfw/help/gntp.aspx
36
+ .. _Growl: http://growl.info/
37
+ .. _Growl for Windows: http://www.growlforwindows.com/
38
+
39
+ Installation
40
+ ------------
41
+
42
+ Simply use pip::
43
+
44
+ $ pip install gntplib
45
+
46
+ There are the following **optional** prerequisites.
47
+
48
+ * ``pycrypto`` - to use ``gntplib.ciphers`` module for message encryption
49
+ * ``tornado`` - to use ``gntplib.async`` module for asynchronous processing
50
+
51
+ Documentation
52
+ -------------
53
+
54
+ Release version: http://packages.python.org/gntplib/ (`ja
55
+ <http://packages.python.org/gntplib/ja/>`_)
56
+
57
+ Development version: http://gntplib.readthedocs.org/en/latest/
58
+
59
+ History
60
+ -------
61
+
62
+ 0.5 (2012-04-13)
63
+ ~~~~~~~~~~~~~~~~
64
+
65
+ * Support ``SUBSCRIBE`` request.
66
+
67
+ - Add ``gntplib.subscribe()``, ``gntplib.Subscriber`` and
68
+ ``gntplib.async.AsyncSubscriber``.
69
+
70
+ * Support Custom Headers and App-Specific Headers.
71
+
72
+ * Deprecate ``gntplib.notify()``, ``gntplib.Notifier()`` and
73
+ ``gntplib.AsyncNotifier()`` in favor of ``gntplib.publish()``,
74
+ ``gntplib.Publisher()`` and ``gntplib.async.AsyncPublisher()``.
75
+
76
+ * Deprecate ``gntplib.RawIcon`` and ``gntplib.async.AsyncIcon`` in favor of
77
+ ``gntplib.Resource`` and ``gntplib.async.AsyncResource``.
78
+
79
+ 0.4 (2012-04-07)
80
+ ~~~~~~~~~~~~~~~~
81
+
82
+ * Support password and encryption
83
+ * Support Growl for Windows
84
+
85
+ 0.3 (2012-03-30)
86
+ ~~~~~~~~~~~~~~~~
87
+
88
+ * Support Python 3
89
+
90
+ 0.2 (2012-03-18)
91
+ ~~~~~~~~~~~~~~~~
92
+
93
+ * Add support for asynchronous processing built on Tornado.
94
+
95
+ - Add ``gntplib.async.AsyncNotifier`` and ``gntplib.async.AsyncIcon``.
96
+
97
+ * Imporve usability of callback.
98
+
99
+ - ``SocketCallback``: Now ``SocketCallback`` is not a abstract class, but
100
+ represents a socket callback. Its ``if_clicked``, ``if_closed`` and
101
+ ``if_timedout`` methods are replaced with ``on_click``, ``on_close`` and
102
+ ``on_timeout`` methods respectively, which can be set at the constructor.
103
+
104
+ - ``Notifier.notify()``: Redefine ``callback`` argument as for the callback
105
+ to run after closing the connection with the GNTP server.
106
+ Add ``gntp_callback`` argument for url callback (as string) and socket
107
+ callback (as ``SocketCallback`` instance).
108
+ Add ``context``, ``context_type``, ``on_click``, ``on_close`` and
109
+ ``on_timeout`` arguments to define a socket callback easily.
110
+
111
+ * Remove ``callback`` argument from ``gntplib.notify()``.
112
+
113
+ * Rename ``gntplib.Icon`` to ``gntplib.RawIcon``.
114
+
115
+ 0.1 (2012-03-12)
116
+ ~~~~~~~~~~~~~~~~
117
+
118
+ * Initial release.
@@ -0,0 +1,12 @@
1
+ gntplib/__init__.py,sha256=7VdMpycTOxdRtG4LPU9UT3hSCs0dNDUmPzzxd1q7uPs,39058
2
+ gntplib/__version__.py,sha256=hWHIth9AZdm6SLiyBpiC_Mct9BucCMVbsp0xvi3IBuU,14
3
+ gntplib/async.py,sha256=SAqPRwmvOUwkKVZY8-KnFxPwAHoScre5grBpkT6kLMg,7659
4
+ gntplib/ciphers.py,sha256=iaSWP_hFJxGv_yv91v6Z51A8YOd15rbx9j2wZ7E5e2s,2735
5
+ gntplib/compat.py,sha256=8mtq5JLXo4OfN-bZpYoSaTlu71VyrPGrZ5FKROg66QA,166
6
+ gntplib/exceptions.py,sha256=5WCFEjHvQWpFusdnLmgUFwJo9nb2sGFTpQcW0vpeoJM,127
7
+ gntplib/keys.py,sha256=VA6CW8dsOoiC0ODgb1ESqn8Ibj1l-JO_Acd8czW_BgM,2373
8
+ gntplib/utils.py,sha256=3zZK0ng02iqb4p5s1sJGeIlC16WKV1TkfYYotUI8Hd4,310
9
+ gntplib-0.66.dist-info/METADATA,sha256=-fVpLYOPJZ7lmWE58el1cAn22j9qVuNPNaLe-YqGOVk,3634
10
+ gntplib-0.66.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
11
+ gntplib-0.66.dist-info/top_level.txt,sha256=w79bTPPYSZrHpvaUgB_Jj4vs8ATzLhJpv3MDGxrIksg,8
12
+ gntplib-0.66.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
- Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.33.6)
3
- Root-Is-Purelib: true
4
- Tag: py3-none-any
5
-
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (74.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -1,11 +0,0 @@
1
- gntplib/__init__.py,sha256=s-1a1AsS6mQRFtJAkFxmTutt2V2DboBOFfEmcFpMLNM,37519
2
- gntplib/async.py,sha256=v1YqCig_1DbJfFRaMLZ86vWfsgtulBO-XvhT2Fz07Y0,7466
3
- gntplib/ciphers.py,sha256=iAAk5YxrnrP3kLsD3cUqr05LoNEUwIEK67f34e7VclM,2638
4
- gntplib/compat.py,sha256=tgvkxlSmRBx_gPlX6-Z-K9EDeT_ounuN2vBvk_-bTzs,157
5
- gntplib/exceptions.py,sha256=jIDdu-PdkFi9c7vq0liq7H2jTEjLhBk1OhWy5khyqJ4,122
6
- gntplib/keys.py,sha256=iZ5W3ZAmS2XdHnvAD_w4erJQ3fZeVN-eNL8v31nRKtM,2294
7
- gntplib/utils.py,sha256=6oKvWgB73DI74OO8o1FbPxDiQNQL9FJkY5nf3C777Vc,299
8
- gntplib-0.5.dist-info/METADATA,sha256=unBYB6gqosC4p2MljxUv8iPmU7wch1T5z8UAZbBMNhA,3517
9
- gntplib-0.5.dist-info/WHEEL,sha256=v8slff5hmCpvciQ3G55d2d1CnOBupjDFJHDE2dUb1Ao,97
10
- gntplib-0.5.dist-info/top_level.txt,sha256=w79bTPPYSZrHpvaUgB_Jj4vs8ATzLhJpv3MDGxrIksg,8
11
- gntplib-0.5.dist-info/RECORD,,