omdev 0.0.0.dev69__py3-none-any.whl → 0.0.0.dev71__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 CHANGED
@@ -135,7 +135,7 @@
135
135
  "module": ".tools.gittools",
136
136
  "attr": "_CLI_MODULE",
137
137
  "file": "omdev/tools/gittools.py",
138
- "line": 74,
138
+ "line": 124,
139
139
  "value": {
140
140
  "$.cli.types.CliModule": {
141
141
  "cmd_name": "git",
@@ -194,6 +194,30 @@
194
194
  }
195
195
  }
196
196
  },
197
+ {
198
+ "module": ".tools.proftools",
199
+ "attr": "_CLI_MODULE",
200
+ "file": "omdev/tools/proftools.py",
201
+ "line": 50,
202
+ "value": {
203
+ "$.cli.types.CliModule": {
204
+ "cmd_name": "prof",
205
+ "mod_name": "omdev.tools.proftools"
206
+ }
207
+ }
208
+ },
209
+ {
210
+ "module": ".tools.rsttool",
211
+ "attr": "_CLI_MODULE",
212
+ "file": "omdev/tools/rsttool.py",
213
+ "line": 55,
214
+ "value": {
215
+ "$.cli.types.CliModule": {
216
+ "cmd_name": "rst",
217
+ "mod_name": "omdev.tools.rsttool"
218
+ }
219
+ }
220
+ },
197
221
  {
198
222
  "module": ".tools.sqlrepl",
199
223
  "attr": "_CLI_MODULE",
omdev/__about__.py CHANGED
@@ -30,6 +30,10 @@ class Project(ProjectBase):
30
30
  'mypy ~= 1.11',
31
31
  ],
32
32
 
33
+ 'prof': [
34
+ 'gprof2dot ~= 2024.6',
35
+ ],
36
+
33
37
  'tokens': [
34
38
  'tokenize_rt ~= 6.0',
35
39
  ],
omdev/cli/managers.py CHANGED
@@ -50,5 +50,5 @@ def setup_install_manager(cli_pkg: str) -> None:
50
50
  if detect_install_manager(cli_pkg) is None:
51
51
  return
52
52
 
53
- from .pathhack import _install_pth_file
53
+ from ._pathhack import _install_pth_file
54
54
  _install_pth_file()
omdev/tools/gittools.py CHANGED
@@ -4,11 +4,35 @@ import subprocess
4
4
  import urllib.parse
5
5
 
6
6
  from omlish import argparse as ap
7
+ from omlish import check
7
8
  from omlish import logs
8
9
 
9
10
  from ..cli import CliModule
10
11
 
11
12
 
13
+ def rev_parse(rev: str) -> str:
14
+ return subprocess.check_output(['git', 'rev-parse', rev]).decode().strip()
15
+
16
+
17
+ def get_first_commit_of_day(rev: str) -> str | None:
18
+ commit_date = subprocess.check_output([
19
+ 'git', 'show', '-s', '--format=%ci', rev,
20
+ ]).decode().strip().split(' ')[0]
21
+
22
+ first_commit = subprocess.check_output([
23
+ 'git', 'rev-list', '--reverse', '--max-parents=1',
24
+ '--since', f'{commit_date} 00:00:00',
25
+ '--until', f'{commit_date} 23:59:59',
26
+ rev,
27
+ ]).decode().strip().splitlines()
28
+
29
+ # Return the first commit (if there is any)
30
+ if first_commit:
31
+ return first_commit[0]
32
+ else:
33
+ return None
34
+
35
+
12
36
  class Cli(ap.Cli):
13
37
  @ap.command()
14
38
  def blob_sizes(self) -> None:
@@ -70,6 +94,32 @@ class Cli(ap.Cli):
70
94
 
71
95
  print(out_dir)
72
96
 
