diff --git a/app/cmd/db.py b/app/cmd/db.py index 55664a3..8cc8159 100644 --- a/app/cmd/db.py +++ b/app/cmd/db.py @@ -206,25 +206,6 @@ def _create_transcribed_by(folder: str)-> None: Transcribed_by.create(**data) -def __find_indiv(folder: str, role: str)-> None: - indiv_lst = [] - for acte in os.listdir(folder): - if acte.endswith(".xml"): - soup = make_soup(os.path.join(folder, acte)) - xml_indivs = soup.sourceDesc.find_all("listPerson", {"type": role}) - for xml_indiv in xml_indivs: - persons = xml_indiv.find_all("person") - for person in persons: - indiv_lst.append(person.text.replace("\n", "")) - return set(indiv_lst) - -def __csv_indiv_infos(indiv_type): - with open(os.path.join(APPPATH, "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(list_csv): individuals = [{"name_indiv": actor[0], "role_indiv": actor[1], "house_indiv": [t.id_house for t in House.select().where( @@ -290,6 +271,24 @@ def _create_involved_in(folder: str): for data in tqdm(princes_actes, desc="Populating involved_in..."): Involved_in.create(**data) +def __csv_indiv_infos(indiv_type): + with open(os.path.join(APPPATH, "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 __find_indiv(folder: str, role: str)-> None: + indiv_lst = [] + for acte in os.listdir(folder): + if acte.endswith(".xml"): + soup = make_soup(os.path.join(folder, acte)) + xml_indivs = soup.sourceDesc.find_all("listPerson", {"type": role}) + for xml_indiv in xml_indivs: + persons = xml_indiv.find_all("person") + for person in persons: + indiv_lst.append(person.text.replace("\n", "")) + return set(indiv_lst) @db_cli.command() def init() -> None: