mirror of
https://github.com/Ladebeze66/projetcbaollm.git
synced 2025-12-16 21:27:53 +01:00
24 lines
805 B
Python
24 lines
805 B
Python
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)}") |