nercone-modern 1.7.0__py3-none-any.whl → 1.8.0__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.
- nercone_modern/__main__.py +11 -13
- nercone_modern/progressbar.py +22 -14
- {nercone_modern-1.7.0.dist-info → nercone_modern-1.8.0.dist-info}/METADATA +2 -2
- nercone_modern-1.8.0.dist-info/RECORD +9 -0
- nercone_modern-1.7.0.dist-info/RECORD +0 -9
- {nercone_modern-1.7.0.dist-info → nercone_modern-1.8.0.dist-info}/WHEEL +0 -0
nercone_modern/__main__.py
CHANGED
|
@@ -10,9 +10,9 @@ import time
|
|
|
10
10
|
from nercone_modern.logging import ModernLogging
|
|
11
11
|
from nercone_modern.progressbar import ModernProgressBar
|
|
12
12
|
|
|
13
|
-
logger0 = ModernLogging("Demo", display_level="DEBUG", show_level=False)
|
|
14
|
-
show_proc = logger0.prompt("Show process name?", default="N", choices=["y", "N"], interrupt_ignore=True) == "
|
|
15
|
-
show_level = logger0.prompt("Show level name?", default="N", choices=["y", "N"], interrupt_ignore=True) == "
|
|
13
|
+
logger0 = ModernLogging("Demo", display_level="DEBUG", show_proc=False, show_level=False)
|
|
14
|
+
show_proc = logger0.prompt("Show process name?", default="N", choices=["y", "N"], interrupt_ignore=True, level_color="magenta") == "y"
|
|
15
|
+
show_level = logger0.prompt("Show level name?", default="N", choices=["y", "N"], interrupt_ignore=True, level_color="magenta") == "y"
|
|
16
16
|
logger1 = ModernLogging("Main", display_level="DEBUG", show_proc=show_proc, show_level=show_level)
|
|
17
17
|
logger2 = ModernLogging("Sub", display_level="DEBUG", show_proc=show_proc, show_level=show_level)
|
|
18
18
|
|
|
@@ -31,26 +31,24 @@ try:
|
|
|
31
31
|
raise SystemExit(0)
|
|
32
32
|
|
|
33
33
|
progress_bar1 = ModernProgressBar(total=100, process_name="Task 1", spinner_mode=False)
|
|
34
|
-
progress_bar1.setMessage("
|
|
35
|
-
progress_bar2 = ModernProgressBar(total=
|
|
36
|
-
progress_bar2.setMessage("
|
|
34
|
+
progress_bar1.setMessage("Waiting...")
|
|
35
|
+
progress_bar2 = ModernProgressBar(total=1, process_name="Task 2", spinner_mode=True)
|
|
36
|
+
progress_bar2.setMessage("Waiting...")
|
|
37
37
|
|
|
38
38
|
progress_bar1.start()
|
|
39
39
|
progress_bar2.start()
|
|
40
40
|
|
|
41
|
-
progress_bar1.setMessage("
|
|
41
|
+
progress_bar1.setMessage("Running...")
|
|
42
42
|
for i in range(100):
|
|
43
43
|
time.sleep(0.05)
|
|
44
44
|
progress_bar1.update()
|
|
45
|
-
progress_bar1.setMessage("
|
|
45
|
+
progress_bar1.setMessage("Done!")
|
|
46
46
|
progress_bar1.finish()
|
|
47
47
|
|
|
48
48
|
progress_bar2.spin_start()
|
|
49
|
-
progress_bar2.setMessage("
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
progress_bar2.update(2)
|
|
53
|
-
progress_bar2.setMessage("DONE")
|
|
49
|
+
progress_bar2.setMessage("Running with Spinner Mode...")
|
|
50
|
+
time.sleep(10)
|
|
51
|
+
progress_bar2.setMessage("Done!")
|
|
54
52
|
progress_bar2.finish()
|
|
55
53
|
except KeyboardInterrupt:
|
|
56
54
|
print()
|
nercone_modern/progressbar.py
CHANGED
|
@@ -16,12 +16,13 @@ class ModernProgressBar:
|
|
|
16
16
|
_last_rendered = False
|
|
17
17
|
_lock = threading.RLock()
|
|
18
18
|
|
|
19
|
-
def __init__(self, total: int, process_name: str, spinner_mode: bool = False, primary_color: str = "blue", secondary_color: str = "
|
|
19
|
+
def __init__(self, total: int, process_name: str, spinner_mode: bool = False, primary_color: str = "blue", secondary_color: str = "white", box_color: str = "blue", box_left: str = "[", box_right: str = "]"):
|
|
20
20
|
self.total = total
|
|
21
21
|
self.process_name = process_name.strip()
|
|
22
22
|
self.spinner_mode = spinner_mode
|
|
23
23
|
self.primary_color = primary_color
|
|
24
24
|
self.secondary_color = secondary_color
|
|
25
|
+
self.box_color = box_color
|
|
25
26
|
self.box_left = box_left
|
|
26
27
|
self.box_right = box_right
|
|
27
28
|
self.current = 0
|
|
@@ -30,7 +31,7 @@ class ModernProgressBar:
|
|
|
30
31
|
self.log_lines = 0
|
|
31
32
|
self.step = 0
|
|
32
33
|
self.spinner_step = 0
|
|
33
|
-
self.message = "No
|
|
34
|
+
self.message = "No message"
|
|
34
35
|
self._spinner_thread = None
|
|
35
36
|
self._spinner_stop_event = threading.Event()
|
|
36
37
|
self._spinner_ready = False
|
|
@@ -127,14 +128,24 @@ class ModernProgressBar:
|
|
|
127
128
|
bar = self._progress_bar(progress, advance_spinner=advance_spinner and self._should_spin())
|
|
128
129
|
percentage_value = int(round(min(max(progress, 0), 1) * 100))
|
|
129
130
|
percentage = f"{percentage_value:3d}%"
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
if self.current == self.total:
|
|
132
|
+
percentage = "DONE"
|
|
133
|
+
percentage_alt = " "
|
|
134
|
+
if self.spinner_mode:
|
|
135
|
+
if self._should_spin():
|
|
136
|
+
percentage_alt = "RUNN"
|
|
137
|
+
else:
|
|
138
|
+
percentage_alt = "WAIT"
|
|
139
|
+
name_width = max(len(bar.process_name) for bar in ModernProgressBar._active_bars) if ModernProgressBar._active_bars else len(self.process_name)
|
|
140
|
+
proc_name = f"{self.process_name:<{name_width}}"
|
|
141
|
+
total_width = max(len(str(bar.total)) for bar in ModernProgressBar._active_bars) if ModernProgressBar._active_bars else max(len(str(self.total)), 1)
|
|
142
|
+
status = ""
|
|
143
|
+
if not (final or (self.spinner_mode and self._spinner_ready)):
|
|
144
|
+
if self.spinner_mode:
|
|
145
|
+
status = f"{self.box_left}{' ' * total_width}/{' ' * total_width}{self.box_right} "
|
|
146
|
+
else:
|
|
147
|
+
status = f"{self.box_left}{self.current:>{total_width}}/{self.total}{self.box_right} "
|
|
148
|
+
line = f"{ModernColor.color(self.box_color)}{self.box_left}{ModernColor.color('reset')}{ModernColor.color('gray')}{bar}{ModernColor.color('reset')}{ModernColor.color(self.box_color)}{self.box_right}{ModernColor.color('reset')} {ModernColor.color(self.primary_color)}{proc_name}{ModernColor.color('reset')} {percentage_alt if self.spinner_mode else percentage} {status}{ModernColor.color(self.primary_color)}|{ModernColor.color('reset')} {self.message}"
|
|
138
149
|
total_move_up = self.log_lines + (len(ModernProgressBar._active_bars) - self.index)
|
|
139
150
|
if total_move_up > 0:
|
|
140
151
|
sys.stdout.write(f"\033[{total_move_up}A")
|
|
@@ -158,10 +169,7 @@ class ModernProgressBar:
|
|
|
158
169
|
filled_bar = "-"
|
|
159
170
|
if self.current <= 0 and not self._spinner_ready:
|
|
160
171
|
return f"{ModernColor.color('gray')}{empty_bar * (bar_length + 1)}"
|
|
161
|
-
|
|
162
|
-
filled_length = int(progress * bar_length) + 1
|
|
163
|
-
else:
|
|
164
|
-
filled_length = int(progress * bar_length)
|
|
172
|
+
filled_length = int(progress * bar_length) + 1
|
|
165
173
|
return f"{ModernColor.color(self.primary_color)}{filled_bar * filled_length}{ModernColor.color(self.secondary_color)}{center_bar}{ModernColor.color('gray')}{empty_bar * (bar_length - filled_length)}"
|
|
166
174
|
else:
|
|
167
175
|
if self.current <= 0 and not self._spinner_ready:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: nercone-modern
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.0
|
|
4
4
|
Summary: Modern CLI Library
|
|
5
5
|
Author: Nercone
|
|
6
6
|
Author-email: Nercone <nercone@diamondgotcat.net>
|
|
@@ -13,7 +13,7 @@ Project-URL: Homepage, https://github.com/DiamondGotCat/nercone-modern
|
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
<img width="1920" alt="nercone_modern" src="https://github.com/user-attachments/assets/
|
|
16
|
+
<img width="1920" alt="nercone_modern" src="https://github.com/user-attachments/assets/58bbaeef-ad81-4105-a5ed-a64d29d91e2c" />
|
|
17
17
|
|
|
18
18
|
# nercone-modern
|
|
19
19
|
Modern CLI Library
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
nercone_modern/__init__.py,sha256=ArF3T8FdWIhwGcL4MfYcHqMse3n5gjuyzbLNlcqRcxs,443
|
|
2
|
+
nercone_modern/__main__.py,sha256=tiCwzvs4N0J9_vFoA7eaQqkSIhVcDxUQ9uLPNeSQVWo,2475
|
|
3
|
+
nercone_modern/color.py,sha256=e2P9WXeGosHLCAasdE7IQW29GPZOVDMLsUCsLj6hBkM,1268
|
|
4
|
+
nercone_modern/logging.py,sha256=61ixjR37-ewS1RUwnNZnkNGQEBazhiSJJv5g-rLq834,10158
|
|
5
|
+
nercone_modern/progressbar.py,sha256=ohfLTOVPUD9LyvF5AcxtlLqXs0uYO3gUGL9ii8RkZ7E,8504
|
|
6
|
+
nercone_modern/text.py,sha256=eGxGQOJ3b-783ocLibkG62cOcYD4HLG_3diA52tU8jI,1031
|
|
7
|
+
nercone_modern-1.8.0.dist-info/WHEEL,sha256=w4ZtLaDgMAZW2MMZZwtH8zENekoQYBCeullI-zsXJQk,78
|
|
8
|
+
nercone_modern-1.8.0.dist-info/METADATA,sha256=lJcU9MrME8qmxGj6nPrpUEa-nikXdpOp5AvGhwYjISA,6127
|
|
9
|
+
nercone_modern-1.8.0.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
nercone_modern/__init__.py,sha256=ArF3T8FdWIhwGcL4MfYcHqMse3n5gjuyzbLNlcqRcxs,443
|
|
2
|
-
nercone_modern/__main__.py,sha256=5XLj1f0jTdi1IhDq79gXCQeGDIBLAkW4b_PzK9B4zj8,2458
|
|
3
|
-
nercone_modern/color.py,sha256=e2P9WXeGosHLCAasdE7IQW29GPZOVDMLsUCsLj6hBkM,1268
|
|
4
|
-
nercone_modern/logging.py,sha256=61ixjR37-ewS1RUwnNZnkNGQEBazhiSJJv5g-rLq834,10158
|
|
5
|
-
nercone_modern/progressbar.py,sha256=QaDqfxa9XUmI3kfw7ueuRHwylAZGm-L3d7sG7PzV1tE,7782
|
|
6
|
-
nercone_modern/text.py,sha256=eGxGQOJ3b-783ocLibkG62cOcYD4HLG_3diA52tU8jI,1031
|
|
7
|
-
nercone_modern-1.7.0.dist-info/WHEEL,sha256=w4ZtLaDgMAZW2MMZZwtH8zENekoQYBCeullI-zsXJQk,78
|
|
8
|
-
nercone_modern-1.7.0.dist-info/METADATA,sha256=mYxhpUMYgG2N9Fu2XcSudMC3rp7HQt8zwf10BLxKIr4,6127
|
|
9
|
-
nercone_modern-1.7.0.dist-info/RECORD,,
|
|
File without changes
|