omdev 0.0.0.dev92__py3-none-any.whl → 0.0.0.dev93__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
@@ -119,6 +119,18 @@
119
119
  }
120
120
  }
121
121
  },
122
+ {
123
+ "module": ".prompttoolkit.apps.ncdu",
124
+ "attr": "_CLI_MODULE",
125
+ "file": "omdev/prompttoolkit/apps/ncdu.py",
126
+ "line": 157,
127
+ "value": {
128
+ "$.cli.types.CliModule": {
129
+ "cmd_name": "ptk/ncdu",
130
+ "mod_name": "omdev.prompttoolkit.apps.ncdu"
131
+ }
132
+ }
133
+ },
122
134
  {
123
135
  "module": ".pyproject.__main__",
124
136
  "attr": "_CLI_MODULE",
@@ -2,6 +2,7 @@
2
2
  # flake8: noqa: F401
3
3
 
4
4
  from prompt_toolkit import Application
5
+ from prompt_toolkit.filters import to_filter
5
6
  from prompt_toolkit.key_binding import KeyBindings
6
7
  from prompt_toolkit.key_binding import KeyPressEvent
7
8
  from prompt_toolkit.layout import Layout
@@ -1,3 +1,7 @@
1
+ """
2
+ TODO:
3
+ - reuse dir sizes lol
4
+ """
1
5
  import dataclasses as dc
2
6
  import os
3
7
  import typing as ta
@@ -5,6 +9,7 @@ import typing as ta
5
9
  from omlish.lite.strings import format_num_bytes
6
10
 
7
11
  from ... import prompttoolkit as ptk
12
+ from ...cli import CliModule
8
13
 
9
14
 
10
15
  def get_directory_size(path: str) -> int:
@@ -49,10 +54,17 @@ class NcduApp:
49
54
 
50
55
  self._root_path = root_path
51
56
  self._current_path = root_path
52
- self._entries = scan_directory(root_path)
57
+
58
+ self._entries_by_path: dict[str, list[Entry]] = {}
59
+ self._entries = self._get_entries(root_path)
60
+
53
61
  self._cursor = 0
54
62
 
55
- self._text_area = ptk.TextArea(focusable=True)
63
+ self._text_area = ptk.TextArea(
64
+ read_only=True,
65
+ )
66
+ self._text_area.window.always_hide_cursor = ptk.to_filter(True)
67
+
56
68
  self.update_display()
57
69
 
58
70
  self._kb = ptk.KeyBindings()
@@ -78,6 +90,14 @@ class NcduApp:
78
90
  full_screen=True,
79
91
  )
80
92
 
93
+ def _get_entries(self, path: str) -> list[Entry]:
94
+ try:
95
+ return self._entries_by_path[path]
96
+ except KeyError:
97
+ pass
98
+ entries = self._entries_by_path[path] = scan_directory(path)
99
+ return entries
100
+
81
101
  #
82
102
 
83
103
  def update_display(self) -> None:
@@ -103,14 +123,14 @@ class NcduApp:
103
123
  selected_entry = self._entries[self._cursor]
104
124
  if selected_entry.type == 'dir':
105
125
  self._current_path = os.path.join(self._current_path, selected_entry.name[:-1])
106
- self._entries = scan_directory(self._current_path)
126
+ self._entries = self._get_entries(self._current_path)
107
127
  self._cursor = 0
108
128
  self.update_display()
109
129
 
110
130
  def go_back(self, event: ptk.KeyPressEvent) -> None:
111
131
  if self._current_path != self._root_path:
112
132
  self._current_path = os.path.dirname(self._current_path)
113
- self._entries = scan_directory(self._current_path)
133
+ self._entries = self._get_entries(self._current_path)
114
134
  self._cursor = 0
115
135
  self.update_display()
116
136
 
@@ -127,14 +147,16 @@ def _main() -> None:
127
147
  import argparse
128
148
 
129
149
  parser = argparse.ArgumentParser()
130
-
131
150
  parser.add_argument('dir', default='.', nargs='?')
132
-
133
151
  args = parser.parse_args()
134
152
 
135
153
  ncdu_app = NcduApp(args.dir)
136
154
  ncdu_app.run()
137
155
 
138
156
 
157
+ # @omlish-manifest
158
+ _CLI_MODULE = CliModule('ptk/ncdu', __name__)
159
+
160
+
139
161
  if __name__ == '__main__':
140
162
  _main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omdev
