From 67469cf33928d8ea45fce8e9092442f7f08620b2 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sat, 21 Sep 2024 20:56:03 +0200 Subject: [PATCH] On corrige le cas des ical vides --- src/agenda_culturel/db_importer.py | 3 +++ src/agenda_culturel/import_tasks/extractor.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/agenda_culturel/db_importer.py b/src/agenda_culturel/db_importer.py index 9ffc237..de38ce8 100644 --- a/src/agenda_culturel/db_importer.py +++ b/src/agenda_culturel/db_importer.py @@ -43,6 +43,9 @@ class DBImporterEvents: except: return (False, "JSON file is not correctly structured") + if len(structure) == 0: + return (True, "") + if "header" not in structure: return (False, "JSON is not correctly structured: missing header") if "events" not in structure: diff --git a/src/agenda_culturel/import_tasks/extractor.py b/src/agenda_culturel/import_tasks/extractor.py index 9fce25c..9a00769 100644 --- a/src/agenda_culturel/import_tasks/extractor.py +++ b/src/agenda_culturel/import_tasks/extractor.py @@ -214,7 +214,7 @@ class Extractor(ABC): def get_structure(self): if len(self.events) == 0: - return None + return {} else: return {"header": self.header, "events": self.events}