Skip to content

Commit 37d8aa6

Browse files
committed
improved the progressbar & remaingin time logic heavily & elasped time now shows hours
1 parent f693250 commit 37d8aa6

File tree

5 files changed

+36
-27
lines changed

5 files changed

+36
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# PyDVPL Cli Converter
2-
- A Cli Tool Coded In Python3 To Convert WoTB ( Dava ) SmartDLC DVPL File Based On LZ4 Compression.
2+
- A Cli Tool Coded In Python3 To Convert WoTB ( Dava ) SmartDLC DVPL Files Based On LZ4 Compression.
33

44
Package & Module Structure :
55

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "pydvpl"
33
description = "A CLI Tool Coded In Python3 To Convert WoTB ( Dava ) SmartDLC DVPL File Based On LZ4 High Compression."
44
readme = "README.md"
5-
version = "0.8.0"
5+
version = "0.9.0"
66
authors = [{ name = "RifsxD", email = "support@rxd-mods.xyz" }]
77
license = { text = "MIT License" }
88
requires-python = ">=3.10"
@@ -14,6 +14,8 @@ classifiers = [
1414
]
1515
dependencies = [
1616
"lz4>=4.3.3",
17+
"setuptools>=69.2.0",
18+
"requests>=2.31.0"
1719
]
1820

1921
[project.scripts]

src/pydvpl/_pydvpl.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import threading
77
import sys
88
import multiprocessing
9-
import queue
109
from pathlib import Path
1110
from functools import partial
1211

@@ -88,35 +87,39 @@ def brand_ascii():
8887

8988
output_lock = threading.Lock()
9089

91-
# Define a thread-safe queue to store processed files
92-
processed_queue = queue.Queue()
90+
def print_remaining_time(processed_files, total_files, start_time):
91+
elapsed_time = time.time() - start_time
92+
if processed_files.value > 0:
93+
avg_processing_time_per_file = elapsed_time / processed_files.value
94+
remaining_files = total_files - processed_files.value
95+
remaining_time = remaining_files * avg_processing_time_per_file
96+
if remaining_time < 1:
97+
print(f" | Remaining time: {Color.GREEN}{int(remaining_time * 1000)} ms{Color.RESET}", end='')
98+
elif remaining_time < 60:
99+
print(f" | Remaining time: {Color.YELLOW}{int(remaining_time)} s{Color.RESET}", end='')
100+
elif remaining_time < 3600:
101+
print(f" | Remaining time: {Color.ORANGE}{int(remaining_time / 60)} min(s){Color.RESET}\r", end='')
102+
else:
103+
print(f" | Remaining time: {Color.RED}{int(remaining_time / 3600)} hour(s){Color.RESET}", end='')
93104

94105

95106
def print_progress_bar_with_time(processed_files, total_files, start_time):
96107
with output_lock:
97108
progress = min(processed_files.value / total_files, 1.0) # Ensure progress doesn't exceed 100%
98109
bar_length = 50
99110
filled_length = int(bar_length * progress)
100-
bar = '=' * filled_length + '-' * (bar_length - filled_length)
111+
gap_length = 1 # Adjust gap length as needed
112+
if filled_length < bar_length: # If progress is less than 100%
113+
gap_bar = f'{Color.GREY} {Color.RESET}' * gap_length
114+
else:
115+
gap_bar = ''
116+
filled_bar = f'{Color.GREEN}{Color.RESET}' * filled_length
117+
unfilled_bar = f'{Color.GREY}{Color.RESET}' * (bar_length - filled_length - gap_length)
118+
bar = filled_bar + gap_bar + unfilled_bar
101119
percentage = progress * 100
102120
sys.stdout.write('\rProcessing: [{:<50}] {:.2f}%'.format(bar, percentage))
103121
sys.stdout.flush()
104-
105-
# Calculate remaining time
106-
if progress > 0:
107-
elapsed_time = time.time() - start_time
108-
remaining_files = total_files - processed_files.value
109-
if processed_files.value > 0:
110-
avg_time_per_file = elapsed_time / processed_files.value
111-
remaining_time = remaining_files * avg_time_per_file
112-
if remaining_time < 60:
113-
remaining_time_str = f"{int(remaining_time)} s"
114-
elif remaining_time < 3600:
115-
remaining_time_str = f"{int(remaining_time / 60)} min"
116-
else:
117-
remaining_time_str = f"{int(remaining_time / 3600)} h"
118-
sys.stdout.write(f' | Remaining time: {remaining_time_str}')
119-
sys.stdout.flush()
122+
print_remaining_time(processed_files, total_files, start_time)
120123

121124

122125
def count_total_files(directory):
@@ -298,14 +301,14 @@ def process_mode(directory_or_file, config):
298301

299302
def confirm_upgrade():
300303
while True:
301-
user_input = input("Are you sure you want to upgrade pydvpl? (y, yes / n, no): ").strip().lower()
304+
user_input = input("Are you sure you want to upgrade pydvpl? 'yes' (y) or 'no' (n): ").strip().lower()
302305
if user_input in ['yes', 'y']:
303306
return True
304307
elif user_input in ['no', 'n']:
305308
return False
306309
else:
307310
print("Invalid input. Please enter 'yes' (y) or 'no' (n).")
308-
sys.exit(1) # Exit the script if invalid input is provided
311+
sys.exit(1)
309312

310313

311314

@@ -433,8 +436,10 @@ def print_elapsed_time(elapsed_time):
433436
print(f"\nProcessing took {Color.GREEN}{int(elapsed_time * 1000)} ms{Color.RESET}\n")
434437
elif elapsed_time < 60:
435438
print(f"\nProcessing took {Color.YELLOW}{int(elapsed_time)} s{Color.RESET}\n")
439+
elif elapsed_time < 3600:
440+
print(f"\nProcessing took {Color.ORANGE}{int(elapsed_time / 60)} min(s){Color.RESET}\n")
436441
else:
437-
print(f"\nProcessing took {Color.RED}{int(elapsed_time / 60)} min{Color.RESET}\n")
442+
print(f"\nProcessing took {Color.RED}{int(elapsed_time / 3600)} hour(s){Color.RESET}\n")
438443

439444

440445
def cli():

src/pydvpl/color/_color.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ class Color:
33
GREEN = '\033[32m'
44
BLUE = '\033[34m'
55
YELLOW = '\033[33m'
6+
GREY = '\033[90m'
7+
ORANGE = '\033[38;5;208m'
68
RESET = '\033[0m'

src/pydvpl/version/_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__title__ = "PyDVPL"
2-
__description__ = "A CLI Tool Coded In Python3 To Convert WoTB ( Dava ) SmartDLC DVPL File Based On LZ4 Compression."
3-
__version__ = "0.8.0"
2+
__description__ = "A CLI Tool Coded In Python3 To Convert WoTB ( Dava ) SmartDLC DVPL Files Based On LZ4 Compression."
3+
__version__ = "0.9.0"
44
__author__ = "RifsxD"
55
__repo__ = "https://github.com/rifsxd/pydvpl"
66
__license__ = "MIT"

0 commit comments

Comments
 (0)