diff --git a/app/cmd/db.py b/app/cmd/db.py index 22ddf24..55664a3 100644 --- a/app/cmd/db.py +++ b/app/cmd/db.py @@ -181,18 +181,27 @@ def _create_acte(folder: str)-> None: Acte.create(**data) def _create_transcribed_by(folder: str)-> None: + """create table transcribed_by""" transcribed = [] for acte in os.listdir(folder): if acte.endswith(".xml"): soup = make_soup(os.path.join(folder, acte)) + # 1.1/ Acte's id. + # the file name is the acte'id when you remove ".xml" + # so we make a query on Acte to get the primary key acte_q = [t.id_acte for t in Acte.select().where( Acte.filename == acte.replace(".xml", ""))] - transcriber = soup.fileDesc.titleStmt - for item in transcriber.find_all("respStmt"): + # 1.2/ Agent's name (transcriber). + # transcriber name is in //fileDesc/titleStmt/respStmt/name + titlestmt = soup.fileDesc.titleStmt + for item in titlestmt.find_all("respStmt"): + # query on table Agent to get the primary key agent_q = [t.id_agent for t in Agent.select().where( Agent.agent_name == item.find("name").text)] + # 2/ Make the data list with both acte's and agent's keys transcribed.append({"transcr_acte": acte_q[0], "transcr_agent": agent_q[0]}) + # 3/ Create the table for data in tqdm(transcribed, desc="Populating Transcribed_by..."): Transcribed_by.create(**data) diff --git a/app/modeles/bdd_actes_princiers_4.png b/app/modeles/bdd_actes_princiers_4.png new file mode 100644 index 0000000..4ed6520 Binary files /dev/null and b/app/modeles/bdd_actes_princiers_4.png differ