pup-py commited on
Commit
e1bb57e
·
1 Parent(s): 429a715

file browser minimal

Browse files
Files changed (2) hide show
  1. nb/prod_files.py +53 -2
  2. nb/prod_marimo.py +2 -0
nb/prod_files.py CHANGED
@@ -1,15 +1,66 @@
1
  import marimo
2
 
3
- __generated_with = "0.18.4"
4
  app = marimo.App(width="full", app_title="🎁 Files")
5
 
6
 
7
  @app.cell
8
  def _():
 
 
9
  import marimo as mo
 
 
 
 
 
 
 
 
 
 
10
  from src.marimo_apps import UI
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- return UI, mo
 
 
 
 
 
13
 
14
 
15
  @app.cell
 
1
  import marimo
2
 
3
+ __generated_with = "0.19.7"
4
  app = marimo.App(width="full", app_title="🎁 Files")
5
 
6
 
7
  @app.cell
8
  def _():
9
+ from datetime import datetime
10
+ from pathlib import Path
11
  import marimo as mo
12
+ import sys
13
+
14
+ ROOT = Path(__file__).parent.parent
15
+ sys.path.append(ROOT.as_posix())
16
+ return Path, datetime, mo
17
+
18
+
19
+ @app.cell
20
+ def _():
21
+ # internal imports
22
  from src.marimo_apps import UI
23
+ return (UI,)
24
+
25
+
26
+ @app.cell
27
+ def _():
28
+ return
29
+
30
+
31
+ @app.cell
32
+ def _(Path, datetime, mo):
33
+ class FileManager:
34
+ def __init__(self, root_path: Path):
35
+ self.root_path = root_path
36
+ self.current_path = root_path
37
+ self.get_files()
38
+
39
+ def get_files(self):
40
+ self.files = []
41
+ self.paths = sorted(
42
+ self.current_path.iterdir(),
43
+ key=lambda p: (not p.is_dir(), p.name.lower())
44
+ )
45
+ for p in self.paths:
46
+ stat = p.stat()
47
+ if p.is_dir():
48
+ size = ""
49
+ else:
50
+ size = stat.st_size
51
+ file = {
52
+ "name": p.name,
53
+ "size": size,
54
+ "mtime": datetime.fromtimestamp(stat.st_mtime).strftime("%Y-%m-%d %H:%M:%S"),
55
+ }
56
+ self.files.append(file)
57
 
58
+ def _display_(self):
59
+ return mo.ui.table(self.files, label=f"### {self.current_path}/", pagination=False)
60
+
61
+ fm = FileManager(Path("."))
62
+ fm
63
+ return
64
 
65
 
66
  @app.cell
nb/prod_marimo.py CHANGED
@@ -26,6 +26,8 @@ def _(UI, mo):
26
  - global and private variables
27
  - `mo.stop`
28
  - hack: no tracking mutations
 
 
29
  """)
30
 
31
  mo.hstack([UI.NAV, md], widths=[1, 5])
 
26
  - global and private variables
27
  - `mo.stop`
28
  - hack: no tracking mutations
29
+ 4. Inspect
30
+ 5.
31
  """)
32
 
33
  mo.hstack([UI.NAV, md], widths=[1, 5])