+ create table acte

main
jgenero 3 years ago
parent 8997266dc8
commit a5ab228b70

@ -81,6 +81,44 @@ def _create_doc(xml_file: str, folder: str)-> None:
for data in tqdm(infos_doc, desc="Populating Document..."):
Document.create(**data)
def _create_acte(xml_file: str, folder: str)-> None:
actes = []
for acte in os.listdir(folder):
soup = make_soup(os.path.join(folder, acte))
numb = soup.TEI["xml:id"]
date_time = soup.msItem.docDate["when"]
date = soup.msItem.docDate.text
analyse = soup.abstract.p.text
ref = soup.msIdentifier.find_all("idno", {"n": "2"})
if len(ref) > 0:
ref_acte = ref[0].text
else:
ref_acte = "NS"
prod_place = soup.find_all("placeName", {"type": "production_place"})[0].text
doc = soup.msIdentifier.find_all("idno", {"n": "1"})[0]
type_diplo = soup.body.div["subtype"]
diplo_state = soup.body.div["type"]
place_query = [t.id_place for t in Production_place.select().where(
Production_place.placename == prod_place)]
doc_query = [t.id_document for t in Document.select().where(
Document.collection_doc == doc.text)]
diplo_query = [t.id_diplo_type for t in Diplo_type.select().where(
Diplo_type.diplo_label == type_diplo)]
state_query = [t.id_state for t in State.select().where(
State.state_label == diplo_state)]
actes.append({
"numb_acte": numb,
"date_time": date_time,
"date": date,
"analysis": analyse,
"doc_acte": doc_query[0],
"ref_acte": ref_acte,
"state_doc": state_query[0],
"diplo_type_acte": diplo_query[0]
})
for data in tqdm(actes, desc="Populating Actes..."):
Acte.create(**data)
def init():
"""initializing db"""
db.connect()
@ -91,12 +129,11 @@ def init():
_create_institution(institution)
_create_state(state)
_create_diplo_type(diplomatic_type)
_create_produc_place(xml, "./static/xml/Bourbon/Brb_5_Charles_Ier")
_create_doc(xml, "./static/xml/Bourbon/Brb_5_Charles_Ier")
_create_produc_place(xml, xml_folder)
_create_doc(xml, xml_folder)
_create_acte(xml, xml_folder)
xml = "../bourbon-latex/charles-actes-latex.xml"
xml_folder = "./static/xml/Bourbon/Brb_5_Charles_Ier"
init()
# diplo_state = soup.body.div["type"]
# state_query = [t.id_state for t in State.select().where(State.state_label == item[2])]
Loading…
Cancel
Save