feat(series-studio): initial implementation of unified series studio engine (PDF & DOCX)
This commit is contained in:
commit
03d9922066
20 files changed
+7082
No files matched your search
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
themes.py
|
||||
Gestionnaire des thèmes graphiques pour series-studio.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
THEMES_DIR = os.path.join(os.path.dirname(__file__), "themes")
|
||||
|
||||
def list_themes():
|
||||
"""Renvoie la liste des thèmes disponibles avec métadonnées."""
|
||||
themes = []
|
||||
if not os.path.exists(THEMES_DIR):
|
||||
return themes
|
||||
for fname in sorted(os.listdir(THEMES_DIR)):
|
||||
if fname.endswith(".json"):
|
||||
path = os.path.join(THEMES_DIR, fname)
|
||||
try:
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
themes.append({
|
||||
"name": data.get("name", fname[:-5]),
|
||||
"label": data.get("label", data.get("name", fname[:-5]))
|
||||
})
|
||||
except Exception:
|
||||
pass
|
||||
return themes
|
||||
|
||||
def get_theme(theme_name="classique"):
|
||||
"""Charge les jetons de style d'un thème donné."""
|
||||
if not theme_name:
|
||||
theme_name = "classique"
|
||||
path = os.path.join(THEMES_DIR, f"{theme_name}.json")
|
||||
if not os.path.exists(path):
|
||||
raise ValueError(f"Thème inconnu : '{theme_name}'")
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
Reference in new issue
Block a user