correct path

This commit is contained in:
2025-12-04 21:25:41 +01:00
parent a6643fc181
commit 3d51827217

29
main.py
View File

@@ -1,19 +1,17 @@
import os
import argparse
import concurrent.futures
import logging
import os
import sqlite3
import time as tm
import traceback
import mail as ml
from datetime import date, datetime
from logging.handlers import TimedRotatingFileHandler
from urllib.request import urlretrieve
import dotenv
import ovh
import fetcher as ft
import mail as ml
from urllib.request import urlretrieve
import logging
from logging.handlers import TimedRotatingFileHandler
import traceback
import sqlite3
import time as tm
def init():
@@ -141,7 +139,7 @@ def indexer(ids: list[str]) -> list[str]:
conn = get_conn()
logger.info("Indexation des factures pour l'année %s", YEAR)
target_dir = os.path.join(PATH_OVH, "ovh" + str(YEAR))
target_dir = os.path.join(PATH_OVH, str(YEAR) + "/ovh")
try:
ids_already_in = {fn for fn in os.listdir(target_dir) if fn.endswith(".pdf")}
except FileNotFoundError:
@@ -261,8 +259,7 @@ def save_pdf(bill: dict) -> None:
Télécharge le PDF dune facture dans un sous-dossier par année.
Noms de fichiers : <billId>.pdf
"""
fmt_year = str(datetime.now().year) + "/ovh/"
year_dir = os.path.join(PATH_OVH, fmt_year)
year_dir = os.path.join(PATH_OVH, str(datetime.now().year) + "/ovh")
os.makedirs(year_dir, exist_ok=True)
dest = os.path.join(year_dir, f"{bill['billId']}.pdf")
@@ -299,11 +296,7 @@ if __name__ == "__main__":
init()
start = tm.time()
logger.info("Démarrage du traitement des factures OVH pour %s", YEAR)
final_path = str(YEAR) + "/ovh/"
os.makedirs(
os.path.join(PATH_OVH, final_path),
exist_ok=True,
)
os.makedirs(os.path.join(PATH_OVH, str(YEAR)), exist_ok=True)
ids_candidats = indexer(get_ids())
bills_json = []