Show More
@@ -1,38 +1,30 | |||||
1 | # util.py - Utilities for declaring interfaces. |
|
1 | # util.py - Utilities for declaring interfaces. | |
2 | # |
|
2 | # | |
3 | # Copyright 2018 Gregory Szorc <gregory.szorc@gmail.com> |
|
3 | # Copyright 2018 Gregory Szorc <gregory.szorc@gmail.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | # zope.interface imposes a run-time cost due to module import overhead and |
|
8 | # zope.interface imposes a run-time cost due to module import overhead and | |
9 | # bookkeeping for declaring interfaces. So, we use stubs for various |
|
9 | # bookkeeping for declaring interfaces. So, we use stubs for various | |
10 | # zope.interface primitives unless instructed otherwise. |
|
10 | # zope.interface primitives unless instructed otherwise. | |
11 |
|
11 | |||
12 | from __future__ import annotations |
|
12 | from __future__ import annotations | |
13 |
|
13 | |||
14 | from .. import encoding |
|
14 | if True: | |
15 |
|
||||
16 | if encoding.environ.get(b'HGREALINTERFACES'): |
|
|||
17 | from ..thirdparty.zope import interface as zi |
|
|||
18 |
|
||||
19 | Attribute = zi.Attribute |
|
|||
20 | Interface = zi.Interface |
|
|||
21 | implementer = zi.implementer |
|
|||
22 | else: |
|
|||
23 |
|
15 | |||
24 | class Attribute: |
|
16 | class Attribute: | |
25 | def __init__(self, __name__, __doc__=b''): |
|
17 | def __init__(self, __name__, __doc__=b''): | |
26 | pass |
|
18 | pass | |
27 |
|
19 | |||
28 | class Interface: |
|
20 | class Interface: | |
29 | def __init__( |
|
21 | def __init__( | |
30 | self, name, bases=(), attrs=None, __doc__=None, __module__=None |
|
22 | self, name, bases=(), attrs=None, __doc__=None, __module__=None | |
31 | ): |
|
23 | ): | |
32 | pass |
|
24 | pass | |
33 |
|
25 | |||
34 | def implementer(*ifaces): |
|
26 | def implementer(*ifaces): | |
35 | def wrapper(cls): |
|
27 | def wrapper(cls): | |
36 | return cls |
|
28 | return cls | |
37 |
|
29 | |||
38 | return wrapper |
|
30 | return wrapper |
General Comments 0
You need to be logged in to leave comments.
Login now