omdev 0.0.0.dev310__py3-none-any.whl → 0.0.0.dev312__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 +12 -0
- omdev/ptk/__init__.py +5 -2
- omdev/ptk/confirm.py +54 -0
- omdev/ptk/markdown/markdown.py +6 -0
- omdev/tools/antlr/__main__.py +11 -0
- omdev/tools/antlr/cli.py +62 -0
- omdev/{antlr → tools/antlr}/consts.py +1 -1
- omdev/tools/antlr/gen.py +187 -0
- omdev/tools/git/cli.py +16 -4
- {omdev-0.0.0.dev310.dist-info → omdev-0.0.0.dev312.dist-info}/METADATA +2 -2
- {omdev-0.0.0.dev310.dist-info → omdev-0.0.0.dev312.dist-info}/RECORD +16 -13
- omdev/antlr/gen.py +0 -114
- /omdev/{antlr → tools/antlr}/__init__.py +0 -0
- {omdev-0.0.0.dev310.dist-info → omdev-0.0.0.dev312.dist-info}/WHEEL +0 -0
- {omdev-0.0.0.dev310.dist-info → omdev-0.0.0.dev312.dist-info}/entry_points.txt +0 -0
- {omdev-0.0.0.dev310.dist-info → omdev-0.0.0.dev312.dist-info}/licenses/LICENSE +0 -0
- {omdev-0.0.0.dev310.dist-info → omdev-0.0.0.dev312.dist-info}/top_level.txt +0 -0
omdev/.manifests.json
CHANGED
@@ -290,6 +290,18 @@
|
|
290
290
|
}
|
291
291
|
}
|
292
292
|
},
|
293
|
+
{
|
294
|
+
"module": ".tools.antlr.__main__",
|
295
|
+
"attr": "_CLI_MODULE",
|
296
|
+
"file": "omdev/tools/antlr/__main__.py",
|
297
|
+
"line": 4,
|
298
|
+
"value": {
|
299
|
+
"$.cli.types.CliModule": {
|
300
|
+
"cmd_name": "antlr",
|
301
|
+
"mod_name": "omdev.tools.antlr.__main__"
|
302
|
+
}
|
303
|
+
}
|
304
|
+
},
|
293
305
|
{
|
294
306
|
"module": ".tools.cloc",
|
295
307
|
"attr": "_CLI_MODULE",
|
omdev/ptk/__init__.py
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# ruff: noqa: F401
|
2
2
|
# flake8: noqa: F401
|
3
3
|
|
4
|
-
from prompt_toolkit import Application
|
5
|
-
from prompt_toolkit import prompt
|
4
|
+
from prompt_toolkit.application import Application
|
6
5
|
from prompt_toolkit.application import get_app
|
7
6
|
from prompt_toolkit.application import get_app_session
|
8
7
|
from prompt_toolkit.application import run_in_terminal
|
@@ -80,7 +79,9 @@ from prompt_toolkit.output import DummyOutput
|
|
80
79
|
from prompt_toolkit.output import Output
|
81
80
|
from prompt_toolkit.search import SearchDirection
|
82
81
|
from prompt_toolkit.selection import SelectionType
|
82
|
+
from prompt_toolkit.shortcuts import confirm
|
83
83
|
from prompt_toolkit.shortcuts import print_formatted_text
|
84
|
+
from prompt_toolkit.shortcuts import prompt
|
84
85
|
from prompt_toolkit.styles import BaseStyle
|
85
86
|
from prompt_toolkit.styles import DynamicStyle
|
86
87
|
from prompt_toolkit.styles import Style
|
@@ -95,3 +96,5 @@ from prompt_toolkit.widgets.toolbars import FormattedTextToolbar
|
|
95
96
|
from prompt_toolkit.widgets.toolbars import SearchToolbar
|
96
97
|
from prompt_toolkit.widgets.toolbars import SystemToolbar
|
97
98
|
from prompt_toolkit.widgets.toolbars import ValidationToolbar
|
99
|
+
|
100
|
+
from .confirm import strict_confirm
|
omdev/ptk/confirm.py
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
from prompt_toolkit.formatted_text import merge_formatted_text
|
2
|
+
from prompt_toolkit.key_binding import KeyBindings
|
3
|
+
from prompt_toolkit.key_binding import KeyPressEvent
|
4
|
+
from prompt_toolkit.shortcuts import PromptSession
|
5
|
+
|
6
|
+
from omlish import check
|
7
|
+
|
8
|
+
|
9
|
+
##
|
10
|
+
|
11
|
+
|
12
|
+
def create_strict_confirm_session(
|
13
|
+
message: str,
|
14
|
+
suffix: str = ' (y/n) ',
|
15
|
+
) -> PromptSession[str | bool]:
|
16
|
+
"""Create a `PromptSession` object for the 'confirm' function."""
|
17
|
+
|
18
|
+
bindings = KeyBindings()
|
19
|
+
|
20
|
+
@bindings.add('y')
|
21
|
+
@bindings.add('Y')
|
22
|
+
def yes(event: KeyPressEvent) -> None:
|
23
|
+
session.default_buffer.text = 'y'
|
24
|
+
event.app.exit(result=True)
|
25
|
+
|
26
|
+
@bindings.add('n')
|
27
|
+
@bindings.add('N')
|
28
|
+
def no(event: KeyPressEvent) -> None:
|
29
|
+
session.default_buffer.text = 'n'
|
30
|
+
event.app.exit(result=False)
|
31
|
+
|
32
|
+
complete_message = merge_formatted_text([message, suffix])
|
33
|
+
session: PromptSession[str | bool] = PromptSession(
|
34
|
+
complete_message,
|
35
|
+
key_bindings=bindings,
|
36
|
+
)
|
37
|
+
return session
|
38
|
+
|
39
|
+
|
40
|
+
def strict_confirm(message: str = 'Confirm?', suffix: str = ' (y/n) ') -> bool:
|
41
|
+
"""Display a confirmation prompt that returns True/False. Requires an explicit answer."""
|
42
|
+
|
43
|
+
while True:
|
44
|
+
session = create_strict_confirm_session(message, suffix)
|
45
|
+
ret = session.prompt()
|
46
|
+
|
47
|
+
if isinstance(ret, str):
|
48
|
+
check.empty(ret)
|
49
|
+
|
50
|
+
elif isinstance(ret, bool):
|
51
|
+
return ret
|
52
|
+
|
53
|
+
else:
|
54
|
+
raise TypeError(ret)
|
omdev/ptk/markdown/markdown.py
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
"""
|
2
|
+
TODO:
|
3
|
+
- accept pre-parsed tokens
|
4
|
+
- provide live view in this pkg
|
5
|
+
"""
|
1
6
|
import itertools
|
2
7
|
import typing as ta
|
3
8
|
|
@@ -36,6 +41,7 @@ class Markdown:
|
|
36
41
|
def __init__(
|
37
42
|
self,
|
38
43
|
markup: str,
|
44
|
+
*,
|
39
45
|
width: int | None = None,
|
40
46
|
strip_trailing_lines: bool = True,
|
41
47
|
) -> None:
|
omdev/tools/antlr/cli.py
ADDED
@@ -0,0 +1,62 @@
|
|
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/gen.py
ADDED
@@ -0,0 +1,187 @@
|
|
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
|
+
]
|
137
|
+
|
138
|
+
for l in in_lines:
|
139
|
+
l = re.sub(r'^(from antlr4)(.*)', rf'from {antlr_imp}\2', l)
|
140
|
+
out_lines.append(l)
|
141
|
+
|
142
|
+
with open(ap, 'w') as f:
|
143
|
+
f.write(''.join(out_lines))
|
144
|
+
|
145
|
+
def process_dir(self, dir: str) -> None: # noqa
|
146
|
+
log.info('Processing directory %s', dir)
|
147
|
+
|
148
|
+
ad = os.path.join(dir, self._out_subdir)
|
149
|
+
if os.path.exists(ad):
|
150
|
+
self._rmtree(ad)
|
151
|
+
|
152
|
+
for f in os.listdir(dir):
|
153
|
+
fp = os.path.join(dir, f)
|
154
|
+
if not os.path.isfile(fp) or not f.endswith('.g4'):
|
155
|
+
continue
|
156
|
+
|
157
|
+
self.process_g4(fp)
|
158
|
+
|
159
|
+
if not os.path.exists(ad):
|
160
|
+
return
|
161
|
+
|
162
|
+
ip = os.path.join(ad, '__init__.py')
|
163
|
+
check.state(not os.path.exists(ip))
|
164
|
+
|
165
|
+
for f in list(os.listdir(ad)):
|
166
|
+
fp = os.path.join(ad, f)
|
167
|
+
if not os.path.isfile(fp):
|
168
|
+
continue
|
169
|
+
|
170
|
+
if f.split('.')[-1] in ('interp', 'tokens'):
|
171
|
+
os.unlink(fp)
|
172
|
+
|
173
|
+
elif f != '__init__.py' and f.endswith('.py'):
|
174
|
+
self.process_py(fp)
|
175
|
+
|
176
|
+
with open(ip, 'w'):
|
177
|
+
pass
|
178
|
+
|
179
|
+
def run(self) -> None:
|
180
|
+
dns = _find_dirs(*self._root_dirs, filter=lambda dn: os.path.basename(dn) == '_antlr')
|
181
|
+
for dn in dns:
|
182
|
+
self._rmtree(dn)
|
183
|
+
|
184
|
+
fns = _find_files(*self._root_dirs, filter=lambda fn: fn.endswith('.g4'))
|
185
|
+
fds = {os.path.dirname(fn) for fn in fns}
|
186
|
+
for dn in sorted(fds):
|
187
|
+
self.process_dir(dn)
|
omdev/tools/git/cli.py
CHANGED
@@ -23,7 +23,6 @@ import dataclasses as dc
|
|
23
23
|
import logging
|
24
24
|
import os
|
25
25
|
import re
|
26
|
-
import sys
|
27
26
|
import typing as ta
|
28
27
|
import urllib.parse
|
29
28
|
|
@@ -380,6 +379,8 @@ class Cli(ap.Cli):
|
|
380
379
|
)
|
381
380
|
def update_submodule_branches(self) -> None:
|
382
381
|
def run_submodule(submodule: str, cwd: str | None) -> None:
|
382
|
+
log.info('Updating submodule %s', submodule)
|
383
|
+
|
383
384
|
submodule_path = submodule if cwd is None else os.path.join(cwd, submodule)
|
384
385
|
|
385
386
|
# Get the HEAD branch from origin
|
@@ -401,21 +402,32 @@ class Cli(ap.Cli):
|
|
401
402
|
subprocesses.check_call('git', 'checkout', head_branch, cwd=submodule_path)
|
402
403
|
subprocesses.check_call('git', 'pull', cwd=submodule_path)
|
403
404
|
|
405
|
+
failed: set[str] = set()
|
406
|
+
|
404
407
|
def run(cwd: str | None) -> None:
|
405
408
|
submodules = subprocesses.check_output(
|
406
409
|
'git', 'submodule', 'foreach', '-q', 'echo $name',
|
407
410
|
cwd=cwd,
|
408
411
|
).decode().strip().splitlines()
|
409
412
|
|
410
|
-
for submodule in submodules:
|
413
|
+
for submodule in sorted(submodules):
|
411
414
|
try:
|
412
415
|
run_submodule(submodule, cwd)
|
413
|
-
|
416
|
+
|
417
|
+
except Exception: # noqa
|
418
|
+
failed.add(submodule)
|
419
|
+
|
414
420
|
if self.args.on_error_resume_next:
|
415
|
-
|
421
|
+
log.exception('Failed to update submodule %s', submodule)
|
416
422
|
else:
|
417
423
|
raise
|
418
424
|
|
425
|
+
if failed:
|
426
|
+
log.error(
|
427
|
+
'The following submodules failed to update:\n%s',
|
428
|
+
'\n'.join([f' {f}' for f in failed]),
|
429
|
+
)
|
430
|
+
|
419
431
|
if not self.args.dir:
|
420
432
|
run(None)
|
421
433
|
else:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: omdev
|
3
|
-
Version: 0.0.0.
|
3
|
+
Version: 0.0.0.dev312
|
4
4
|
Summary: omdev
|
5
5
|
Author: wrmsr
|
6
6
|
License: BSD-3-Clause
|
@@ -12,7 +12,7 @@ Classifier: Operating System :: OS Independent
|
|
12
12
|
Classifier: Operating System :: POSIX
|
13
13
|
Requires-Python: >=3.12
|
14
14
|
License-File: LICENSE
|
15
|
-
Requires-Dist: omlish==0.0.0.
|
15
|
+
Requires-Dist: omlish==0.0.0.dev312
|
16
16
|
Provides-Extra: all
|
17
17
|
Requires-Dist: black~=25.1; extra == "all"
|
18
18
|
Requires-Dist: pycparser~=2.22; extra == "all"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
omdev/.manifests.json,sha256=
|
1
|
+
omdev/.manifests.json,sha256=upvKAe9ZFn6SkZusjneWtBKlCoEdy7WJSRP2Kq_ION0,11257
|
2
2
|
omdev/__about__.py,sha256=16xa_1BdZanTpZbkjAOQ11_x5kJcb1m1tKdvb06J7VI,1202
|
3
3
|
omdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
omdev/cmake.py,sha256=9rfSvFHPmKDj9ngvfDB2vK8O-xO_ZwUm7hMKLWA-yOw,4578
|
@@ -16,9 +16,6 @@ omdev/amalg/srcfiles.py,sha256=TKSYSfv78Wb8bcsQS3V76dV_H_MICPwzv06Ar09ew9U,3079
|
|
16
16
|
omdev/amalg/strip.py,sha256=dWQQ5WbtcebLi_PGjPzVYey2mJOnrRES8rkoUS8L52w,1444
|
17
17
|
omdev/amalg/types.py,sha256=BXXJI0VctKTsZv_wXiyMMq3-xShxZ1ak0wxXUK8n9_g,89
|
18
18
|
omdev/amalg/typing.py,sha256=oLlkCnnZQkyKM_xxqm9uxECjn9xj0c4MIwYxxItBdPY,2191
|
19
|
-
omdev/antlr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
|
-
omdev/antlr/consts.py,sha256=6iKuncbRXnGAqemNAceaR2mdFSs-8VbBV-pluM-8Bu4,284
|
21
|
-
omdev/antlr/gen.py,sha256=ZuDoh8ksIGlTSufEnJXogpk7gRVfmPirERdLx2nMWDo,3020
|
22
19
|
omdev/cache/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
23
20
|
omdev/cache/compute/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
24
21
|
omdev/cache/compute/cache.py,sha256=FA6tZWoQpE8D8Os3abdtfT90juzkqBmESjJE3WQXZtQ,3623
|
@@ -204,7 +201,8 @@ omdev/precheck/lite.py,sha256=rG6NYg0X85eN5UQ8-S7fagP5Ng2Nxwuf5Uh7uI8nQsE,4716
|
|
204
201
|
omdev/precheck/main.py,sha256=VEPdq9n8Yo_HiDqfCdHH1pj3xuJgOzrXie_vWoNbKqw,4303
|
205
202
|
omdev/precheck/manifests.py,sha256=4V4_mMh5ptW0jWBmq0nG3bsx3dyjejVs1ReEUoOz-JA,784
|
206
203
|
omdev/precheck/scripts.py,sha256=Br163NGbLY6Mjkxr9htdzqqsYWiEJbg9Gq-Glz6YQUI,1342
|
207
|
-
omdev/ptk/__init__.py,sha256=
|
204
|
+
omdev/ptk/__init__.py,sha256=IemfBhxxqZe1GeZ2_IMQzqWAB5j0XyARp_aajnonyKY,5142
|
205
|
+
omdev/ptk/confirm.py,sha256=kObMUAu-EZC0vdT9LLwtbNA6YLLNmn-Uy18SQTWBTb8,1471
|
208
206
|
omdev/ptk/apps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
209
207
|
omdev/ptk/apps/ncdu.py,sha256=KTbAgwhzcROOvq20VGN92UwMWcgkMMVOeFfpjZAsKUk,4561
|
210
208
|
omdev/ptk/markdown/LICENSE,sha256=oSmc9j-n23wTJUO0TbY8sIHrf9pFZUovFWfDL7D53IA,1489
|
@@ -212,7 +210,7 @@ omdev/ptk/markdown/__init__.py,sha256=Mj0KTyzdGVhkp79QoUiS6iJjnDz8c9chygcbVIgm1d
|
|
212
210
|
omdev/ptk/markdown/__main__.py,sha256=zaZuKy3-llEztkpoIAIzvspOyCsTJQI33ZuadvSHJKM,181
|
213
211
|
omdev/ptk/markdown/border.py,sha256=4gWpwTimurgJ_MjE-UKMCDMb4DnVcgFPfXutObQWOxk,1726
|
214
212
|
omdev/ptk/markdown/cli.py,sha256=FlV12qpyVWgpfeOzyFg9DlgLkss3rgCet_Jebs6_Xqo,537
|
215
|
-
omdev/ptk/markdown/markdown.py,sha256=
|
213
|
+
omdev/ptk/markdown/markdown.py,sha256=wRxCWSV2u71NP_MTi8A8vVLjZ1TmmaWUZMnvW468Ejc,12368
|
216
214
|
omdev/ptk/markdown/parser.py,sha256=UppwouvAYh3qzQMKL-BjcyqBIl2KHcocXlWiKFZ7cBA,990
|
217
215
|
omdev/ptk/markdown/styles.py,sha256=lc17zooXhff5_2tkqLsCmdq2b_rfSAehmHVR-8Lo2qk,777
|
218
216
|
omdev/ptk/markdown/tags.py,sha256=askGU252Zu8KxG2menVHZHXZ4fGbItgy0G4UW9F3mFI,6983
|
@@ -266,9 +264,14 @@ omdev/tools/prof.py,sha256=hQakAsViJD4gLJpLLZnTkOqmTDAwM48Nx5q-O_aFlYM,1467
|
|
266
264
|
omdev/tools/qr.py,sha256=tm68lPwEAkEwIL2sUKPKBYfwwPtjVWG1DBZwur8_jY8,1737
|
267
265
|
omdev/tools/shadow.py,sha256=4E2ilxa16liIvQxvgU37ITkOMrP6ufShRQfeW7wwtRc,1697
|
268
266
|
omdev/tools/sqlrepl.py,sha256=wAjrfXNrRV63-NJCC2HlGQnFh7lUH0bHMnOjYotQqFs,5753
|
267
|
+
omdev/tools/antlr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
268
|
+
omdev/tools/antlr/__main__.py,sha256=7db8YIfCp4GoU-lW7jJJDiLQ6dDrd25M7gUv1AHGj4w,170
|
269
|
+
omdev/tools/antlr/cli.py,sha256=QeO5vSUJDL43lAa2EYsLnN-jZBcNOTwB1C9Ua_h7qoA,1228
|
270
|
+
omdev/tools/antlr/consts.py,sha256=4xH4jyNE5czXRWCn65jFF0MrAodMPe_kYMWpgMxWmpo,289
|
271
|
+
omdev/tools/antlr/gen.py,sha256=0k2o96gye00iMWlC7l6mVjUoYo9lfouGPBmA7_li23U,5085
|
269
272
|
omdev/tools/git/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
270
273
|
omdev/tools/git/__main__.py,sha256=gI87SBUgTkKUcUM-RtZWnei-UUDDqzbr5aPztb-gvbE,168
|
271
|
-
omdev/tools/git/cli.py,sha256=
|
274
|
+
omdev/tools/git/cli.py,sha256=NL30UkmWWoepNCClzeJTHwka3uGgPzGlsao_RDqVOek,14850
|
272
275
|
omdev/tools/git/consts.py,sha256=JuXivUNDkNhM4pe97icjRVAKM8cNRbrODquHINNKqOE,40
|
273
276
|
omdev/tools/git/messages.py,sha256=NWztIK0nAKJIOVzuVQcR_5LHZUgqyVkrOlpl7dFLMdU,2424
|
274
277
|
omdev/tools/json/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -282,9 +285,9 @@ omdev/tools/json/rendering.py,sha256=3HhdlKSetS6iK1tjF2aILzsl8Mb3D8wW92vYwGpRdVA
|
|
282
285
|
omdev/tools/pawk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
283
286
|
omdev/tools/pawk/__main__.py,sha256=VCqeRVnqT1RPEoIrqHFSu4PXVMg4YEgF4qCQm90-eRI,66
|
284
287
|
omdev/tools/pawk/pawk.py,sha256=zsEkfQX0jF5bn712uqPAyBSdJt2dno1LH2oeSMNfXQI,11424
|
285
|
-
omdev-0.0.0.
|
286
|
-
omdev-0.0.0.
|
287
|
-
omdev-0.0.0.
|
288
|
-
omdev-0.0.0.
|
289
|
-
omdev-0.0.0.
|
290
|
-
omdev-0.0.0.
|
288
|
+
omdev-0.0.0.dev312.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
289
|
+
omdev-0.0.0.dev312.dist-info/METADATA,sha256=d0-7zTLSAmgIA9Rori0icQcE8n6xnia9N8IrOXkdVKw,1674
|
290
|
+
omdev-0.0.0.dev312.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
291
|
+
omdev-0.0.0.dev312.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
|
292
|
+
omdev-0.0.0.dev312.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
|
293
|
+
omdev-0.0.0.dev312.dist-info/RECORD,,
|
omdev/antlr/gen.py
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
TODO:
|
3
|
-
- fix relpath in omlish/
|
4
|
-
- sem-bounded parallelism
|
5
|
-
"""
|
6
|
-
import argparse
|
7
|
-
import os.path
|
8
|
-
import re
|
9
|
-
import shutil
|
10
|
-
import subprocess
|
11
|
-
|
12
|
-
from omlish import check
|
13
|
-
from omlish import lang
|
14
|
-
|
15
|
-
from ..cache import data as dcache
|
16
|
-
from .consts import ANTLR_JAR_URL
|
17
|
-
from .consts import ANTLR_RUNTIME_VENDOR
|
18
|
-
|
19
|
-
|
20
|
-
ANTLR_JAR_CACHE = dcache.UrlSpec(ANTLR_JAR_URL)
|
21
|
-
|
22
|
-
|
23
|
-
class GenPy:
|
24
|
-
def __init__(
|
25
|
-
self,
|
26
|
-
dir: str, # noqa
|
27
|
-
*,
|
28
|
-
out_subdir: str = '_antlr',
|
29
|
-
runtime_import: str = ANTLR_RUNTIME_VENDOR,
|
30
|
-
) -> None:
|
31
|
-
super().__init__()
|
32
|
-
check.arg(not os.path.isabs(out_subdir) and '..' not in out_subdir)
|
33
|
-
self._dir = dir
|
34
|
-
self._out_subdir = out_subdir
|
35
|
-
self._runtime_import = runtime_import
|
36
|
-
self._out_dir = os.path.join(dir, out_subdir)
|
37
|
-
|
38
|
-
@lang.cached_function
|
39
|
-
def jar(self) -> str:
|
40
|
-
return dcache.default().get(ANTLR_JAR_CACHE)
|
41
|
-
|
42
|
-
def process_g4(self, g4_file: str) -> None:
|
43
|
-
subprocess.check_call([
|
44
|
-
'java',
|
45
|
-
'-jar', self.jar(),
|
46
|
-
'-Dlanguage=Python3',
|
47
|
-
'-visitor',
|
48
|
-
'-o', self._out_subdir,
|
49
|
-
g4_file,
|
50
|
-
], cwd=self._dir)
|
51
|
-
|
52
|
-
def process_py(self, py_file: str) -> None:
|
53
|
-
ap = os.path.join(self._out_dir, py_file)
|
54
|
-
with open(ap) as f:
|
55
|
-
in_lines = list(f)
|
56
|
-
|
57
|
-
out_lines = [
|
58
|
-
'# type: ignore\n',
|
59
|
-
'# ruff: noqa\n',
|
60
|
-
'# flake8: noqa\n',
|
61
|
-
]
|
62
|
-
for l in in_lines:
|
63
|
-
l = re.sub(r'^(from antlr4)(.*)', rf'from {self._runtime_import}\2', l)
|
64
|
-
out_lines.append(l)
|
65
|
-
|
66
|
-
with open(ap, 'w') as f:
|
67
|
-
f.write(''.join(out_lines))
|
68
|
-
|
69
|
-
def run(self) -> None:
|
70
|
-
if os.path.exists(self._out_dir):
|
71
|
-
shutil.rmtree(self._out_dir)
|
72
|
-
os.mkdir(self._out_dir)
|
73
|
-
with open(os.path.join(self._out_dir, '__init__.py'), 'w'):
|
74
|
-
pass
|
75
|
-
|
76
|
-
for f in os.listdir(self._dir):
|
77
|
-
fp = os.path.join(self._dir, f)
|
78
|
-
if not os.path.isfile(fp):
|
79
|
-
continue
|
80
|
-
if f.endswith('.g4'):
|
81
|
-
self.process_g4(f)
|
82
|
-
|
83
|
-
for f in list(os.listdir(self._out_dir)):
|
84
|
-
fp = os.path.join(self._out_dir, f)
|
85
|
-
if not os.path.isfile(fp):
|
86
|
-
continue
|
87
|
-
if f.split('.')[-1] in ('interp', 'tokens'):
|
88
|
-
os.unlink(fp)
|
89
|
-
elif f != '__init__.py' and f.endswith('.py'):
|
90
|
-
self.process_py(f)
|
91
|
-
|
92
|
-
|
93
|
-
def _main() -> None:
|
94
|
-
parser = argparse.ArgumentParser()
|
95
|
-
parser.add_argument('roots', nargs='*')
|
96
|
-
args = parser.parse_args()
|
97
|
-
|
98
|
-
if not args.roots:
|
99
|
-
parser.print_help()
|
100
|
-
return
|
101
|
-
|
102
|
-
base_dir = os.getcwd()
|
103
|
-
if not os.path.isfile(os.path.join(base_dir, 'pyproject.toml')):
|
104
|
-
raise RuntimeError('Must run from project root')
|
105
|
-
|
106
|
-
for root_dir in args.roots:
|
107
|
-
print(f'Processing {root_dir}')
|
108
|
-
GenPy(
|
109
|
-
root_dir,
|
110
|
-
).run()
|
111
|
-
|
112
|
-
|
113
|
-
if __name__ == '__main__':
|
114
|
-
_main()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|