Skip to content

Commit daf49c8

Browse files
committed
feat: Add Config class for centralized settings and improve �uild.py's config file encoding and error handling.
1 parent 54dc120 commit daf49c8

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

build.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,18 @@ def update_config_debug_mode(debug_mode):
9090
"""Updates config.ini to match the current build mode."""
9191
# We read the config to preserve other settings, but force debug_mode
9292
config = configparser.ConfigParser()
93-
config.read(CONFIG_FILES)
93+
94+
# Manually read to handle potential BOM (Byte Order Mark) issues
95+
read_success = False
96+
for cfg in CONFIG_FILES:
97+
if os.path.exists(cfg):
98+
try:
99+
with open(cfg, 'r', encoding='utf-8-sig') as f:
100+
config.read_file(f)
101+
read_success = True
102+
break
103+
except Exception as e:
104+
print(f"Warning: Could not read {cfg}: {e}")
94105

95106
# Ensure sections exist
96107
if not config.has_section('General'):
@@ -106,7 +117,7 @@ def update_config_debug_mode(debug_mode):
106117
# Write back
107118
# We pick the first available config file to write to, usually config.ini
108119
target_cfg = CONFIG_FILES[0]
109-
with open(target_cfg, 'w') as f:
120+
with open(target_cfg, 'w', encoding='utf-8') as f:
110121
config.write(f)
111122

112123
def run_build_cycle(debug_mode):

core/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class Config:
3131
FADE_RANGE = 200 # Distance over which it fades to 0 opacity
3232

3333
# Debugging
34-
DEBUG_MODE = True
34+
DEBUG_MODE = False
3535

3636
# Colors (R, G, B, A)
3737
COLOR_BAR = QColor(100, 200, 255, 200)
3838
COLOR_BAR_BORDER = QColor(255, 255, 255, 230)
3939
COLOR_DEBUG_TEXT = QColor(0, 255, 0, 255)
4040

41-
VERSION = "1.1.1"
41+
VERSION = "1.2.0"

0 commit comments

Comments
 (0)