pyarmor.cli 9.2.6__3-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.
@@ -0,0 +1,46 @@
1
+ import logging
2
+
3
+ __VERSION__ = '9.2.6'
4
+
5
+ logger = logging.getLogger('cli')
6
+
7
+
8
+ class CliError(Exception):
9
+ pass
10
+
11
+
12
+ def resoptions(meth):
13
+
14
+ def process(self, res, *args, **kwargs):
15
+ self._options = self.ctx.get_res_options(res.fullname, self._Catalog)
16
+ return meth(self, res, *args, **kwargs)
17
+
18
+ return process
19
+
20
+
21
+ class Component(object):
22
+
23
+ def __init__(self, ctx):
24
+ self.ctx = ctx
25
+ self._options = {}
26
+
27
+ self.logger = logging.getLogger(self.LOGNAME)
28
+
29
+ def __getattr__(self, opt):
30
+ if opt.startswith('o_'):
31
+ return self._options.get(opt[2:], '')
32
+ elif opt.startswith('oi_'):
33
+ return int(self._options.get(opt[3:]))
34
+ elif opt.startswith('ob_'):
35
+ v = self._options.get(opt[3:], '')
36
+ if isinstance(v, str):
37
+ if v.isdigit():
38
+ return bool(int(v))
39
+ return v.lower() in ('1', 'true', 'on', 'yes')
40
+
41
+ return v
42
+ return AttributeError(opt)
43
+
44
+ def trace(self, res, node, value):
45
+ lineno = getattr(node, 'lineno', -1)
46
+ self.logger.info('%s:%s:%s', res.fullname, lineno, value)