cmd/db.py docstring create transcribed_by

main
Jean-Damien 3 years ago
parent 96fb348548
commit 71a782f15f

@ -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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Loading…
Cancel
Save