omdev 0.0.0.dev67__py3-none-any.whl → 0.0.0.dev69__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.
Potentially problematic release.
This version of omdev might be problematic. Click here for more details.
- omdev/.manifests.json +2 -2
- omdev/__about__.py +4 -0
- omdev/cli/clicli.py +4 -0
- omdev/tools/nbtools.py +83 -12
- {omdev-0.0.0.dev67.dist-info → omdev-0.0.0.dev69.dist-info}/METADATA +5 -2
- {omdev-0.0.0.dev67.dist-info → omdev-0.0.0.dev69.dist-info}/RECORD +10 -10
- {omdev-0.0.0.dev67.dist-info → omdev-0.0.0.dev69.dist-info}/LICENSE +0 -0
- {omdev-0.0.0.dev67.dist-info → omdev-0.0.0.dev69.dist-info}/WHEEL +0 -0
- {omdev-0.0.0.dev67.dist-info → omdev-0.0.0.dev69.dist-info}/entry_points.txt +0 -0
- {omdev-0.0.0.dev67.dist-info → omdev-0.0.0.dev69.dist-info}/top_level.txt +0 -0
omdev/.manifests.json
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"module": ".cli.clicli",
|
|
40
40
|
"attr": "_CLI_MODULE",
|
|
41
41
|
"file": "omdev/cli/clicli.py",
|
|
42
|
-
"line":
|
|
42
|
+
"line": 88,
|
|
43
43
|
"value": {
|
|
44
44
|
"$.cli.types.CliModule": {
|
|
45
45
|
"cmd_name": "cli",
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
"module": ".tools.nbtools",
|
|
172
172
|
"attr": "_CLI_MODULE",
|
|
173
173
|
"file": "omdev/tools/nbtools.py",
|
|
174
|
-
"line":
|
|
174
|
+
"line": 115,
|
|
175
175
|
"value": {
|
|
176
176
|
"$.cli.types.CliModule": {
|
|
177
177
|
"cmd_name": [
|
omdev/__about__.py
CHANGED
omdev/cli/clicli.py
CHANGED
|
@@ -25,6 +25,10 @@ class CliCli(ap.Cli):
|
|
|
25
25
|
def print_revision(self) -> None:
|
|
26
26
|
print(__about__.__revision__)
|
|
27
27
|
|
|
28
|
+
@ap.command(name='home')
|
|
29
|
+
def print_home(self) -> None:
|
|
30
|
+
print(sys.prefix)
|
|
31
|
+
|
|
28
32
|
@ap.command(
|
|
29
33
|
ap.arg('--url', default=DEFAULT_REINSTALL_URL),
|
|
30
34
|
ap.arg('--local', action='store_true'),
|
omdev/tools/nbtools.py
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import io
|
|
2
2
|
import json
|
|
3
3
|
import os.path
|
|
4
|
+
import subprocess
|
|
4
5
|
import sys
|
|
6
|
+
import urllib.parse
|
|
7
|
+
import urllib.request
|
|
5
8
|
|
|
6
9
|
from omlish import argparse as ap
|
|
10
|
+
from omlish import check
|
|
7
11
|
|
|
8
12
|
from ..cli import CliModule
|
|
9
13
|
|
|
@@ -13,32 +17,99 @@ class Cli(ap.Cli):
|
|
|
13
17
|
ap.arg('file'),
|
|
14
18
|
ap.arg('-w', '--write', action='store_true'),
|
|
15
19
|
ap.arg('-o', '--overwrite', action='store_true'),
|
|
20
|
+
ap.arg('--no-header', action='store_true'),
|
|
21
|
+
ap.arg('--keep-bangs', action='store_true'),
|
|
22
|
+
ap.arg('--black', action='store_true'),
|
|
16
23
|
)
|
|
17
|
-
def
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
def strip_code(self) -> None:
|
|
25
|
+
out_file: str | None = None
|
|
26
|
+
out_header: list[str] = []
|
|
27
|
+
|
|
28
|
+
if ':' in self.args.file:
|
|
29
|
+
url = self.args.file
|
|
30
|
+
pu = urllib.parse.urlparse(url)
|
|
31
|
+
check.equal(pu.scheme, 'https')
|
|
32
|
+
|
|
33
|
+
out_header.append(f'# Origin: {url}')
|
|
34
|
+
|
|
35
|
+
if pu.hostname == 'github.com':
|
|
36
|
+
_, user, repo, blob, *rest = pu.path.split('/')
|
|
37
|
+
check.equal(blob, 'blob')
|
|
38
|
+
url = f'https://raw.githubusercontent.com/{user}/{repo}/refs/heads/{"/".join(rest)}'
|
|
39
|
+
|
|
40
|
+
elif pu.hostname == 'raw.githubusercontent.com':
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
else:
|
|
44
|
+
raise ValueError(pu.hostname)
|
|
45
|
+
|
|
46
|
+
file = pu.path.split('/')[-1]
|
|
47
|
+
check.state(file.endswith('.ipynb'))
|
|
48
|
+
|
|
49
|
+
if self.args.write:
|
|
50
|
+
out_file = file.rpartition('.')[0] + '.py'
|
|
51
|
+
|
|
52
|
+
with urllib.request.urlopen(url) as resp: # noqa
|
|
53
|
+
buf = resp.read()
|
|
54
|
+
|
|
55
|
+
dct = json.loads(buf.decode('utf-8'))
|
|
56
|
+
|
|
57
|
+
elif self.args.file == '-':
|
|
58
|
+
if self.args.write:
|
|
59
|
+
raise Exception('Write not supported with stdin')
|
|
60
|
+
|
|
61
|
+
dct = json.load(sys.stdin)
|
|
62
|
+
|
|
22
63
|
else:
|
|
23
|
-
|
|
64
|
+
with open(self.args.file) as f:
|
|
65
|
+
dct = json.load(f)
|
|
66
|
+
|
|
67
|
+
if self.args.write:
|
|
68
|
+
out_file = self.args.file.rpartition('.')[0] + '.py'
|
|
24
69
|
|
|
25
|
-
|
|
26
|
-
|
|
70
|
+
if out_file is not None and os.path.isfile(out_file) and not self.args.overwrite:
|
|
71
|
+
raise OSError(f'File exists: {out_file}')
|
|
72
|
+
|
|
73
|
+
delim = '\n##\n\n'
|
|
27
74
|
|
|
28
75
|
out = io.StringIO()
|
|
76
|
+
if not self.args.no_header and out_header:
|
|
77
|
+
out.write('\n'.join(out_header))
|
|
78
|
+
out.write(delim)
|
|
79
|
+
|
|
29
80
|
code_cells = [c for c in dct['cells'] if c['cell_type'] == 'code']
|
|
30
81
|
for i, c in enumerate(code_cells):
|
|
31
82
|
if i:
|
|
32
|
-
out.write(
|
|
33
|
-
|
|
83
|
+
out.write(delim)
|
|
84
|
+
|
|
85
|
+
src = ''.join(c['source'])
|
|
86
|
+
if not self.args.keep_bangs:
|
|
87
|
+
src = ''.join(
|
|
88
|
+
('# ' + l) if l.startswith('!') else l
|
|
89
|
+
for l in src.splitlines(keepends=True)
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
out.write(src)
|
|
34
93
|
out.write('\n')
|
|
35
94
|
|
|
95
|
+
out_src = out.getvalue()
|
|
96
|
+
|
|
97
|
+
if self.args.black:
|
|
98
|
+
proc = subprocess.run(
|
|
99
|
+
[sys.executable, '-m', 'black', '-'],
|
|
100
|
+
input=out_src.encode('utf-8'),
|
|
101
|
+
stdout=subprocess.PIPE,
|
|
102
|
+
check=True,
|
|
103
|
+
)
|
|
104
|
+
out_src = proc.stdout.decode('utf-8')
|
|
105
|
+
|
|
36
106
|
if out_file is not None:
|
|
37
107
|
with open(out_file, 'w') as f:
|
|
38
|
-
f.write(
|
|
108
|
+
f.write(out_src)
|
|
39
109
|
print(f'Wrote {out_file}')
|
|
110
|
+
|
|
40
111
|
else:
|
|
41
|
-
sys.stdout.write(
|
|
112
|
+
sys.stdout.write(out_src)
|
|
42
113
|
|
|
43
114
|
|
|
44
115
|
# @omlish-manifest
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: omdev
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev69
|
|
4
4
|
Summary: omdev
|
|
5
5
|
Author: wrmsr
|
|
6
6
|
License: BSD-3-Clause
|
|
@@ -12,8 +12,9 @@ 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.dev69
|
|
16
16
|
Provides-Extra: all
|
|
17
|
+
Requires-Dist: black ~=24.10 ; extra == 'all'
|
|
17
18
|
Requires-Dist: pycparser ~=2.22 ; extra == 'all'
|
|
18
19
|
Requires-Dist: cffi ~=1.17 ; extra == 'all'
|
|
19
20
|
Requires-Dist: pcpp ~=1.30 ; extra == 'all'
|
|
@@ -21,6 +22,8 @@ Requires-Dist: docutils ~=0.21 ; extra == 'all'
|
|
|
21
22
|
Requires-Dist: mypy ~=1.11 ; extra == 'all'
|
|
22
23
|
Requires-Dist: tokenize-rt ~=6.0 ; extra == 'all'
|
|
23
24
|
Requires-Dist: wheel ~=0.44 ; extra == 'all'
|
|
25
|
+
Provides-Extra: black
|
|
26
|
+
Requires-Dist: black ~=24.10 ; extra == 'black'
|
|
24
27
|
Provides-Extra: c
|
|
25
28
|
Requires-Dist: pycparser ~=2.22 ; extra == 'c'
|
|
26
29
|
Requires-Dist: cffi ~=1.17 ; extra == 'c'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
omdev/.manifests.json,sha256
|
|
2
|
-
omdev/__about__.py,sha256=
|
|
1
|
+
omdev/.manifests.json,sha256=uO7iZexM0Maf0zfoaBOG0fia5BzUfRQ3Ji9A4CSmd08,4477
|
|
2
|
+
omdev/__about__.py,sha256=2mFs3ycC0n2aFJRsyL2yt4CVslLnIMTEYwXmubo7EeM,1066
|
|
3
3
|
omdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
omdev/bracepy.py,sha256=HwBK5XmlOsF_juTel25fRLJK9vHSJCWXuCc-OZlevRQ,2619
|
|
5
5
|
omdev/classdot.py,sha256=K0YMTngaC6uuEKhDb95tFzW33Re_YEdgIWBBeze4PTI,1628
|
|
@@ -59,7 +59,7 @@ omdev/cexts/_distutils/compilers/options.py,sha256=H7r5IcLvga5Fs3jjXWIT-6ap3JBdu
|
|
|
59
59
|
omdev/cexts/_distutils/compilers/unixccompiler.py,sha256=o1h8QuyupLntv4F21_XjzAZmCiwwxJuTmOirvBSL-Qw,15419
|
|
60
60
|
omdev/cli/__init__.py,sha256=V_l6VP1SZMlJbO-8CJwSuO9TThOy2S_oaPepNYgIrbE,37
|
|
61
61
|
omdev/cli/__main__.py,sha256=mOJpgc07o0r5luQ1DlX4tk2PqZkgmbwPbdzJ3KmtjgQ,138
|
|
62
|
-
omdev/cli/clicli.py,sha256=
|
|
62
|
+
omdev/cli/clicli.py,sha256=S2iFrFpGrhm2Ls1Z9qiteBVDEdmF4QJgP3Vv5ndnQ8o,2537
|
|
63
63
|
omdev/cli/install.py,sha256=C-W171YlIHt4Cfok-nWSMbHwWhqF_PFqq2HixFttYx8,4460
|
|
64
64
|
omdev/cli/main.py,sha256=fQL-KdKZDmw00d8vtgxGmUc9Pp3dnhW1BW-Pzu6JPX0,4172
|
|
65
65
|
omdev/cli/managers.py,sha256=tC4saQQhawMwmRzXs4ErKuO3P10rm7GhY2PUUsTK2Ss,1159
|
|
@@ -115,14 +115,14 @@ omdev/tools/dockertools.py,sha256=fkiIAzV-67b4knoF68P19shk94Vec_7xX8MwFGzvPlc,69
|
|
|
115
115
|
omdev/tools/gittools.py,sha256=SMuKeonZP16lYBecmKB7sn_VZ-ljQnJJF6TGX0isVwA,2031
|
|
116
116
|
omdev/tools/importscan.py,sha256=vxOMdAABShqt5-G3n6DGHopCZ5uGgciThY0MCa5W0mA,4066
|
|
117
117
|
omdev/tools/mkrelimp.py,sha256=fwt4GWzenuLNVtzdK2uaJJTSuJbUVJZquF5adwAwlPg,4051
|
|
118
|
-
omdev/tools/nbtools.py,sha256=
|
|
118
|
+
omdev/tools/nbtools.py,sha256=5sAFXw0joeHsE1wCseiyYFHxE459UfE83S8VnHIRXiE,3395
|
|
119
119
|
omdev/tools/piptools.py,sha256=-jR5q3w4sHqntxCLExFCBNIARB788FUsAbJ62PK2sBU,2774
|
|
120
120
|
omdev/tools/proftools.py,sha256=xKSm_yPoCnfsvS3iT9MblDqFMuZmGfI3_koGj8amMyU,145
|
|
121
121
|
omdev/tools/rst.py,sha256=6dWk8QZHoGiLSuBw3TKsXZjjFK6wWBEtPi9krdCLKKg,977
|
|
122
122
|
omdev/tools/sqlrepl.py,sha256=tmFZh80-xsGM62dyQ7_UGLebChrj7IHbIPYBWDJMgVk,5741
|
|
123
|
-
omdev-0.0.0.
|
|
124
|
-
omdev-0.0.0.
|
|
125
|
-
omdev-0.0.0.
|
|
126
|
-
omdev-0.0.0.
|
|
127
|
-
omdev-0.0.0.
|
|
128
|
-
omdev-0.0.0.
|
|
123
|
+
omdev-0.0.0.dev69.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
|
124
|
+
omdev-0.0.0.dev69.dist-info/METADATA,sha256=iywdQ1OkwY6R1tyXqZ_19DKRmYK2uNHdW2xXLTx4VPs,1368
|
|
125
|
+
omdev-0.0.0.dev69.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
126
|
+
omdev-0.0.0.dev69.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
|
|
127
|
+
omdev-0.0.0.dev69.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
|
|
128
|
+
omdev-0.0.0.dev69.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|