Delete test-colors path in any case + small refactors.

Less indents and more logging.

part of CURA-12469
This commit is contained in:
Remco Burema 2025-03-25 08:46:12 +01:00
parent 2b032af13c
commit fa8e4b26cf

View File

@ -566,22 +566,27 @@ class CuraConan(ConanFile):
def _make_internal_distinct(self): def _make_internal_distinct(self):
test_colors_path = Path(self.source_folder, "resources", "themes", "daily_test_colors.json") test_colors_path = Path(self.source_folder, "resources", "themes", "daily_test_colors.json")
if not test_colors_path.exists():
print(f"Could not find '{str(test_colors_path)}'. Won't generate rotating colors for alpha builds.")
return
if "alpha" in self.version: if "alpha" in self.version:
biweekly_day = (datetime.now() - datetime(2025, 3, 14)).days biweekly_day = (datetime.now() - datetime(2025, 3, 14)).days
with test_colors_path.open("r") as test_colors_file: with test_colors_path.open("r") as test_colors_file:
test_colors = json.load(test_colors_file) test_colors = json.load(test_colors_file)
for theme_dir in Path(self.source_folder, "resources", "themes").iterdir(): for theme_dir in Path(self.source_folder, "resources", "themes").iterdir():
if theme_dir.is_dir(): if not theme_dir.is_dir():
theme_path = Path(theme_dir, "theme.json") continue
if theme_path.exists(): theme_path = Path(theme_dir, "theme.json")
with theme_path.open("r") as theme_file: if not theme_path.exists():
theme = json.load(theme_file) print(f"('Colorize-by-day' alpha builds): Skipping {str(theme_path)}, could not find file.")
if theme["colors"]: continue
theme["colors"]["main_window_header_background"] = test_colors[biweekly_day] with theme_path.open("r") as theme_file:
with theme_path.open("w") as theme_file: theme = json.load(theme_file)
json.dump(theme, theme_file) if theme["colors"]:
elif test_colors_path.exists(): theme["colors"]["main_window_header_background"] = test_colors[biweekly_day]
test_colors_path.unlink() with theme_path.open("w") as theme_file:
json.dump(theme, theme_file)
test_colors_path.unlink()
def generate(self): def generate(self):
copy(self, "cura_app.py", self.source_folder, str(self._script_dir)) copy(self, "cura_app.py", self.source_folder, str(self._script_dir))