97
+ @ap.command(
98
+ ap.arg('rev', nargs='?', default='HEAD'),
99
+ ap.arg('-d', '--diff', action='store_true'),
100
+ ap.arg('-s', '--diff-stat', action='store_true'),
101
+ ap.arg('-g', '--github', action='store_true'),
102
+ )
103
+ def recap(self) -> None:
104
+ rev = rev_parse(self.args.rev)
105
+ day_rev = check.not_none(get_first_commit_of_day(rev))
106
+ base_rev = rev_parse(f'{day_rev}~1')
107
+
108
+ if self.args.diff or self.args.diff_stat:
109
+ os.execvp('git', ['git', 'diff', *(['--stat'] if self.args.diff_stat else []), base_rev, rev])
110
+
111
+ elif self.args.github:
112
+ rm_url = subprocess.check_output(['git', 'remote', 'get-url', 'origin']).decode('utf-8').strip()
113
+ pu = urllib.parse.urlparse(rm_url)
114
+ check.equal(pu.scheme, 'https')
115
+ check.equal(pu.hostname, 'github.com')
116
+ _, user, repo, *_ = pu.path.split('/')
117
+ gh_url = f'https://github.com/{user}/{repo}/compare/{base_rev}...{rev}'
118
+ print(gh_url)
119
+
120
+ else:
121
+ print(base_rev)
122
+
73
123
 
74
124
  # @omlish-manifest
75
125
  _CLI_MODULE = CliModule('git', __name__)
omdev/tools/proftools.py CHANGED
@@ -1,4 +1,55 @@
1
- """
2
- TODO:
3
- - rm prof.pstats.pdf ; ./python -m gprof2dot -f pstats prof.pstats | dot -Tpdf -o prof.pstats.pdf && open prof.pstats.pdf
4
- """ # noqa
1
+ import os.path
2
+ import subprocess
3
+ import sys
4
+ import tempfile
5
+
6
+ from omlish import argparse as ap
7
+
8
+ from ..cli import CliModule
9
+
10
+
11
+ class Cli(ap.Cli):
12
+ @ap.command(
13
+ ap.arg('file'),
14
+ ap.arg('out-file', nargs='?'),
15
+ ap.arg('-w', '--write', action='store_true'),
16
+ ap.arg('-o', '--overwrite', action='store_true'),
17
+ ap.arg('-O', '--open', action='store_true'),
18
+ )
19
+ def pstats_pdf(self) -> None:
20
+ out_file = self.args.out_file
21
+ if out_file is None and self.args.write:
22
+ out_file = self.args.file + '.pdf'
23
+
24
+ if out_file is not None:
25
+ if os.path.exists(out_file) and not self.args.overwrite:
26
+ raise OSError(f'File exists: {out_file}')
27
+ else:
28
+ out_file = tempfile.mktemp(suffix=os.path.basename(self.args.file) + '.pdf') # noqa
29
+
30
+ dot = subprocess.check_output([
31
+ sys.executable,
32
+ '-m', 'gprof2dot',
33
+ '-f', 'pstats',
34
+ self.args.file,
35
+ ])
36
+
37
+ pdf = subprocess.check_output(
38
+ ['dot', '-Tpdf'],
39
+ input=dot,
40
+ )
41
+
42
+ with open(out_file, 'wb') as f:
43
+ f.write(pdf)
44
+ print(out_file)
45
+
46
+ if self.args.open:
47
+ subprocess.check_call(['open', out_file])
48
+
49
+
50
+ # @omlish-manifest
51
+ _CLI_MODULE = CliModule('prof', __name__)
52
+
53
+
54
+ if __name__ == '__main__':
55
+ Cli()()
omdev/tools/rsttool.py ADDED
@@ -0,0 +1,60 @@
1
+ """
2
+ TODO:
3
+ - omdev/rst.py *and* rsttool.py, when we want extracted helpers
4
+ """
5
+ import contextlib
6
+ import io
7
+ import sys
8
+
9
+ import docutils.core
10
+
11
+ from omlish import argparse as ap
12
+
13
+ from ..cli import CliModule
14
+
15
+
16
+ def rst2html(rst, report_level=None):
17
+ kwargs = {
18
+ 'writer_name': 'html',
19
+ 'settings_overrides': {
20
+ '_disable_config': True,
21
+ 'report_level': int(report_level) if report_level else 0,
22
+ },
23
+ }
24
+
25
+ target = io.StringIO()
26
+ with contextlib.redirect_stderr(target):
27
+ parts = docutils.core.publish_parts(rst, **kwargs) # type: ignore
28
+ html = parts['html_body']
29
+ warning = target.getvalue().strip()
30
+ return html, warning
31
+
32
+
33
+ class Cli(ap.Cli):
34
+ @ap.command(
35
+ ap.arg('input-file', nargs='?'),
36
+ ap.arg('--report-level', type=int),
37
+ )
38
+ def html(self) -> None:
39
+ if self.args.input_file is not None:
40
+ with open(self.args.input_file) as f:
41
+ src = f.read()
42
+ else:
43
+ src = sys.stdin.read()
44
+
45
+ html, warning = rst2html(
46
+ src,
47
+ report_level=self.args.report_level,
48
+ )
49
+
50
+ if warning:
51
+ sys.stderr.write(warning)
52
+ print(html)
53
+
54
+
55
+ # @omlish-manifest
56
+ _CLI_MODULE = CliModule('rst', __name__)
57
+
58
+
59
+ if __name__ == '__main__':
60
+ Cli().call_and_exit()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omdev
3
- Version: 0.0.0.dev69
3
+ Version: 0.0.0.dev71
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.dev69
15
+ Requires-Dist: omlish ==0.0.0.dev71
16
16
  Provides-Extra: all
