mapres 2.4a4__tar.gz → 2.4a6__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.4a4/src/mapres.egg-info → mapres-2.4a6}/PKG-INFO +1 -1
- {mapres-2.4a4 → mapres-2.4a6}/pyproject.toml +1 -1
- mapres-2.4a6/src/mapres/__init__.py +126 -0
- {mapres-2.4a4 → mapres-2.4a6}/src/mapres/datamap.py +2 -0
- {mapres-2.4a4 → mapres-2.4a6/src/mapres.egg-info}/PKG-INFO +1 -1
- mapres-2.4a4/src/mapres/__init__.py +0 -53
- {mapres-2.4a4 → mapres-2.4a6}/LICENSE +0 -0
- {mapres-2.4a4 → mapres-2.4a6}/README.md +0 -0
- {mapres-2.4a4 → mapres-2.4a6}/setup.cfg +0 -0
- {mapres-2.4a4 → mapres-2.4a6}/src/mapres/cache.py +0 -0
- {mapres-2.4a4 → mapres-2.4a6}/src/mapres/exceptions.py +0 -0
- {mapres-2.4a4 → mapres-2.4a6}/src/mapres/layers.py +0 -0
- {mapres-2.4a4 → mapres-2.4a6}/src/mapres/maps/__init__.py +0 -0
- {mapres-2.4a4 → mapres-2.4a6}/src/mapres/maps/color.py +0 -0
- {mapres-2.4a4 → mapres-2.4a6}/src/mapres/maps/time.py +0 -0
- {mapres-2.4a4 → mapres-2.4a6}/src/mapres/resolver.py +0 -0
- {mapres-2.4a4 → mapres-2.4a6}/src/mapres.egg-info/SOURCES.txt +0 -0
- {mapres-2.4a4 → mapres-2.4a6}/src/mapres.egg-info/dependency_links.txt +0 -0
- {mapres-2.4a4 → mapres-2.4a6}/src/mapres.egg-info/requires.txt +0 -0
- {mapres-2.4a4 → mapres-2.4a6}/src/mapres.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
from importlib.metadata import version as _pkg_version, PackageNotFoundError
|
|
2
|
+
from types import SimpleNamespace
|
|
3
|
+
import sys
|
|
4
|
+
import importlib.abc
|
|
5
|
+
import importlib.util
|
|
6
|
+
import re
|
|
7
|
+
|
|
8
|
+
# Package version
|
|
9
|
+
try:
|
|
10
|
+
__version__ = _pkg_version('mapres')
|
|
11
|
+
except PackageNotFoundError:
|
|
12
|
+
__version__ = '0.0.0'
|
|
13
|
+
|
|
14
|
+
# ------------------------------------------------------------
|
|
15
|
+
# Public API imports
|
|
16
|
+
# ------------------------------------------------------------
|
|
17
|
+
from .resolver import MapResolver, res, setGlobalMaps, setDefaultPasses
|
|
18
|
+
from .datamap import DataMap, datamap, syntax
|
|
19
|
+
from .layers import Layer, LayerStack
|
|
20
|
+
|
|
21
|
+
# maps
|
|
22
|
+
from .maps.color import ColorMap, ascii_colors, mc_colors, strip_colors
|
|
23
|
+
from .maps.time import TimeMap, time
|
|
24
|
+
|
|
25
|
+
# namespaces
|
|
26
|
+
maps = SimpleNamespace(
|
|
27
|
+
# color
|
|
28
|
+
ColorMap=ColorMap,
|
|
29
|
+
ascii_colors=ascii_colors,
|
|
30
|
+
mc_colors=mc_colors,
|
|
31
|
+
strip_colors=strip_colors,
|
|
32
|
+
|
|
33
|
+
# time
|
|
34
|
+
TimeMap=TimeMap,
|
|
35
|
+
time=time,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
__all__ = [
|
|
39
|
+
# core modules
|
|
40
|
+
'MapResolver',
|
|
41
|
+
'res',
|
|
42
|
+
'DataMap',
|
|
43
|
+
'datamap',
|
|
44
|
+
'syntax',
|
|
45
|
+
'Layer',
|
|
46
|
+
'LayerStack',
|
|
47
|
+
'setGlobalMaps',
|
|
48
|
+
'setDefaultPasses',
|
|
49
|
+
|
|
50
|
+
# maps
|
|
51
|
+
'ColorMap',
|
|
52
|
+
'ascii_colors',
|
|
53
|
+
'mc_colors',
|
|
54
|
+
'strip_colors',
|
|
55
|
+
'TimeMap',
|
|
56
|
+
'time',
|
|
57
|
+
|
|
58
|
+
# namespaces
|
|
59
|
+
'maps',
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
# ------------------------------------------------------------
|
|
63
|
+
# Local-only literal prefix transformer
|
|
64
|
+
# ------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
# Matches: res"<tag>"
|
|
67
|
+
PREFIX_PATTERN = re.compile(r'(\bres)"([^"]*)"')
|
|
68
|
+
|
|
69
|
+
def _transform_source(code: str) -> str:
|
|
70
|
+
return PREFIX_PATTERN.sub(r'\1("\2")', code)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class _MapresLoader(importlib.abc.SourceLoader):
|
|
74
|
+
def __init__(self, fullname, path):
|
|
75
|
+
self.fullname = fullname
|
|
76
|
+
self.path = path
|
|
77
|
+
|
|
78
|
+
def get_filename(self, fullname):
|
|
79
|
+
return self.path
|
|
80
|
+
|
|
81
|
+
def get_data(self, path):
|
|
82
|
+
with open(path, "r", encoding="utf-8") as f:
|
|
83
|
+
original = f.read()
|
|
84
|
+
transformed = _transform_source(original)
|
|
85
|
+
return transformed.encode("utf-8")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class _MapresFinder(importlib.abc.MetaPathFinder):
|
|
89
|
+
def __init__(self, target_module):
|
|
90
|
+
self.target_module = target_module
|
|
91
|
+
|
|
92
|
+
def find_spec(self, fullname, path, target=None):
|
|
93
|
+
# Only rewrite the module that imported mapres
|
|
94
|
+
if fullname != self.target_module:
|
|
95
|
+
return None
|
|
96
|
+
|
|
97
|
+
spec = importlib.util.find_spec(fullname)
|
|
98
|
+
if spec and spec.origin:
|
|
99
|
+
return importlib.util.spec_from_loader(
|
|
100
|
+
fullname,
|
|
101
|
+
_MapresLoader(fullname, spec.origin),
|
|
102
|
+
origin=spec.origin
|
|
103
|
+
)
|
|
104
|
+
return None
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _install_local_hook(module_name):
|
|
108
|
+
sys.meta_path.insert(0, _MapresFinder(module_name))
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
# ------------------------------------------------------------
|
|
112
|
+
# Hook activation
|
|
113
|
+
# ------------------------------------------------------------
|
|
114
|
+
def __getattr__(name):
|
|
115
|
+
# Detect the module that imported mapres
|
|
116
|
+
frame = sys._getframe(1)
|
|
117
|
+
module_name = frame.f_globals.get("__name__")
|
|
118
|
+
|
|
119
|
+
# Install hook for that module
|
|
120
|
+
_install_local_hook(module_name)
|
|
121
|
+
|
|
122
|
+
# Expose your public API normally
|
|
123
|
+
if name in __all__:
|
|
124
|
+
return globals()[name]
|
|
125
|
+
|
|
126
|
+
raise AttributeError(name)
|
|
@@ -10,6 +10,7 @@ class syntax:
|
|
|
10
10
|
hash_tags = r'#([^#]+)#' # #value#
|
|
11
11
|
pipe_tags = r'\|([^|]+)\|' # |value|
|
|
12
12
|
paren_dollar = r'\$\(([^)]+)\)' # $(value)
|
|
13
|
+
colons = r':([^:\n]+):' # :value:
|
|
13
14
|
|
|
14
15
|
@dataclass
|
|
15
16
|
class DataMap:
|
|
@@ -67,3 +68,4 @@ datamap.at_tags = datamap(syntax=syntax.at_tags)
|
|
|
67
68
|
datamap.hash_tags = datamap(syntax=syntax.hash_tags)
|
|
68
69
|
datamap.pipe_tags = datamap(syntax=syntax.pipe_tags)
|
|
69
70
|
datamap.paren_dollar = datamap(syntax=syntax.paren_dollar)
|
|
71
|
+
datamap.colons = datamap(syntax=syntax.colons)
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
from importlib.metadata import version as _pkg_version, PackageNotFoundError
|
|
2
|
-
from types import SimpleNamespace
|
|
3
|
-
|
|
4
|
-
# Package version
|
|
5
|
-
try:
|
|
6
|
-
__version__ = _pkg_version('mapres')
|
|
7
|
-
except PackageNotFoundError:
|
|
8
|
-
__version__ = '0.0.0'
|
|
9
|
-
|
|
10
|
-
from .resolver import MapResolver, res, setGlobalMaps, setDefaultPasses
|
|
11
|
-
from .datamap import DataMap, datamap, syntax
|
|
12
|
-
from .layers import Layer, LayerStack
|
|
13
|
-
|
|
14
|
-
# maps
|
|
15
|
-
from .maps.color import ColorMap, ascii_colors, mc_colors, strip_colors
|
|
16
|
-
from .maps.time import TimeMap, time
|
|
17
|
-
|
|
18
|
-
# namespaces
|
|
19
|
-
maps = SimpleNamespace(
|
|
20
|
-
# color
|
|
21
|
-
ColorMap = ColorMap,
|
|
22
|
-
ascii_colors = ascii_colors,
|
|
23
|
-
mc_colors = mc_colors,
|
|
24
|
-
strip_colors = strip_colors,
|
|
25
|
-
|
|
26
|
-
# time
|
|
27
|
-
TimeMap = TimeMap,
|
|
28
|
-
time = time,
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
__all__ = [
|
|
32
|
-
# core modules
|
|
33
|
-
'MapResolver',
|
|
34
|
-
'res',
|
|
35
|
-
'DataMap',
|
|
36
|
-
'datamap',
|
|
37
|
-
'syntax',
|
|
38
|
-
'Layer',
|
|
39
|
-
'LayerStack',
|
|
40
|
-
'setGlobalMaps',
|
|
41
|
-
'setDefaultPasses',
|
|
42
|
-
|
|
43
|
-
# maps
|
|
44
|
-
'ColorMap',
|
|
45
|
-
'ascii_colors',
|
|
46
|
-
'mc_colors',
|
|
47
|
-
'strip_colors',
|
|
48
|
-
'TimeMap',
|
|
49
|
-
'time',
|
|
50
|
-
|
|
51
|
-
# namespaces
|
|
52
|
-
'maps',
|
|
53
|
-
]
|
|
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
|