3
- Version: 0.0.0.dev92
3
+ Version: 0.0.0.dev93
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.dev92
15
+ Requires-Dist: omlish ==0.0.0.dev93
16
16
  Provides-Extra: all
17
17
  Requires-Dist: black ~=24.10 ; extra == 'all'
18
18
  Requires-Dist: pycparser ~=2.22 ; extra == 'all'
@@ -1,4 +1,4 @@
1
- omdev/.manifests.json,sha256=juVlULcmZOz0t66Qf-GhpG_-4NGQU0XDmd7EjaRygxk,6257
1
+ omdev/.manifests.json,sha256=gV7IN6_fyHuAMPPFoFWS652RyoQ5K2ctUS3P4hVo7Mo,6546
2
2
  omdev/__about__.py,sha256=5MidJkdjpvZISIof4d7vMN7HhC7h5aUfl-FL0IpbY0A,1207
3
3
  omdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  omdev/bracepy.py,sha256=I8EdqtDvxzAi3I8TuMEW-RBfwXfqKbwp06CfOdj3L1o,2743
@@ -98,9 +98,9 @@ omdev/precheck/lite.py,sha256=d8D-BY-Z0rqQigQ_aR9QXxdB3EBCHJc7WgBJngGiEiE,3871
98
98
  omdev/precheck/main.py,sha256=2YizDZSDhMeQaZKVH83s99pBmtOUL9B-8dXwIcw6fQQ,2674
99
99
  omdev/precheck/manifests.py,sha256=YfXqt6u0hlFXY0QkBMec6V_6Y9T4eCVAmrJDkQkB13U,774
100
100
  omdev/precheck/scripts.py,sha256=qq6MXkxgrYngPg5pWnXH4uRSuRkP3mFqbeml1UmvGBc,1265
101
- omdev/prompttoolkit/__init__.py,sha256=C4pFxNoIVo7cOH_jZ7-ruaYYd6DxEvuJr5ZGDrMFwXo,402
101
+ omdev/prompttoolkit/__init__.py,sha256=StAwXQ96e8Xkkg7ciR9oBBhcSgqHT76vhoZML82BuY0,447
102
102
  omdev/prompttoolkit/apps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
103
- omdev/prompttoolkit/apps/ncdu.py,sha256=V2jZ-h3HN23KC5FB5gFjeMVZZbj-2j6zxyMca3O8OM0,3950
103
+ omdev/prompttoolkit/apps/ncdu.py,sha256=FbQf2IQVPWxyyxukfsTkgqmUGKAa_9hEjDyl0GHb7s0,4496
104
104
  omdev/pyproject/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
105
105
  omdev/pyproject/__main__.py,sha256=gn3Rl1aYPYdiTtEqa9ifi0t-e4ZwPY0vhJ4UXvYdJDY,165
106
106
  omdev/pyproject/cexts.py,sha256=x13piOOnNrYbA17qZLDVuR0p1sqhgEwpk4FtImX-klM,4281
@@ -129,9 +129,9 @@ omdev/tools/piptools.py,sha256=-jR5q3w4sHqntxCLExFCBNIARB788FUsAbJ62PK2sBU,2774
129
129
  omdev/tools/proftools.py,sha256=8ZU9x_Dq8eT2ZFwU9sJpDIvxcIn9qBc8y2ELKPb5e5M,1382
130
130
  omdev/tools/rsttool.py,sha256=suwsfseUf8GH8rYmYygTUdif-Jk_bX1g9fYRLXaKkmM,1340
131
131
  omdev/tools/sqlrepl.py,sha256=tmFZh80-xsGM62dyQ7_UGLebChrj7IHbIPYBWDJMgVk,5741
132
- omdev-0.0.0.dev92.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
133
- omdev-0.0.0.dev92.dist-info/METADATA,sha256=473r1V0N3U0g1TIQ5xaptW6ygcmGv_cYbKqWYIOgSJY,1638
134
- omdev-0.0.0.dev92.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
135
- omdev-0.0.0.dev92.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
136
- omdev-0.0.0.dev92.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
137
- omdev-0.0.0.dev92.dist-info/RECORD,,
132
+ omdev-0.0.0.dev93.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
133
+ omdev-0.0.0.dev93.dist-info/METADATA,sha256=n-9dHJ7N3DsHFpDq4mRbglWuMHjjE5ZkHhvsP-4vVmY,1638
134
+ omdev-0.0.0.dev93.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
135
+ omdev-0.0.0.dev93.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
136
+ omdev-0.0.0.dev93.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
137
+ omdev-0.0.0.dev93.dist-info/RECORD,,