17
17
  Requires-Dist: black ~=24.10 ; extra == 'all'
18
18
  Requires-Dist: pycparser ~=2.22 ; extra == 'all'
@@ -20,6 +20,7 @@ Requires-Dist: cffi ~=1.17 ; extra == 'all'
20
20
  Requires-Dist: pcpp ~=1.30 ; extra == 'all'
21
21
  Requires-Dist: docutils ~=0.21 ; extra == 'all'
22
22
  Requires-Dist: mypy ~=1.11 ; extra == 'all'
23
+ Requires-Dist: gprof2dot ~=2024.6 ; extra == 'all'
23
24
  Requires-Dist: tokenize-rt ~=6.0 ; extra == 'all'
24
25
  Requires-Dist: wheel ~=0.44 ; extra == 'all'
25
26
  Provides-Extra: black
@@ -32,6 +33,8 @@ Provides-Extra: docutils
32
33
  Requires-Dist: docutils ~=0.21 ; extra == 'docutils'
33
34
  Provides-Extra: mypy
34
35
  Requires-Dist: mypy ~=1.11 ; extra == 'mypy'
36
+ Provides-Extra: prof
37
+ Requires-Dist: gprof2dot ~=2024.6 ; extra == 'prof'
35
38
  Provides-Extra: tokens
36
39
  Requires-Dist: tokenize-rt ~=6.0 ; extra == 'tokens'
37
40
  Provides-Extra: wheel
@@ -1,5 +1,5 @@
1
- omdev/.manifests.json,sha256=uO7iZexM0Maf0zfoaBOG0fia5BzUfRQ3Ji9A4CSmd08,4477
2
- omdev/__about__.py,sha256=2mFs3ycC0n2aFJRsyL2yt4CVslLnIMTEYwXmubo7EeM,1066
1
+ omdev/.manifests.json,sha256=nQzpxNEwzKDGCbPlKZ9WGPy-hFOMM2c4ME7jt0lxWzA,4991
2
+ omdev/__about__.py,sha256=bwCUKH9MgCgKZ4s7JedVN9_ESOv-1CziylwJJCgiaE4,1131
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,11 +59,11 @@ 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/_pathhack.py,sha256=_446loyBbCI3LaP2OhYAkKjWEgf_7eJ6UZyt_hlrClA,1479
62
63
  omdev/cli/clicli.py,sha256=S2iFrFpGrhm2Ls1Z9qiteBVDEdmF4QJgP3Vv5ndnQ8o,2537
63
64
  omdev/cli/install.py,sha256=C-W171YlIHt4Cfok-nWSMbHwWhqF_PFqq2HixFttYx8,4460
64
65
  omdev/cli/main.py,sha256=fQL-KdKZDmw00d8vtgxGmUc9Pp3dnhW1BW-Pzu6JPX0,4172
65
- omdev/cli/managers.py,sha256=tC4saQQhawMwmRzXs4ErKuO3P10rm7GhY2PUUsTK2Ss,1159
66
- omdev/cli/pathhack.py,sha256=_446loyBbCI3LaP2OhYAkKjWEgf_7eJ6UZyt_hlrClA,1479
66
+ omdev/cli/managers.py,sha256=BV98_n30Jj63OJrFgRoVZRfICxMLXEZKoEn4rMj9LV4,1160
67
67
  omdev/cli/types.py,sha256=bqKw9SbtBtAip2vF9v4khh0CqKG6LBr6n9VzWBz7AJE,474
68
68
  omdev/interp/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
