omdev 0.0.0.dev466__py3-none-any.whl → 0.0.0.dev468__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/__about__.py CHANGED
@@ -44,7 +44,7 @@ class Project(ProjectBase):
44
44
 
45
45
  'tui': [
46
46
  'rich ~= 14.2',
47
- 'textual ~= 6.3',
47
+ 'textual ~= 6.4',
48
48
  ],
49
49
  }
50
50
 
@@ -14,8 +14,10 @@ import os
14
14
  import socketserver
15
15
  import sys
16
16
  import threading
17
+ import typing as ta
17
18
  import webbrowser
18
19
 
20
+ from omlish import check
19
21
  from omlish import lang
20
22
 
21
23
 
@@ -69,7 +71,15 @@ HTML_TEMPLATE = """
69
71
  """
70
72
 
71
73
 
72
- def view_json(filepath: str, port: int) -> None:
74
+ def view_json(
75
+ filepath: str,
76
+ port: int,
77
+ *,
78
+ mode: ta.Literal['jsonl', 'json5', 'json', None] = None,
79
+ ) -> None:
80
+ if filepath == '-':
81
+ filepath = '/dev/stdin'
82
+
73
83
  if not os.path.exists(filepath):
74
84
  print(f"Error: File not found at '{filepath}'", file=sys.stderr)
75
85
  return
@@ -81,13 +91,21 @@ def view_json(filepath: str, port: int) -> None:
81
91
  print(f'Error: Invalid JSON file. {e}', file=sys.stderr)
82
92
  return
83
93
 
84
- if filepath.endswith('.jsonl'):
94
+ if mode is None:
95
+ if filepath.endswith('.jsonl'):
96
+ mode = 'json'
97
+ elif filepath.endswith('.json5'):
98
+ mode = 'json5'
99
+
100
+ if mode == 'jsonl':
85
101
  json_content = [json.loads(sl) for l in raw_content.splitlines() if (sl := l.strip())]
86
- elif filepath.endswith('.json5'):
102
+ elif mode == 'json5':
87
103
  from omlish.formats import json5
88
104
  json_content = json5.loads(raw_content)
89
- else:
105
+ elif mode in ('json', None):
90
106
  json_content = json.loads(raw_content)
107
+ else:
108
+ raise ValueError(mode)
91
109
 
92
110
  # Use compact dumps for embedding in JS, it's more efficient
93
111
  json_string = json.dumps(json_content)
@@ -142,9 +160,17 @@ def _main() -> None:
142
160
  default=(default_port := 8999),
143
161
  help=f'The port to run the web server on. Defaults to {default_port}.',
144
162
  )
163
+ parser.add_argument('-l', '--lines', action='store_true')
164
+ parser.add_argument('-5', '--five', action='store_true')
145
165
  args = parser.parse_args()
146
166
 
147
- view_json(args.filepath, args.port)
167
+ check.state(not (args.lines and args.five))
168
+
169
+ view_json(
170
+ args.filepath,
171
+ args.port,
172
+ mode='jsonl' if args.lines else 'json5' if args.five else None,
173
+ )
148
174
 
149
175
 
150
176
  if __name__ == '__main__':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: omdev
3
- Version: 0.0.0.dev466
3
+ Version: 0.0.0.dev468
4
4
  Summary: omdev
5
5
  Author: wrmsr
6
6
  License-Expression: BSD-3-Clause
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.13
14
14
  Requires-Python: >=3.13
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
- Requires-Dist: omlish==0.0.0.dev466
17
+ Requires-Dist: omlish==0.0.0.dev468
18
18
  Provides-Extra: all
19
19
  Requires-Dist: black~=25.9; extra == "all"
20
20
  Requires-Dist: pycparser~=2.23; extra == "all"
@@ -27,7 +27,7 @@ Requires-Dist: mypy~=1.18; extra == "all"
27
27
  Requires-Dist: gprof2dot~=2025.4; extra == "all"
28
28
  Requires-Dist: segno~=1.6; extra == "all"
29
29
  Requires-Dist: rich~=14.2; extra == "all"
30
- Requires-Dist: textual~=6.3; extra == "all"
30
+ Requires-Dist: textual~=6.4; extra == "all"
31
31
  Provides-Extra: black
32
32
  Requires-Dist: black~=25.9; extra == "black"
33
33
  Provides-Extra: c
