omdev 0.0.0.dev424__py3-none-any.whl → 0.0.0.dev426__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.
- omdev/{.manifests.json → .omlish-manifests.json} +1 -13
- omdev/ci/cache.py +4 -1
- omdev/ci/cli.py +4 -1
- omdev/ci/docker/cacheserved/cache.py +4 -1
- omdev/ci/docker/packing.py +1 -1
- omdev/ci/github/api/clients.py +4 -1
- omdev/ci/github/api/v1/client.py +4 -1
- omdev/ci/github/api/v2/azure.py +4 -1
- omdev/ci/github/api/v2/client.py +4 -1
- omdev/imgur.py +2 -2
- omdev/interp/providers/standalone.py +4 -1
- omdev/manifests/_dumping.py +1 -8
- omdev/manifests/building.py +6 -3
- omdev/packaging/revisions.py +4 -1
- omdev/ptk/markdown/utils.py +1 -1
- omdev/py/attrdocs.py +3 -3
- omdev/py/docstrings/numpydoc.py +4 -4
- omdev/py/tools/mkrelimp.py +1 -1
- omdev/pyproject/pkg.py +5 -2
- omdev/pyproject/reqs.py +4 -1
- omdev/pyproject/venvs.py +4 -1
- omdev/scripts/ci.py +4469 -4325
- omdev/scripts/interp.py +20 -24
- omdev/scripts/pyproject.py +44 -32
- omdev/tools/json/processing.py +1 -1
- {omdev-0.0.0.dev424.dist-info → omdev-0.0.0.dev426.dist-info}/METADATA +2 -2
- {omdev-0.0.0.dev424.dist-info → omdev-0.0.0.dev426.dist-info}/RECORD +31 -36
- omdev/tools/antlr/__init__.py +0 -0
- omdev/tools/antlr/__main__.py +0 -11
- omdev/tools/antlr/cli.py +0 -62
- omdev/tools/antlr/consts.py +0 -7
- omdev/tools/antlr/gen.py +0 -188
- {omdev-0.0.0.dev424.dist-info → omdev-0.0.0.dev426.dist-info}/WHEEL +0 -0
- {omdev-0.0.0.dev424.dist-info → omdev-0.0.0.dev426.dist-info}/entry_points.txt +0 -0
- {omdev-0.0.0.dev424.dist-info → omdev-0.0.0.dev426.dist-info}/licenses/LICENSE +0 -0
- {omdev-0.0.0.dev424.dist-info → omdev-0.0.0.dev426.dist-info}/top_level.txt +0 -0
omdev/tools/antlr/cli.py
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
import logging
|
2
|
-
import re
|
3
|
-
import subprocess
|
4
|
-
import sys
|
5
|
-
|
6
|
-
from omlish.argparse import all as ap
|
7
|
-
from omlish.logs import all as logs
|
8
|
-
|
9
|
-
from .consts import ANTLR_RUNTIME_PACKAGE
|
10
|
-
from .gen import GenPy
|
11
|
-
from .gen import get_jar_path
|
12
|
-
|
13
|
-
|
14
|
-
log = logging.getLogger(__name__)
|
15
|
-
|
16
|
-
|
17
|
-
##
|
18
|
-
|
19
|
-
|
20
|
-
class Cli(ap.Cli):
|
21
|
-
@ap.cmd()
|
22
|
-
def jar(self) -> None:
|
23
|
-
print(get_jar_path())
|
24
|
-
|
25
|
-
@ap.cmd()
|
26
|
-
def latest(self) -> None:
|
27
|
-
o, _ = subprocess.Popen(
|
28
|
-
[
|
29
|
-
sys.executable,
|
30
|
-
'-m', 'pip',
|
31
|
-
'index', 'versions',
|
32
|
-
ANTLR_RUNTIME_PACKAGE,
|
33
|
-
],
|
34
|
-
stdout=subprocess.PIPE,
|
35
|
-
).communicate()
|
36
|
-
tl = o.decode().splitlines()[0]
|
37
|
-
m = re.fullmatch(rf'{ANTLR_RUNTIME_PACKAGE} \((?P<version>[^)]+)\)', tl)
|
38
|
-
if m is None:
|
39
|
-
raise ValueError(f'Failed to parse version: {tl}')
|
40
|
-
v = m.groupdict()['version']
|
41
|
-
print(v)
|
42
|
-
|
43
|
-
#
|
44
|
-
|
45
|
-
@ap.cmd(
|
46
|
-
ap.arg('roots', nargs='+'),
|
47
|
-
)
|
48
|
-
def gen(self) -> None:
|
49
|
-
gp = GenPy(
|
50
|
-
self.args.roots,
|
51
|
-
)
|
52
|
-
gp.run()
|
53
|
-
|
54
|
-
|
55
|
-
def _main() -> None:
|
56
|
-
logs.configure_standard_logging(logging.INFO)
|
57
|
-
cli = Cli()
|
58
|
-
cli()
|
59
|
-
|
60
|
-
|
61
|
-
if __name__ == '__main__':
|
62
|
-
_main()
|
omdev/tools/antlr/consts.py
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
ANTLR_VERSION = '4.13.2'
|
2
|
-
ANTLR_JAR_NAME = f'antlr-{ANTLR_VERSION}-complete.jar'
|
3
|
-
ANTLR_JAR_URL = f'https://www.antlr.org/download/{ANTLR_JAR_NAME}'
|
4
|
-
ANTLR_RUNTIME_PACKAGE = 'antlr4-python3-runtime'
|
5
|
-
ANTLR_GITHUB_REPO = 'antlr/antlr4'
|
6
|
-
|
7
|
-
ANTLR_RUNTIME_VENDOR = 'omlish.text.antlr._runtime._all'
|
omdev/tools/antlr/gen.py
DELETED
@@ -1,188 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
TODO:
|
3
|
-
- mtime cmp
|
4
|
-
- parallelism
|
5
|
-
"""
|
6
|
-
import logging
|
7
|
-
import os.path
|
8
|
-
import re
|
9
|
-
import shutil
|
10
|
-
import subprocess
|
11
|
-
import typing as ta
|
12
|
-
|
13
|
-
from omlish import check
|
14
|
-
from omlish import lang
|
15
|
-
from omlish.os.paths import is_path_in_dir
|
16
|
-
|
17
|
-
from ...cache import data as dcache
|
18
|
-
from .consts import ANTLR_JAR_URL
|
19
|
-
from .consts import ANTLR_RUNTIME_VENDOR
|
20
|
-
|
21
|
-
|
22
|
-
log = logging.getLogger(__name__)
|
23
|
-
|
24
|
-
|
25
|
-
##
|
26
|
-
|
27
|
-
|
28
|
-
ANTLR_JAR_CACHE = dcache.UrlSpec(ANTLR_JAR_URL)
|
29
|
-
|
30
|
-
|
31
|
-
@lang.cached_function
|
32
|
-
def get_jar_path() -> str:
|
33
|
-
return dcache.default().get(ANTLR_JAR_CACHE)
|
34
|
-
|
35
|
-
|
36
|
-
##
|
37
|
-
|
38
|
-
|
39
|
-
def _find_dirs(*base_paths: str, filter: ta.Callable[[str], bool] = lambda _: True) -> ta.Sequence[str]: # noqa
|
40
|
-
return sorted(
|
41
|
-
os.path.join(dp, dn)
|
42
|
-
for base_path in base_paths
|
43
|
-
for dp, dns, fns in os.walk(base_path)
|
44
|
-
for dn in dns
|
45
|
-
if filter(dn)
|
46
|
-
)
|
47
|
-
|
48
|
-
|
49
|
-
def _find_files(*base_paths: str, filter: ta.Callable[[str], bool] = lambda _: True) -> ta.Sequence[str]: # noqa
|
50
|
-
return sorted(
|
51
|
-
os.path.join(dp, fn)
|
52
|
-
for base_path in base_paths
|
53
|
-
for dp, dns, fns in os.walk(base_path)
|
54
|
-
for fn in fns
|
55
|
-
if filter(fn)
|
56
|
-
)
|
57
|
-
|
58
|
-
|
59
|
-
class GenPy:
|
60
|
-
def __init__(
|
61
|
-
self,
|
62
|
-
root_dirs: str, # noqa
|
63
|
-
*,
|
64
|
-
out_subdir: str = '_antlr',
|
65
|
-
runtime_import: str = ANTLR_RUNTIME_VENDOR,
|
66
|
-
jar_path: str | None = None,
|
67
|
-
# parallelism: int | None = None,
|
68
|
-
) -> None:
|
69
|
-
super().__init__()
|
70
|
-
|
71
|
-
check.non_empty_str(out_subdir)
|
72
|
-
check.arg(not os.path.isabs(out_subdir) and '.' not in out_subdir and '/' not in out_subdir)
|
73
|
-
|
74
|
-
self._root_dirs = frozenset(check.non_empty_str(rd) for rd in check.not_isinstance(root_dirs, str))
|
75
|
-
self._out_subdir = out_subdir
|
76
|
-
self._runtime_import = runtime_import
|
77
|
-
self._given_jar_path = jar_path
|
78
|
-
|
79
|
-
#
|
80
|
-
|
81
|
-
def _rmtree(self, tgt: str) -> None: # noqa
|
82
|
-
if not any(is_path_in_dir(rd, tgt) for rd in self._root_dirs):
|
83
|
-
raise RuntimeError(f'Refusing to delete {tgt!r} outside of {self._root_dirs!r}')
|
84
|
-
shutil.rmtree(tgt)
|
85
|
-
|
86
|
-
#
|
87
|
-
|
88
|
-
@lang.cached_function
|
89
|
-
def jar_path(self) -> str:
|
90
|
-
if (gjp := self._given_jar_path) is not None:
|
91
|
-
return gjp
|
92
|
-
return get_jar_path()
|
93
|
-
|
94
|
-
#
|
95
|
-
|
96
|
-
def process_g4(self, g4_file: str) -> None:
|
97
|
-
ap = os.path.abspath(g4_file)
|
98
|
-
check.state(os.path.isfile(ap))
|
99
|
-
|
100
|
-
od = os.path.join(os.path.dirname(ap), self._out_subdir)
|
101
|
-
os.makedirs(od, exist_ok=True)
|
102
|
-
|
103
|
-
log.info('Compiling grammar %s', g4_file)
|
104
|
-
|
105
|
-
try:
|
106
|
-
subprocess.check_call([
|
107
|
-
'java',
|
108
|
-
'-jar', self.jar_path(),
|
109
|
-
'-Dlanguage=Python3',
|
110
|
-
'-visitor',
|
111
|
-
'-o', self._out_subdir,
|
112
|
-
os.path.basename(g4_file),
|
113
|
-
], cwd=os.path.dirname(ap))
|
114
|
-
|
115
|
-
except Exception: # noqa
|
116
|
-
log.exception('Exception in grammar %s', g4_file)
|
117
|
-
raise
|
118
|
-
|
119
|
-
def process_py(self, py_file: str) -> None:
|
120
|
-
ap = os.path.abspath(py_file)
|
121
|
-
with open(ap) as f:
|
122
|
-
in_lines = list(f)
|
123
|
-
|
124
|
-
pfp = py_file.split(os.sep)
|
125
|
-
arp = ANTLR_RUNTIME_VENDOR.split('.')
|
126
|
-
if (cpl := lang.common_prefix_len(pfp, arp)) > 0:
|
127
|
-
pkg_depth = len(os.path.normpath(py_file).split(os.path.sep))
|
128
|
-
antlr_imp = '.'.join([*([''] * (pkg_depth - cpl)), *arp[cpl:]])
|
129
|
-
else:
|
130
|
-
antlr_imp = ANTLR_RUNTIME_VENDOR
|
131
|
-
|
132
|
-
out_lines = [
|
133
|
-
'# type: ignore\n',
|
134
|
-
'# ruff: noqa\n',
|
135
|
-
'# flake8: noqa\n',
|
136
|
-
'# @omlish-generated\n',
|
137
|
-
]
|
138
|
-
|
139
|
-
for l in in_lines:
|
140
|
-
l = re.sub(r'^(from antlr4)(.*)', rf'from {antlr_imp}\2', l)
|
141
|
-
out_lines.append(l)
|
142
|
-
|
143
|
-
with open(ap, 'w') as f:
|
144
|
-
f.write(''.join(out_lines))
|
145
|
-
|
146
|
-
def process_dir(self, dir: str) -> None: # noqa
|
147
|
-
log.info('Processing directory %s', dir)
|
148
|
-
|
149
|
-
ad = os.path.join(dir, self._out_subdir)
|
150
|
-
if os.path.exists(ad):
|
151
|
-
self._rmtree(ad)
|
152
|
-
|
153
|
-
for f in os.listdir(dir):
|
154
|
-
fp = os.path.join(dir, f)
|
155
|
-
if not os.path.isfile(fp) or not f.endswith('.g4'):
|
156
|
-
continue
|
157
|
-
|
158
|
-
self.process_g4(fp)
|
159
|
-
|
160
|
-
if not os.path.exists(ad):
|
161
|
-
return
|
162
|
-
|
163
|
-
ip = os.path.join(ad, '__init__.py')
|
164
|
-
check.state(not os.path.exists(ip))
|
165
|
-
|
166
|
-
for f in list(os.listdir(ad)):
|
167
|
-
fp = os.path.join(ad, f)
|
168
|
-
if not os.path.isfile(fp):
|
169
|
-
continue
|
170
|
-
|
171
|
-
if f.split('.')[-1] in ('interp', 'tokens'):
|
172
|
-
os.unlink(fp)
|
173
|
-
|
174
|
-
elif f != '__init__.py' and f.endswith('.py'):
|
175
|
-
self.process_py(fp)
|
176
|
-
|
177
|
-
with open(ip, 'w'):
|
178
|
-
pass
|
179
|
-
|
180
|
-
def run(self) -> None:
|
181
|
-
dns = _find_dirs(*self._root_dirs, filter=lambda dn: os.path.basename(dn) == '_antlr')
|
182
|
-
for dn in dns:
|
183
|
-
self._rmtree(dn)
|
184
|
-
|
185
|
-
fns = _find_files(*self._root_dirs, filter=lambda fn: fn.endswith('.g4'))
|
186
|
-
fds = {os.path.dirname(fn) for fn in fns}
|
187
|
-
for dn in sorted(fds):
|
188
|
-
self.process_dir(dn)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|