comparison mercurial/interfaces/util.py @ 42824:2c4f656c8e9f

interfaceutil: move to interfaces/ Now that we have a dedicated folder for interfaces, let's move interfaceutil there. Differential Revision: https://phab.mercurial-scm.org/D6742
author Pulkit Goyal <pulkit@yandex-team.ru>
date Sun, 18 Aug 2019 02:28:42 +0300
parents mercurial/utils/interfaceutil.py@856f381ad74b
children 2372284d9457
comparison
equal deleted inserted replaced
42823:268662aac075 42824:2c4f656c8e9f
1 # util.py - Utilities for declaring interfaces.
2 #
3 # Copyright 2018 Gregory Szorc <gregory.szorc@gmail.com>
4 #
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.
7
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
10 # zope.interface primitives unless instructed otherwise.
11
12 from __future__ import absolute_import
13
14 from .. import (
15 encoding,
16 )
17
18 if encoding.environ.get('HGREALINTERFACES'):
19 from ..thirdparty.zope import (
20 interface as zi,
21 )
22
23 Attribute = zi.Attribute
24 Interface = zi.Interface
25 implementer = zi.implementer
26 else:
27 class Attribute(object):
28 def __init__(self, __name__, __doc__=''):
29 pass
30
31 class Interface(object):
32 def __init__(self, name, bases=(), attrs=None, __doc__=None,
33 __module__=None):
34 pass
35
36 def implementer(*ifaces):
37 def wrapper(cls):
38 return cls
39
40 return wrapper