@@ -46,7 +46,7 @@ Provides-Extra: qr
46
46
  Requires-Dist: segno~=1.6; extra == "qr"
47
47
  Provides-Extra: tui
48
48
  Requires-Dist: rich~=14.2; extra == "tui"
49
- Requires-Dist: textual~=6.3; extra == "tui"
49
+ Requires-Dist: textual~=6.4; extra == "tui"
50
50
  Dynamic: license-file
51
51
 
52
52
  # Overview
@@ -1,5 +1,5 @@
1
1
  omdev/.omlish-manifests.json,sha256=cMWrMB14_AFp9mQiTEeoTYL1uaC3zq7ER7-XHGCXY8I,11671
2
- omdev/__about__.py,sha256=9oG5_aX1pKiZ-pxcYppjvatDSNyKOwEcT5zG7-H_bSY,1236
2
+ omdev/__about__.py,sha256=4LCYNbYuwflVqzyblLDjjNuSJso6Ot0pG6st2WCqY9E,1236
3
3
  omdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  omdev/cmake.py,sha256=gu49t10_syXh_TUJs4POsxeFs8we8Y3XTOOPgIXmGvg,4608
5
5
  omdev/imgur.py,sha256=oqei705LhSnLWQTOMHMHwRecRXcpSEP90Sg4SVINPQ0,3133
@@ -326,7 +326,7 @@ omdev/tools/json/processing.py,sha256=sSfL6iMB7Znp5ntAFeXYCog0GLA49dPfvoXRoG0D_A
326
326
  omdev/tools/json/rendering.py,sha256=dsZki-47lPuYP_-x7gFFl57IZnCJUXHS-NBGpQZjvk0,2628
327
327
  omdev/tools/jsonview/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
328
328
  omdev/tools/jsonview/__main__.py,sha256=BF-MVWpPJJeQYUqJA48G395kxw0lEJnV-hRLV_F9G2A,173
329
- omdev/tools/jsonview/cli.py,sha256=8pHULS_xxDV00kM8bO5dLH7i-zqQIoNjXTKFwhxSZ_A,4245
329
+ omdev/tools/jsonview/cli.py,sha256=iSuL9Q6oa-56-slpsbhUo8gba_tWWo06_sOgQJmg3BE,4906
330
330
  omdev/tools/jsonview/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
331
331
  omdev/tools/jsonview/resources/jsonview.css,sha256=RqQMm98EnQkbVM-8BgjNduzUfsVDMzgNC_NjjwG0bqI,579
332
332
  omdev/tools/jsonview/resources/jsonview.js,sha256=faDvXDOXKvEvjOuIlz4D3F2ReQXb_buXDU27hKuuqAw,1648
@@ -355,9 +355,9 @@ omdev/tui/textual/autocomplete/__init__.py,sha256=m0EGewct7SoATrTcsCSmeRQyPucP5S
355
355
  omdev/tui/textual/autocomplete/matching.py,sha256=joxUxF4jfs47E4JK0DAo_l0lwoNe9mU6iJzxI2FlVYI,6801
356
356
  omdev/tui/textual/autocomplete/paths.py,sha256=Z3ZlTkPZezKBaFgB23d6IFJXanJc8OueBm-S0kExdRM,7242
357
357
  omdev/tui/textual/autocomplete/widget.py,sha256=1UgWqDT0d9wD6w7MNaZBjgj0o9FohYXydifocPErdks,22629
358
- omdev-0.0.0.dev466.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
359
- omdev-0.0.0.dev466.dist-info/METADATA,sha256=9LF_k7bpTn2d6uPl66XkrLdvGU0tND7YXUkY7XZttMk,5170
360
- omdev-0.0.0.dev466.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
361
- omdev-0.0.0.dev466.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
362
- omdev-0.0.0.dev466.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
363
- omdev-0.0.0.dev466.dist-info/RECORD,,
358
+ omdev-0.0.0.dev468.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
359
+ omdev-0.0.0.dev468.dist-info/METADATA,sha256=7yARZjBZ-geufgap6OxhPUUXX4uCTeESTgIdncPktow,5170
360
+ omdev-0.0.0.dev468.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
361
+ omdev-0.0.0.dev468.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
362
+ omdev-0.0.0.dev468.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
363
+ omdev-0.0.0.dev468.dist-info/RECORD,,