Skip to content

Commit 0eaa54e

Browse files
committed
Fix crash when Input folder is empty
1 parent 2fe87c9 commit 0eaa54e

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

Python/convert_all.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def convert_all(progress_bar):
2121
output_folder_path = Path(sg.user_settings_get_entry("cccp_folder")) / "Mods"
2222

2323
mod_count = len(list(get_input_mod_paths(input_folder_path)))
24+
2425
progress_bar.segment(mod_count)
26+
2527
for i, input_mod_path in enumerate(get_input_mod_paths(input_folder_path)):
2628
progress_bar.setTitle(
2729
f"Converting {input_mod_path.stem}{input_mod_path.suffix} ({i+1}/{mod_count})...\t"

Python/progress_bar.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ class InvalidSegmentCount(Exception):
33

44

55
class Segment:
6-
76
# cur = current ind of seg, max = seg count
87
# step = step size per seg, prev = progress when segs created
98
def __init__(self, cur, max, step, prev):
@@ -14,7 +13,6 @@ def __init__(self, cur, max, step, prev):
1413

1514

1615
class ProgressBar:
17-
1816
data = []
1917
cur_segment = None
2018
title = ""
@@ -26,14 +24,13 @@ def __init__(self, progress_bar, progress_bar_text=None):
2624
self.text = progress_bar_text
2725

2826
def segment(self, count):
29-
if count <= 0:
30-
raise InvalidSegmentCount("You must have at least one segment!")
3127
if len(self.data) == 0:
3228
self.cur_segment = Segment(0, count, 1, 0)
3329
self.pbar.update(max=count, current_count=0)
3430
else:
35-
s = self.cur_segment
36-
self.cur_segment = Segment(0, count, s.step / count, self.progress)
31+
self.cur_segment = Segment(
32+
0, count, self.cur_segment.step / count, self.progress
33+
)
3734

3835
self.updateText()
3936
self.data.append(self.cur_segment)

0 commit comments

Comments
 (0)