zope.hookable 6.0__cp310-cp310-win_amd64.whl → 8.0__cp310-cp310-win_amd64.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 zope.hookable might be problematic. Click here for more details.
- zope/hookable/__init__.py +79 -75
- zope/hookable/_zope_hookable.c +285 -264
- zope/hookable/_zope_hookable.cp310-win_amd64.pyd +0 -0
- zope/hookable/tests/__init__.py +1 -1
- zope/hookable/tests/test_compile_flags.py +29 -29
- zope/hookable/tests/test_hookable.py +203 -198
- {zope.hookable-6.0.dist-info → zope_hookable-8.0.dist-info}/METADATA +50 -15
- zope_hookable-8.0.dist-info/RECORD +11 -0
- {zope.hookable-6.0.dist-info → zope_hookable-8.0.dist-info}/WHEEL +1 -1
- {zope.hookable-6.0.dist-info → zope_hookable-8.0.dist-info/licenses}/LICENSE.txt +44 -44
- zope.hookable-6.0-py3.10-nspkg.pth +0 -1
- zope.hookable-6.0.dist-info/RECORD +0 -13
- zope.hookable-6.0.dist-info/namespace_packages.txt +0 -1
- {zope.hookable-6.0.dist-info → zope_hookable-8.0.dist-info}/top_level.txt +0 -0
zope/hookable/__init__.py
CHANGED
|
@@ -1,75 +1,79 @@
|
|
|
1
|
-
##############################################################################
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2003 Zope Foundation and Contributors.
|
|
4
|
-
# All Rights Reserved.
|
|
5
|
-
#
|
|
6
|
-
# This software is subject to the provisions of the Zope Public License,
|
|
7
|
-
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
|
|
8
|
-
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
|
|
9
|
-
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
10
|
-
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
|
|
11
|
-
# FOR A PARTICULAR PURPOSE.
|
|
12
|
-
#
|
|
13
|
-
##############################################################################
|
|
14
|
-
"""Hookable object support
|
|
15
|
-
"""
|
|
16
|
-
import os
|
|
17
|
-
import platform
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
@property
|
|
41
|
-
def
|
|
42
|
-
return self.
|
|
43
|
-
|
|
44
|
-
@property
|
|
45
|
-
def
|
|
46
|
-
return self.
|
|
47
|
-
|
|
48
|
-
@property
|
|
49
|
-
def
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
@property
|
|
53
|
-
def
|
|
54
|
-
return getattr(self._original, '
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
def
|
|
61
|
-
self._implementation = self.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
1
|
+
##############################################################################
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2003 Zope Foundation and Contributors.
|
|
4
|
+
# All Rights Reserved.
|
|
5
|
+
#
|
|
6
|
+
# This software is subject to the provisions of the Zope Public License,
|
|
7
|
+
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
|
|
8
|
+
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
|
|
9
|
+
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
10
|
+
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
|
|
11
|
+
# FOR A PARTICULAR PURPOSE.
|
|
12
|
+
#
|
|
13
|
+
##############################################################################
|
|
14
|
+
"""Hookable object support
|
|
15
|
+
"""
|
|
16
|
+
import os
|
|
17
|
+
import platform
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Keep these two flags separate: we want the `_PURE_PYTHON` one
|
|
21
|
+
# to represent that the flag is explicitly set to '1' in the environment,
|
|
22
|
+
# since our 'tox.ini' sets it to '0' for its environments which expect
|
|
23
|
+
# to test the C extension.
|
|
24
|
+
_PYPY_OR_JAVA = platform.python_implementation() in ('PyPy', 'Jython')
|
|
25
|
+
_PURE_PYTHON = os.environ.get('PURE_PYTHON') == '1'
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class _py_hookable:
|
|
29
|
+
__slots__ = ('_original', '_implementation')
|
|
30
|
+
|
|
31
|
+
def __init__(self, *args, **kw):
|
|
32
|
+
if not args and 'implementation' in kw:
|
|
33
|
+
args = (kw.pop('implementation'),)
|
|
34
|
+
if kw:
|
|
35
|
+
raise TypeError('Unknown keyword arguments')
|
|
36
|
+
if len(args) != 1:
|
|
37
|
+
raise TypeError('Exactly one argument required')
|
|
38
|
+
self._original = self._implementation = args[0]
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def original(self):
|
|
42
|
+
return self._original
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def implementation(self):
|
|
46
|
+
return self._implementation
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def __doc__(self):
|
|
50
|
+
return self._original.__doc__
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def __dict__(self):
|
|
54
|
+
return getattr(self._original, '__dict__', {})
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def __bases__(self):
|
|
58
|
+
return getattr(self._original, '__bases__', ())
|
|
59
|
+
|
|
60
|
+
def sethook(self, new_callable):
|
|
61
|
+
old, self._implementation = self._implementation, new_callable
|
|
62
|
+
return old
|
|
63
|
+
|
|
64
|
+
def reset(self):
|
|
65
|
+
self._implementation = self._original
|
|
66
|
+
|
|
67
|
+
def __call__(self, *args, **kw):
|
|
68
|
+
return self._implementation(*args, **kw)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
from zope.hookable._zope_hookable import hookable as _c_hookable
|
|
73
|
+
except ModuleNotFoundError: # pragma: no cover
|
|
74
|
+
_c_hookable = None
|
|
75
|
+
|
|
76
|
+
if _PYPY_OR_JAVA or _PURE_PYTHON or _c_hookable is None:
|
|
77
|
+
hookable = _py_hookable
|
|
78
|
+
else: # pragma: no cover
|
|
79
|
+
hookable = _c_hookable
|