mapres 3.dev8__py3-none-any.whl → 3.dev10__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.
- mapres/datamap.py +31 -22
- mapres/evaluator.py +6 -18
- {mapres-3.dev8.dist-info → mapres-3.dev10.dist-info}/METADATA +1 -1
- {mapres-3.dev8.dist-info → mapres-3.dev10.dist-info}/RECORD +7 -7
- {mapres-3.dev8.dist-info → mapres-3.dev10.dist-info}/WHEEL +0 -0
- {mapres-3.dev8.dist-info → mapres-3.dev10.dist-info}/licenses/LICENSE +0 -0
- {mapres-3.dev8.dist-info → mapres-3.dev10.dist-info}/top_level.txt +0 -0
mapres/datamap.py
CHANGED
|
@@ -27,14 +27,23 @@ class DataMap:
|
|
|
27
27
|
|
|
28
28
|
Syntax metadata (__syntax__) determines which delimiters
|
|
29
29
|
this map responds to (angle, brace, colon, percent, pipe, etc).
|
|
30
|
+
|
|
31
|
+
Mode metadata (__mode__) controls behavior:
|
|
32
|
+
- None: plain static map
|
|
33
|
+
- "dynamic": values may be provided by callables/providers
|
|
34
|
+
- "config": config-style maps (no dynamic evaluation)
|
|
35
|
+
- "callable": map exposes callable methods for nested calls
|
|
30
36
|
'''
|
|
31
37
|
__syntax__: str = None
|
|
32
|
-
__mode__: str | None = None # "dynamic", "config", or None
|
|
38
|
+
__mode__: str | None = None # "dynamic", "config", "callable", or None
|
|
33
39
|
|
|
34
40
|
def as_map(self):
|
|
35
41
|
'''
|
|
36
42
|
Convert datamap fields into a dictionary.
|
|
37
43
|
If mode='dynamic', evaluate provider functions.
|
|
44
|
+
|
|
45
|
+
Callable mode does NOT change as_map() behavior; methods are
|
|
46
|
+
used by the evaluator, not exported as map entries.
|
|
38
47
|
'''
|
|
39
48
|
result = {}
|
|
40
49
|
|
|
@@ -59,15 +68,7 @@ class DataMap:
|
|
|
59
68
|
|
|
60
69
|
# main decorator factory
|
|
61
70
|
def datamap(_cls=None, *, syntax=None, mode=None):
|
|
62
|
-
'''
|
|
63
|
-
@datamap decorator.
|
|
64
|
-
|
|
65
|
-
Supports:
|
|
66
|
-
@datamap
|
|
67
|
-
@datamap(mode='dynamic')
|
|
68
|
-
@datamap(syntax='angle')
|
|
69
|
-
@datamap(syntax='angle', mode='config')
|
|
70
|
-
'''
|
|
71
|
+
'''@datamap decorator'''
|
|
71
72
|
def wrap(cls):
|
|
72
73
|
cls.__syntax__ = syntax
|
|
73
74
|
cls.__mode__ = mode
|
|
@@ -90,6 +91,8 @@ class _SyntaxFactory:
|
|
|
90
91
|
@datamap.angles
|
|
91
92
|
@datamap.angles(mode='config')
|
|
92
93
|
@datamap.angles.config
|
|
94
|
+
@datamap.angles.dynamic
|
|
95
|
+
@datamap.angles.callable
|
|
93
96
|
'''
|
|
94
97
|
def __init__(self, syntax_name):
|
|
95
98
|
self._syntax = syntax_name
|
|
@@ -106,24 +109,30 @@ class _SyntaxFactory:
|
|
|
106
109
|
def config(self):
|
|
107
110
|
# Case 3: @datamap.angles.config
|
|
108
111
|
return datamap(syntax=self._syntax, mode='config')
|
|
109
|
-
|
|
112
|
+
|
|
110
113
|
@property
|
|
111
114
|
def dynamic(self):
|
|
115
|
+
# @datamap.angles.dynamic
|
|
112
116
|
return datamap(syntax=self._syntax, mode='dynamic')
|
|
113
117
|
|
|
118
|
+
@property
|
|
119
|
+
def callable(self):
|
|
120
|
+
# @datamap.angles.callable
|
|
121
|
+
return datamap(syntax=self._syntax, mode='callable')
|
|
114
122
|
|
|
115
123
|
|
|
116
124
|
# build syntax shortcuts
|
|
117
|
-
datamap.braces
|
|
118
|
-
|
|
119
|
-
datamap.
|
|
120
|
-
datamap.
|
|
121
|
-
datamap.
|
|
122
|
-
datamap.
|
|
123
|
-
datamap.
|
|
124
|
-
datamap.
|
|
125
|
-
datamap.hash_tags = _SyntaxFactory(syntax.hash_tags)
|
|
125
|
+
datamap.braces = _SyntaxFactory(syntax.braces)
|
|
126
|
+
datamap.dollars = _SyntaxFactory(syntax.dollars)
|
|
127
|
+
datamap.angles = _SyntaxFactory(syntax.angles)
|
|
128
|
+
datamap.percents = _SyntaxFactory(syntax.percents)
|
|
129
|
+
datamap.pipes = _SyntaxFactory(syntax.pipes)
|
|
130
|
+
datamap.colons = _SyntaxFactory(syntax.colons)
|
|
131
|
+
datamap.at_tags = _SyntaxFactory(syntax.at_tags)
|
|
132
|
+
datamap.hash_tags = _SyntaxFactory(syntax.hash_tags)
|
|
126
133
|
datamap.paren_dollars = _SyntaxFactory(syntax.paren_dollars)
|
|
127
134
|
|
|
128
|
-
# global mode
|
|
129
|
-
datamap.config
|
|
135
|
+
# global mode shortcuts
|
|
136
|
+
datamap.config = datamap(mode='config')
|
|
137
|
+
datamap.dynamic = datamap(mode='dynamic')
|
|
138
|
+
datamap.callable = datamap(mode='callable')
|
mapres/evaluator.py
CHANGED
|
@@ -11,15 +11,11 @@ class Evaluator:
|
|
|
11
11
|
self.ctx = ctx or {}
|
|
12
12
|
self._seen = set() # cycle detection
|
|
13
13
|
|
|
14
|
-
#
|
|
15
|
-
# PUBLIC API
|
|
16
|
-
# -----------------------------
|
|
14
|
+
# public api
|
|
17
15
|
def evaluate(self, node):
|
|
18
16
|
return self._eval(node)
|
|
19
17
|
|
|
20
|
-
#
|
|
21
|
-
# INTERNAL DISPATCH
|
|
22
|
-
# -----------------------------
|
|
18
|
+
# internal dispatch
|
|
23
19
|
def _eval(self, node):
|
|
24
20
|
if isinstance(node, TemplateNode):
|
|
25
21
|
return self._eval_template(node)
|
|
@@ -35,18 +31,14 @@ class Evaluator:
|
|
|
35
31
|
|
|
36
32
|
raise EvaluationError(f"Unknown AST node: {node}")
|
|
37
33
|
|
|
38
|
-
#
|
|
39
|
-
# TEMPLATE
|
|
40
|
-
# -----------------------------
|
|
34
|
+
# template
|
|
41
35
|
def _eval_template(self, node: TemplateNode):
|
|
42
36
|
parts = []
|
|
43
37
|
for child in node.children:
|
|
44
38
|
parts.append(self._eval(child))
|
|
45
39
|
return "".join(parts)
|
|
46
40
|
|
|
47
|
-
#
|
|
48
|
-
# IDENTIFIER
|
|
49
|
-
# -----------------------------
|
|
41
|
+
# identifier
|
|
50
42
|
def _eval_ident(self, node: IdentNode):
|
|
51
43
|
name = node.name
|
|
52
44
|
|
|
@@ -77,9 +69,7 @@ class Evaluator:
|
|
|
77
69
|
self._seen.remove(name)
|
|
78
70
|
raise EvaluationError(f"Missing key '{name}'")
|
|
79
71
|
|
|
80
|
-
#
|
|
81
|
-
# CALL (nested token)
|
|
82
|
-
# -----------------------------
|
|
72
|
+
# call (nested token)
|
|
83
73
|
def _eval_call(self, node: CallNode):
|
|
84
74
|
outer = node.name
|
|
85
75
|
|
|
@@ -110,9 +100,7 @@ class Evaluator:
|
|
|
110
100
|
self._seen.remove(outer)
|
|
111
101
|
raise EvaluationError(f"Missing nested key '{outer}({arg_value})'")
|
|
112
102
|
|
|
113
|
-
#
|
|
114
|
-
# HELPERS
|
|
115
|
-
# -----------------------------
|
|
103
|
+
# helpers
|
|
116
104
|
def _map_to_dict(self, m):
|
|
117
105
|
if hasattr(m, "as_map"):
|
|
118
106
|
return m.as_map()
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
mapres/__init__.py,sha256=t23ofM-wzpPByYi1rEQonxyU1yyza4ZzwwHDZUa5QqA,1010
|
|
2
2
|
mapres/ast.py,sha256=6PcMkwtNHYD8xEkdyzDgn_mRTj1ZaWSyuHZK3BtXiuo,427
|
|
3
3
|
mapres/cache.py,sha256=hbvsoc6Qw3RhWAEfOOpKHtC7i9EomoUgWzyd4dnH71w,333
|
|
4
|
-
mapres/datamap.py,sha256=
|
|
5
|
-
mapres/evaluator.py,sha256
|
|
4
|
+
mapres/datamap.py,sha256=0kfxBSAaIXwT8srkcurPbXBbbpmc_HbAzL-iJ45pKNc,4439
|
|
5
|
+
mapres/evaluator.py,sha256=YZ4SUTMM1XhcxH1Skm2J4QSP6_P79TfuQn33cCekRsI,3348
|
|
6
6
|
mapres/exceptions.py,sha256=jirHKK5yCffSCWWkgZY_gTSIOaFCmXOe5NJJf60HeeQ,130
|
|
7
7
|
mapres/layers.py,sha256=sFc1eUOBg2BoB2cBXIleq8RMYcg5GZpUoCnGh-uKN6U,1380
|
|
8
8
|
mapres/parser.py,sha256=8XLCzYosvh81bN-Jddc1AM4w0X7bsHnBzmA8sq5_72w,4018
|
|
@@ -11,8 +11,8 @@ mapres/tokenizer.py,sha256=zw1jhnfypak1bLSTlyo9Xj4UoOF9DJ3y1qqu2OzudiI,5702
|
|
|
11
11
|
mapres/maps/__init__.py,sha256=lIRRfem1Fw4iynuwUQ7BY5qrC4fbJKxqLivao2_Dtm4,239
|
|
12
12
|
mapres/maps/color.py,sha256=noRTGFNo9xLl5YEhX0tttV6i_oDAiptXmRVnkr5EzwM,1348
|
|
13
13
|
mapres/maps/time.py,sha256=TyncycYoIGVZWps32qWlFy2a2hTayvZWVHu9uh2nid8,2050
|
|
14
|
-
mapres-3.
|
|
15
|
-
mapres-3.
|
|
16
|
-
mapres-3.
|
|
17
|
-
mapres-3.
|
|
18
|
-
mapres-3.
|
|
14
|
+
mapres-3.dev10.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
15
|
+
mapres-3.dev10.dist-info/METADATA,sha256=JEbQIvISO6tzTT-q8T_4vqZ3fbfhjATadPmbiq2LdM0,1476
|
|
16
|
+
mapres-3.dev10.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
17
|
+
mapres-3.dev10.dist-info/top_level.txt,sha256=5LMVQqJdtyjxfzv7wJBOZ-360m0Yc79w_-Y7s3n6cTw,7
|
|
18
|
+
mapres-3.dev10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|