From 7926f233c16ee26f894c3a9943c6e09cf1241c2d Mon Sep 17 00:00:00 2001 From: jgenero Date: Fri, 21 Oct 2022 14:35:01 +0200 Subject: [PATCH] loop to get all princes' actes in db --- app/cmd/db.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/app/cmd/db.py b/app/cmd/db.py index acbc926..478ddd0 100644 --- a/app/cmd/db.py +++ b/app/cmd/db.py @@ -232,8 +232,7 @@ def _create_involved_in(folder: str): @db_cli.command() def init() -> None: """Initialization of the database""" - xml_folder = os.path.join(APPPATH, "static", "xml", - "Bourbon") + princes_houses = ["Berry", "Bourbon", "Anjou"] print("Dropping existing DB...") db.drop_tables([Institution, State, House, Intervention_type, @@ -247,10 +246,21 @@ def init() -> None: _create_house(houses) _create_interv_type(interventions) _create_diplo_type(diplomatic_type) - _create_produc_place(xml_folder) - _create_doc(xml_folder) - _create_acte(xml_folder) - # check which names need to be add to the actors.csv actors = [*__csv_indiv_infos("secret"), *__csv_indiv_infos("prince")] + _create_indiv(actors) - _create_involved_in(xml_folder) + for prince_house in princes_houses: + xml_folder = os.path.join(APPPATH, "static", "xml", prince_house) + print("\n\n**** HOUSE ", prince_house, " ****") + # check which names need to be add to the actors.csv + names_in_csv = [actor[0] for actor in actors] + names_in_xml = __find_indiv(xml_folder, "signatory") + for name in [x for x in names_in_xml if x not in names_in_csv]: + print("!! name " + name + " not found in /app/static/csv/actors.csv") + _create_produc_place(xml_folder) + _create_doc(xml_folder) + _create_acte(xml_folder) + for prince_house in princes_houses: + print("\n\n**** INVOLVED IN ", prince_house, " ****") + xml_folder = os.path.join(APPPATH, "static", "xml", prince_house) + _create_involved_in(xml_folder)