Skip to content

Commit 92344f5

Browse files
author
PyCompiler ARK++
committed
bcasl yml -only
1 parent 4414622 commit 92344f5

1 file changed

Lines changed: 19 additions & 20 deletions

File tree

bcasl/Loader.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
BCASL loader (simplifié)
1919
2020
Objectifs de simplification:
21-
- Config YAML uniquement (bcasl.yaml ou bcasl.yml) - YAML ONLY, NO JSON
21+
- Config YML uniquement (bcasl.yml ou .bcasl.yml) - YML ONLY, NO YAML, NO JSON
2222
- Détection de plugins minimale: packages dans Plugins/ ayant __init__.py
2323
- Ordre: plugin_order depuis config sinon basé sur tags simples, sinon alphabétique
2424
- UI minimale pour activer/désactiver et réordonner (pas d'éditeur brut multi-format)
@@ -28,7 +28,6 @@
2828
"""
2929
from __future__ import annotations
3030

31-
import json
3231
import os
3332
from pathlib import Path
3433
from typing import Any, Optional
@@ -142,24 +141,24 @@ def _discover_bcasl_meta(api_dir: Path) -> dict[str, dict[str, Any]]:
142141

143142

144143
def _load_workspace_config(workspace_root: Path) -> dict[str, Any]:
145-
"""Charge bcasl.yaml ou bcasl.yml si présent, sinon génère une config par défaut minimale et l'écrit.
144+
"""Charge bcasl.yml si présent, sinon génère une config par défaut minimale et l'écrit.
146145
147146
Fusionne aussi avec ARK_Main_Config.yml si disponible pour les patterns et options plugins.
148-
YAML ONLY - JSON files are NOT supported.
147+
YML ONLY - YAML and JSON files are NOT supported.
149148
"""
150149

151-
def _read_yaml(p: Path) -> dict[str, Any]:
150+
def _read_yml(p: Path) -> dict[str, Any]:
152151
try:
153152
return yaml.safe_load(p.read_text(encoding="utf-8")) or {}
154153
except Exception:
155154
return {}
156155

157-
# 1) Fichiers candidats (YAML uniquement - NO JSON)
158-
# Priorité: bcasl.yaml > bcasl.yml > .bcasl.yaml > .bcasl.yml
159-
for name in ("bcasl.yaml", "bcasl.yml", ".bcasl.yaml", ".bcasl.yml"):
156+
# 1) Fichiers candidats (YML uniquement - NO YAML, NO JSON)
157+
# Priorité: bcasl.yml > .bcasl.yml
158+
for name in ("bcasl.yml", ".bcasl.yml"):
160159
p = workspace_root / name
161160
if p.exists() and p.is_file():
162-
data = _read_yaml(p)
161+
data = _read_yml(p)
163162

164163
if isinstance(data, dict) and data:
165164
# Fusionner avec ARK_Main_Config.yml si disponible
@@ -274,11 +273,11 @@ def _read_yaml(p: Path) -> dict[str, Any]:
274273
"plugins": detected_plugins,
275274
"plugin_order": plugin_order,
276275
}
277-
# Ecriture best-effort
276+
# Ecriture best-effort en YML uniquement
278277
try:
279-
target = workspace_root / "bcasl.json"
278+
target = workspace_root / "bcasl.yml"
280279
target.write_text(
281-
json.dumps(default_cfg, ensure_ascii=False, indent=2) + "\n",
280+
yaml.safe_dump(default_cfg, allow_unicode=True, sort_keys=False),
282281
encoding="utf-8",
283282
)
284283
except Exception:
@@ -499,7 +498,7 @@ def resolve_bcasl_timeout(self) -> float:
499498

500499
def open_bc_loader_dialog(self) -> None: # UI minimale
501500
"""Fenêtre simple pour activer/désactiver et réordonner les plugins(BCASL).
502-
Persiste dans <workspace>/bcasl.json uniquement (JSON).
501+
Persiste dans <workspace>/bcasl.yml uniquement (YML).
503502
"""
504503
try: # Importer QtWidgets à la demande pour compatibilité headless
505504
from PySide6.QtWidgets import (
@@ -736,18 +735,18 @@ def do_save():
736735
except Exception:
737736
pass
738737

739-
# Ecrire JSON uniquement
740-
target = workspace_root / "bcasl.json"
738+
# Ecrire YML uniquement
739+
target = workspace_root / "bcasl.yml"
741740
try:
742741
target.write_text(
743-
json.dumps(cfg_out, ensure_ascii=False, indent=2) + "\n",
742+
yaml.safe_dump(cfg_out, allow_unicode=True, sort_keys=False),
744743
encoding="utf-8",
745744
)
746745
if hasattr(self, "log") and self.log is not None:
747746
self.log.append(
748747
self.tr(
749-
"✅ Plugins enregistrés dans bcasl.json",
750-
"✅ Plugins plugins saved to bcasl.json",
748+
"✅ Plugins enregistrés dans bcasl.yml",
749+
"✅ Plugins saved to bcasl.yml",
751750
)
752751
)
753752
dlg.accept()
@@ -756,8 +755,8 @@ def do_save():
756755
dlg,
757756
self.tr("Erreur", "Error"),
758757
self.tr(
759-
f"Impossible d'écrire bcasl.json: {e}",
760-
f"Failed to write bcasl.json: {e}",
758+
f"Impossible d'écrire bcasl.yml: {e}",
759+
f"Failed to write bcasl.yml: {e}",
761760
),
762761
)
763762

0 commit comments

Comments
 (0)