First commit

This commit is contained in:
gauvainboiche
2026-07-24 20:47:31 +02:00
commit 46f53e43b1
18 changed files with 677 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
import json
from pathlib import Path
DATA_DIR = Path(__file__).parent / "data"
REQUIRED_FILES = {
"identity.json": ["first_name", "last_name", "email"],
"context.json": ["title", "summary"],
"experiences.json": [],
"languages.json": [],
"hobbies.json": [],
"hyperlinks.json": []
}
def load_json_data() -> dict:
data = {}
if not DATA_DIR.exists():
raise FileNotFoundError(f"Le dossier '{DATA_DIR}' n'existe pas.")
for filename, required_keys in REQUIRED_FILES.items():
file_path = DATA_DIR / filename
if not file_path.exists():
raise FileNotFoundError(f"Fichier requis manquant : '{filename}' dans le dossier data/")
with open(file_path, "r", encoding="utf-8") as f:
try:
content = json.load(f)
except json.JSONDecodeError as e:
raise ValueError(f"Erreur de syntaxe JSON dans '{filename}' : {e}")
# Validation des clés requises
if isinstance(content, dict):
for key in required_keys:
if key not in content or not str(content[key]).strip():
raise KeyError(f"Clé manquante ou vide '{key}' dans '{filename}'")
key_name = filename.replace(".json", "")
data[key_name] = content
return data