import os import json from config import EXPORT_DIR def ensure_export_directory(): """Crée le répertoire d'export s'il n'existe pas""" if not os.path.exists(EXPORT_DIR): os.makedirs(EXPORT_DIR) def save_json(filename, data): """Enregistre les données dans un fichier JSON""" ensure_export_directory() filepath = os.path.join(EXPORT_DIR, filename) with open(filepath, "w", encoding="utf-8") as f: json.dump(data, f, indent=4, ensure_ascii=False) print(f"Fichier enregistré : {filepath}") def get_user_choice(prompt, options): """Obtient un choix valide de l'utilisateur""" while True: choice = input(prompt) if choice in options: return choice print(f"Choix invalide. Options disponibles: {', '.join(options)}")