|
|
|
|
@ -9,12 +9,8 @@ from lxml import etree
|
|
|
|
|
from tqdm import tqdm
|
|
|
|
|
|
|
|
|
|
from app.app import APPPATH, db
|
|
|
|
|
from app.data_actes import diplomatic_type, institution, state
|
|
|
|
|
from app.modeles import Institution, State, Production_place, Diplo_type, Document, Acte, Individual, Duke, Produced_by
|
|
|
|
|
|
|
|
|
|
# from app.data import institution
|
|
|
|
|
# from app.data import state
|
|
|
|
|
# from app.data import diplomatic_type
|
|
|
|
|
from app.data_actes import diplomatic_type, institution, state, houses
|
|
|
|
|
from app.modeles import Institution, State, House, Production_place, Diplo_type, Document, Acte, Individual, Produced_by
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db_cli = AppGroup("db")
|
|
|
|
|
@ -49,6 +45,11 @@ def _create_state(data_lst: list)-> None:
|
|
|
|
|
for data in tqdm(data_lst, desc="Populating State..."):
|
|
|
|
|
State.create(**data)
|
|
|
|
|
|
|
|
|
|
def _create_house(data_lst: list)-> None:
|
|
|
|
|
"""create state table"""
|
|
|
|
|
for data in tqdm(data_lst, desc="Populating House..."):
|
|
|
|
|
House.create(**data)
|
|
|
|
|
|
|
|
|
|
def _create_diplo_type(data_lst: list)-> None:
|
|
|
|
|
"""create diplo type table"""
|
|
|
|
|
for data in tqdm(data_lst, desc="Populating Diplo_type..."):
|
|
|
|
|
@ -158,7 +159,10 @@ def __indiv_infos(indiv_type):
|
|
|
|
|
|
|
|
|
|
def _create_indiv():
|
|
|
|
|
actors = [*__indiv_infos("secret"), *__indiv_infos("prince")]
|
|
|
|
|
individuals = [{"name_indiv": actor[0], "role_indiv": actor[1]}
|
|
|
|
|
individuals = [{"name_indiv": actor[0], "role_indiv": actor[1],
|
|
|
|
|
"house_indiv": [t.id_house for t in House.select().where(
|
|
|
|
|
House.house_label == actor[2])][0],
|
|
|
|
|
"date1": actor[3], "date2": actor[4], "date3": actor[5]}
|
|
|
|
|
for actor in actors]
|
|
|
|
|
for data in tqdm(individuals, desc="Populating Individual..."):
|
|
|
|
|
Individual.create(**data)
|
|
|
|
|
@ -187,11 +191,11 @@ def _create_produced_by(xml_file: str, folder: str):
|
|
|
|
|
prince = duke.text.replace("\n", "")
|
|
|
|
|
prince_q = [t.id_indiv for t in Individual.select().where(
|
|
|
|
|
Individual.name_indiv == duke.text.replace("\n", ""))]
|
|
|
|
|
duke_q = [t.id_duke for t in Duke.select().where(
|
|
|
|
|
Duke.indiv_duke == prince_q[0])]
|
|
|
|
|
# print(prince, "==", prince_q[0], "==", duke_q[0])
|
|
|
|
|
# duke_q = [t.id_duke for t in Duke.select().where(
|
|
|
|
|
# Duke.indiv_duke == prince_q[0])]
|
|
|
|
|
# print(prince, "==", prince_q[0])
|
|
|
|
|
princes_actes.append({"produced_by_acte": acte_q[0],
|
|
|
|
|
"produced_by_prince": duke_q[0]})
|
|
|
|
|
"produced_by_prince": prince_q[0]})
|
|
|
|
|
for data in tqdm(princes_actes, desc="Populating Produced_by..."):
|
|
|
|
|
Produced_by.create(**data)
|
|
|
|
|
|
|
|
|
|
@ -205,19 +209,18 @@ def init() -> None:
|
|
|
|
|
"Bourbon", "Brb_5_Charles_Ier")
|
|
|
|
|
|
|
|
|
|
print("Dropping existing DB...")
|
|
|
|
|
db.drop_tables([Institution, State, Production_place,
|
|
|
|
|
Diplo_type, Document, Acte, Individual, Duke,
|
|
|
|
|
db.drop_tables([Institution, State, House, Production_place,
|
|
|
|
|
Diplo_type, Document, Acte, Individual,
|
|
|
|
|
Produced_by])
|
|
|
|
|
print("Re-creating schema...")
|
|
|
|
|
db.create_tables([Institution, State, Production_place,
|
|
|
|
|
Diplo_type, Document, Acte, Individual, Duke,
|
|
|
|
|
Produced_by])
|
|
|
|
|
db.create_tables([Institution, State, House, Production_place,
|
|
|
|
|
Diplo_type, Document, Acte, Individual, Produced_by])
|
|
|
|
|
_create_institution(institution)
|
|
|
|
|
_create_state(state)
|
|
|
|
|
_create_house(houses)
|
|
|
|
|
_create_diplo_type(diplomatic_type)
|
|
|
|
|
_create_produc_place(xml, xml_folder)
|
|
|
|
|
_create_doc(xml, xml_folder)
|
|
|
|
|
_create_acte(xml, xml_folder)
|
|
|
|
|
_create_indiv()
|
|
|
|
|
_create_duke()
|
|
|
|
|
_create_produced_by(xml, xml_folder)
|
|
|
|
|
|