organize exampels according to products

This commit is contained in:
ykcheungab
2026-08-03 15:52:15 +08:00
parent 8b2f76c76f
commit 3117ddd5b9
21 changed files with 657 additions and 365 deletions
+18 -5
View File
@@ -1,6 +1,12 @@
import json
from pathlib import Path
# Product-facing names that map to on-disk config stems.
# ORY-FINGER currently ships as dd02-ov.json; keep "dd02" as the stable alias.
CONFIG_ALIASES = {
"dd02": "dd02-ov",
}
def _candidate_config_dirs() -> list[Path]:
"""
@@ -62,9 +68,16 @@ def load_config(config_name_or_path):
if config_path.is_absolute():
raise FileNotFoundError(f"Config file not found at absolute path: {config_path}")
direct = CONFIG_DIR / f"{config_name_or_path}.json"
if direct.exists():
return _load_json(direct)
requested = str(config_name_or_path)
candidates = [requested]
alias = CONFIG_ALIASES.get(requested)
if alias and alias not in candidates:
candidates.append(alias)
for name in candidates:
direct = CONFIG_DIR / f"{name}.json"
if direct.exists():
return _load_json(direct)
# Backward-compatible alias resolution: support old names via JSON "name" field.
for candidate in _config_files():
@@ -72,7 +85,7 @@ def load_config(config_name_or_path):
data = _load_json(candidate)
except Exception:
continue
if data.get("name") == config_name_or_path:
if data.get("name") in candidates:
return data
available = [f.stem for f in _config_files()]
@@ -80,7 +93,7 @@ def load_config(config_name_or_path):
raise FileNotFoundError(
f"Input config file not found with name or path: {config_name_or_path}\n"
f" Tried as file path: {config_path} (not found)\n"
f" Tried as config file: {direct} (not found)\n"
f" Tried as config files: {', '.join(candidates)} (not found)\n"
f" Available config files: {available_str}"
)