|
|
|
|
@ -9,13 +9,14 @@ Date : 2022-10-11
|
|
|
|
|
Update : 2022-10-13
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import csv
|
|
|
|
|
import os
|
|
|
|
|
import re
|
|
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
from peewee import *
|
|
|
|
|
from tqdm import tqdm
|
|
|
|
|
|
|
|
|
|
from modeles.princes_db_tables import db, Institution, State, Production_place, Diplo_type, Document, Acte
|
|
|
|
|
from modeles.princes_db_tables import db, Institution, State, Production_place, Diplo_type, Document, Acte, Individual, Duke
|
|
|
|
|
|
|
|
|
|
from data.institution_data import institution
|
|
|
|
|
from data.state_data import state
|
|
|
|
|
@ -119,6 +120,7 @@ def _create_acte(xml_file: str, folder: str)-> None:
|
|
|
|
|
for data in tqdm(actes, desc="Populating Actes..."):
|
|
|
|
|
Acte.create(**data)
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
def __find_indiv(xml_soup, role: str, indiv_lst: list)-> None:
|
|
|
|
|
princes = xml_soup.sourceDesc.find_all("listPerson", {"type": role})
|
|
|
|
|
for prince in princes:
|
|
|
|
|
@ -135,23 +137,55 @@ def _create_individual(xml_file: str, folder: str)-> None:
|
|
|
|
|
__find_indiv(soup, "signatory", indiv_secret)
|
|
|
|
|
print(set(indiv_secret))
|
|
|
|
|
print(set(indiv_prince))
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def __indiv_infos(indiv_type):
|
|
|
|
|
with open("./static/csv/actors.csv", 'r', encoding="utf-8") as opening:
|
|
|
|
|
actors_csv = csv.reader(opening, delimiter=";")
|
|
|
|
|
next(actors_csv, None)
|
|
|
|
|
lst_of_indiv = [row for row in actors_csv if row[1] == indiv_type]
|
|
|
|
|
return lst_of_indiv
|
|
|
|
|
|
|
|
|
|
def _create_indiv():
|
|
|
|
|
actors = [*__indiv_infos("secret"), *__indiv_infos("prince")]
|
|
|
|
|
individuals = [{"name_indiv": actor[0], "role_indiv": actor[1]}
|
|
|
|
|
for actor in actors]
|
|
|
|
|
for data in tqdm(individuals, desc="Populating Individual..."):
|
|
|
|
|
Individual.create(**data)
|
|
|
|
|
|
|
|
|
|
def _create_duke():
|
|
|
|
|
dukes = []
|
|
|
|
|
for info in __indiv_infos("prince"):
|
|
|
|
|
indiv_query = [t.id_indiv for t in Individual.select().where(
|
|
|
|
|
Individual.name_indiv == info[0])]
|
|
|
|
|
dukes.append({"house": info[2], "indiv_duke": indiv_query[0],
|
|
|
|
|
"birth": info[3], "reign": info[4], "death": info[4]})
|
|
|
|
|
for data in tqdm(dukes, desc="Populating Duke..."):
|
|
|
|
|
Duke.create(**data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def init():
|
|
|
|
|
"""initializing db"""
|
|
|
|
|
db.connect()
|
|
|
|
|
print("Dropping existing DB...")
|
|
|
|
|
db.drop_tables([Institution, State, Production_place, Diplo_type, Document, Acte])
|
|
|
|
|
db.drop_tables([Institution, State, Production_place,
|
|
|
|
|
Diplo_type, Document, Acte, Individual, Duke])
|
|
|
|
|
print("Re-creating schema...")
|
|
|
|
|
db.create_tables([Institution, State, Production_place, Diplo_type, Document, Acte])
|
|
|
|
|
db.create_tables([Institution, State, Production_place,
|
|
|
|
|
Diplo_type, Document, Acte, Individual, Duke])
|
|
|
|
|
_create_institution(institution)
|
|
|
|
|
_create_state(state)
|
|
|
|
|
_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()
|
|
|
|
|
|
|
|
|
|
xml = "../bourbon-latex/charles-actes-latex.xml"
|
|
|
|
|
xml_folder = "./static/xml/Bourbon/Brb_5_Charles_Ier"
|
|
|
|
|
|
|
|
|
|
# init()
|
|
|
|
|
_create_individual(xml, xml_folder)
|
|
|
|
|
init()
|
|
|
|
|
# _create_individual(xml, xml_folder)
|
|
|
|
|
|