mapres 2.4a3__tar.gz → 2.4a5__tar.gz
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-2.4a3/src/mapres.egg-info → mapres-2.4a5}/PKG-INFO +1 -1
- {mapres-2.4a3 → mapres-2.4a5}/pyproject.toml +1 -1
- {mapres-2.4a3 → mapres-2.4a5}/src/mapres/datamap.py +21 -14
- {mapres-2.4a3 → mapres-2.4a5/src/mapres.egg-info}/PKG-INFO +1 -1
- {mapres-2.4a3 → mapres-2.4a5}/LICENSE +0 -0
- {mapres-2.4a3 → mapres-2.4a5}/README.md +0 -0
- {mapres-2.4a3 → mapres-2.4a5}/setup.cfg +0 -0
- {mapres-2.4a3 → mapres-2.4a5}/src/mapres/__init__.py +0 -0
- {mapres-2.4a3 → mapres-2.4a5}/src/mapres/cache.py +0 -0
- {mapres-2.4a3 → mapres-2.4a5}/src/mapres/exceptions.py +0 -0
- {mapres-2.4a3 → mapres-2.4a5}/src/mapres/layers.py +0 -0
- {mapres-2.4a3 → mapres-2.4a5}/src/mapres/maps/__init__.py +0 -0
- {mapres-2.4a3 → mapres-2.4a5}/src/mapres/maps/color.py +0 -0
- {mapres-2.4a3 → mapres-2.4a5}/src/mapres/maps/time.py +0 -0
- {mapres-2.4a3 → mapres-2.4a5}/src/mapres/resolver.py +0 -0
- {mapres-2.4a3 → mapres-2.4a5}/src/mapres.egg-info/SOURCES.txt +0 -0
- {mapres-2.4a3 → mapres-2.4a5}/src/mapres.egg-info/dependency_links.txt +0 -0
- {mapres-2.4a3 → mapres-2.4a5}/src/mapres.egg-info/requires.txt +0 -0
- {mapres-2.4a3 → mapres-2.4a5}/src/mapres.egg-info/top_level.txt +0 -0
|
@@ -2,16 +2,20 @@ import re
|
|
|
2
2
|
from dataclasses import dataclass, fields, is_dataclass
|
|
3
3
|
|
|
4
4
|
class syntax:
|
|
5
|
-
|
|
6
|
-
dollars
|
|
7
|
-
angles
|
|
8
|
-
percents
|
|
9
|
-
|
|
5
|
+
double_braces = r'\{\{([^{}]+)\}\}' # {{value}}
|
|
6
|
+
dollars = r'\$\{([^{}]+)\}' # ${value}
|
|
7
|
+
angles = r'<([^<>]+)>' # <value>
|
|
8
|
+
percents = r'%([^%]+)%' # %value%
|
|
9
|
+
at_tags = r'@([^@]+)@' # @value@
|
|
10
|
+
hash_tags = r'#([^#]+)#' # #value#
|
|
11
|
+
pipe_tags = r'\|([^|]+)\|' # |value|
|
|
12
|
+
paren_dollar = r'\$\(([^)]+)\)' # $(value)
|
|
13
|
+
colons = r':([^:\n]+):' # :value:
|
|
10
14
|
|
|
11
15
|
@dataclass
|
|
12
16
|
class DataMap:
|
|
13
17
|
'''Core datamap class. Contains logic used to make datamaps'''
|
|
14
|
-
__syntax__: str = syntax.
|
|
18
|
+
__syntax__: str = syntax.double_braces
|
|
15
19
|
__mode__: str | None = None
|
|
16
20
|
|
|
17
21
|
def as_map(self):
|
|
@@ -31,14 +35,14 @@ class DataMap:
|
|
|
31
35
|
|
|
32
36
|
@classmethod
|
|
33
37
|
def get_syntax(cls):
|
|
34
|
-
return getattr(cls, '__syntax__', syntax.
|
|
38
|
+
return getattr(cls, '__syntax__', syntax.double_braces)
|
|
35
39
|
|
|
36
40
|
|
|
37
41
|
# decorator
|
|
38
42
|
def datamap(
|
|
39
43
|
_cls = None,
|
|
40
44
|
*,
|
|
41
|
-
syntax: str = syntax.
|
|
45
|
+
syntax: str = syntax.double_braces,
|
|
42
46
|
mode: bool | str | None = None,
|
|
43
47
|
):
|
|
44
48
|
'''@datamap decorator with optional values'''
|
|
@@ -47,10 +51,8 @@ def datamap(
|
|
|
47
51
|
cls.__mode__ = mode
|
|
48
52
|
namespace = dict(cls.__dict__)
|
|
49
53
|
namespace['__dict__'] = {}
|
|
50
|
-
# preserve any rules class defined in the original namespace by attaching it to the generated class
|
|
51
54
|
rules_obj = namespace.get('rules', None)
|
|
52
55
|
cls = type(cls.__name__, (DataMap,), namespace)
|
|
53
|
-
# attach rules (if present) to the new class so validators can read them via the datamap class
|
|
54
56
|
if rules_obj is not None:
|
|
55
57
|
setattr(cls, 'rules', rules_obj)
|
|
56
58
|
return dataclass(frozen=False)(cls)
|
|
@@ -58,7 +60,12 @@ def datamap(
|
|
|
58
60
|
|
|
59
61
|
|
|
60
62
|
# decorator shortcuts
|
|
61
|
-
datamap.
|
|
62
|
-
datamap.angles
|
|
63
|
-
datamap.dollars
|
|
64
|
-
datamap.percents
|
|
63
|
+
datamap.double_braces = datamap(syntax=syntax.double_braces)
|
|
64
|
+
datamap.angles = datamap(syntax=syntax.angles)
|
|
65
|
+
datamap.dollars = datamap(syntax=syntax.dollars)
|
|
66
|
+
datamap.percents = datamap(syntax=syntax.percents)
|
|
67
|
+
datamap.at_tags = datamap(syntax=syntax.at_tags)
|
|
68
|
+
datamap.hash_tags = datamap(syntax=syntax.hash_tags)
|
|
69
|
+
datamap.pipe_tags = datamap(syntax=syntax.pipe_tags)
|
|
70
|
+
datamap.paren_dollar = datamap(syntax=syntax.paren_dollar)
|
|
71
|
+
datamap.colons = datamap(syntax=syntax.colons)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|