From 8e444765bd284ed4b34129eb1de9c3b05dcb7e20 Mon Sep 17 00:00:00 2001 From: Jean-Damien Date: Fri, 23 Dec 2022 17:23:39 +0100 Subject: [PATCH] cmd/db.py doctring __find_indiv --- app/cmd/db.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/cmd/db.py b/app/cmd/db.py index ab9339b..96ffc68 100644 --- a/app/cmd/db.py +++ b/app/cmd/db.py @@ -296,7 +296,7 @@ def __find_transcribers(folder: str)-> None: def __csv_indiv_infos(indiv_type): """extract individuals of the same type from static/csv/actors.csv and make a list with them - :param indiv_type: or + :param indiv_type: individuals' type. ( or ) :type indiv_type: str :return: list of individuals of the choosen type :rtype: list @@ -307,7 +307,16 @@ def __csv_indiv_infos(indiv_type): 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: +def __find_indiv(folder: str, role: str): + """find indiv name in //sourceDesc/listPerson/listPerson[@type=''] + and add it to a list. Function used in init() function. + :param folder: name of a folder containing acts' xml file + :type folder: str + :param role: individuals' role. ( or ) + :type role: str + :return: list + :rtype: set list + """ indiv_lst = [] for acte in os.listdir(folder): if acte.endswith(".xml"): @@ -368,7 +377,7 @@ def init() -> None: # 3/ check which names need to be add to the actors.csv names_in_csv = [actor[0] for actor in actors] names_in_xml = __find_indiv(xml_folder, "signatory") - for name in [x for x in names_in_xml if x not in names_in_csv]: + for name in [label for label in names_in_xml if label not in names_in_csv]: print("!! name " + name + " not found in /app/static/csv/actors.csv") # 4/ create tables