from __future__ import annotations

import json
from pathlib import Path
from decorateur_Dt import *
from bibliotheque_json import Auteur, Livre, Bibliotheque

FICHIER_JSON = Path("bibliotheque_reelle.json")

# ============================================================
# PROGRAMME PRINCIPAL
# ============================================================
bibliotheque = Bibliotheque()

if not bibliotheque.livres:
    print("La bibliotheque est VIDE ! ")
# ============================================================
# EXEMPLE D'EMPRUNT
# ============================================================
livre = bibliotheque.trouver_livre(2)
print(livre)
if livre is not None:
    bibliotheque.emprunter_livre(livre.id)

    # Deuxième tentative : doit échouer
    bibliotheque.emprunter_livre(livre.id)
# ============================================================
# EXEMPLE DE RESTITUTION
# ============================================================
if livre is not None:
    bibliotheque.rendre_livre(livre.id)

lst_jules_verne = bibliotheque.trouver_livres_auteur("Isaac","Asimov")
print(lst_jules_verne[0])
calcul_complexe(2_000_000)