69
69
  omdev/interp/__main__.py,sha256=GMCqeGYltgt5dlJzHxY9gqisa8cRkrPfmZYuZnjg4WI,162
@@ -112,17 +112,17 @@ omdev/toml/parser.py,sha256=84bn09uhYHwQGyfww6Rw6y1RxPAE_HDltODOSakcqDM,29186
112
112
  omdev/toml/writer.py,sha256=lk3on3YXVbWuLJa-xsOzOhs1bBAT1vXqw4mBbluZl_w,3040
113
113
  omdev/tools/__init__.py,sha256=iVJAOQ0viGTQOm0DLX4uZLro-9jOioYJGLg9s0kDx1A,78
114
114
  omdev/tools/dockertools.py,sha256=fkiIAzV-67b4knoF68P19shk94Vec_7xX8MwFGzvPlc,6907
115
- omdev/tools/gittools.py,sha256=SMuKeonZP16lYBecmKB7sn_VZ-ljQnJJF6TGX0isVwA,2031
115
+ omdev/tools/gittools.py,sha256=wfNu6uqZdSUbpCWO7OOA8d91t6ZwltRTIhjkzMOq0xU,3795
116
116
  omdev/tools/importscan.py,sha256=vxOMdAABShqt5-G3n6DGHopCZ5uGgciThY0MCa5W0mA,4066
117
117
  omdev/tools/mkrelimp.py,sha256=fwt4GWzenuLNVtzdK2uaJJTSuJbUVJZquF5adwAwlPg,4051
118
118
  omdev/tools/nbtools.py,sha256=5sAFXw0joeHsE1wCseiyYFHxE459UfE83S8VnHIRXiE,3395
119
119
  omdev/tools/piptools.py,sha256=-jR5q3w4sHqntxCLExFCBNIARB788FUsAbJ62PK2sBU,2774
120
- omdev/tools/proftools.py,sha256=xKSm_yPoCnfsvS3iT9MblDqFMuZmGfI3_koGj8amMyU,145
121
- omdev/tools/rst.py,sha256=6dWk8QZHoGiLSuBw3TKsXZjjFK6wWBEtPi9krdCLKKg,977
120
+ omdev/tools/proftools.py,sha256=8ZU9x_Dq8eT2ZFwU9sJpDIvxcIn9qBc8y2ELKPb5e5M,1382
121
+ omdev/tools/rsttool.py,sha256=suwsfseUf8GH8rYmYygTUdif-Jk_bX1g9fYRLXaKkmM,1340
122
122
  omdev/tools/sqlrepl.py,sha256=tmFZh80-xsGM62dyQ7_UGLebChrj7IHbIPYBWDJMgVk,5741
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,,
123
+ omdev-0.0.0.dev71.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
124
+ omdev-0.0.0.dev71.dist-info/METADATA,sha256=VH6UCzzi_xZHYEwtNljGTLWxULtJof_DapUs3-tkMgE,1492
125
+ omdev-0.0.0.dev71.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
126
+ omdev-0.0.0.dev71.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
127
+ omdev-0.0.0.dev71.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
128
+ omdev-0.0.0.dev71.dist-info/RECORD,,
omdev/tools/rst.py DELETED
@@ -1,44 +0,0 @@
1
- import argparse
2
- import contextlib
3
- import io
4
- import sys
5
-
6
- import docutils.core
7
-
8
-
9
- def rst2html(rst, report_level=None):
10
- kwargs = {
11
- 'writer_name': 'html',
12
- 'settings_overrides': {
13
- '_disable_config': True,
14
- 'report_level': int(report_level) if report_level else 0,
15
- },
16
- }
17
-
18
- target = io.StringIO()
19
- with contextlib.redirect_stderr(target):
20
- parts = docutils.core.publish_parts(rst, **kwargs) # type: ignore
21
- html = parts['html_body']
22
- warning = target.getvalue().strip()
23
- return html, warning
24
-
25
-
26
- def _main() -> None:
27
- parser = argparse.ArgumentParser()
28
- parser.add_argument('input', nargs='?')
29
- args = parser.parse_args()
30
-
31
- if args.input:
32
- with open(args.input) as f:
33
- src = f.read()
34
- else:
35
- src = sys.stdin.read()
36
-
37
- html, warning = rst2html(src)
38
- if warning:
39
- sys.stderr.write(warning)
40
- print(html)
41
-
42
-
43
- if __name__ == '__main__':
44
- _main()
File without changes