diff --git a/README.md b/README.md index 818e77a..35ca555 100644 --- a/README.md +++ b/README.md @@ -21,11 +21,11 @@ This file is straight forward. It is a JSON list consisting of all the paragraph ```json [ { - "paragraph_id": 1, + "id": 1, "text": "God, infinitely perfect and blessed in himself, in a plan of sheer goodness freely created man to make him share in his own blessed life. For this reason, at every time and in every place, God draws close to man. He calls man to seek him, to know him, to love him with all his strength. He calls together all men, scattered and divided by sin, into the unity of his family, the Church. To accomplish this, when the fullness of time had come, God sent his Son as Redeemer and Savior. In his Son and through him, he invites men to become, in the Holy Spirit, his adopted children and thus heirs of his blessed life.\n" }, { - "paragraph_id": 2, + "id": 2, "text": "So that this call should resound throughout the world, Christ sent forth the apostles he had chosen, commissioning them to proclaim the gospel: \"Go therefore and make disciples of all nations, baptizing them in the name of the Father and of the Son and of the Holy Spirit, teaching them to observe all that I have commanded you; and lo, I am with you always, to the close of the age.\" Strengthened by this mission, the apostles \"went forth and preached everywhere, while the Lord worked with them and confirmed the message by the signs that attended it.\"\n" } ] diff --git a/helpers/utils.py b/helpers/utils.py index 3daf1b4..b27cab2 100644 --- a/helpers/utils.py +++ b/helpers/utils.py @@ -2,5 +2,12 @@ def create_json_file(destination_file_name: str, source_dict: dict): + """ + Creates a json file and writes it to the destination provided. + + :param destination_file_name: Destination file name + :param source_dict: Source dictionary + :return: None + """ with open(destination_file_name, "w") as outfile: json.dump(source_dict, outfile) diff --git a/main.py b/main.py index 488fa84..80cd01c 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,10 @@ def read_canon_law() -> list: + """ + Reads the canon.pickle file. + :return: a list of Canon Law + """ canon_law_from_pickle = pickle.load(open("pickles/canon.pickle", 'rb')) law_numbers = [law for law in canon_law_from_pickle] @@ -51,6 +55,10 @@ def read_canon_law() -> list: def read_catechism() -> list: + """ + Reads the catechism.pickle file. + :return: a list of catechism paragraphs. + """ catechism_from_pickle = pickle.load(open("pickles/catechism.pickle", 'rb')) catechism_paragraph_numbers = [number for number in catechism_from_pickle] @@ -60,15 +68,19 @@ def read_catechism() -> list: paragraph = catechism_from_pickle[paragraph_number] text = paragraph[0] paragraph_object = { - "paragraph_id": int(paragraph_number), + "id": int(paragraph_number), "text": text } catechism_list.append(paragraph_object) - return sorted(catechism_list, key=itemgetter("paragraph_id")) + return sorted(catechism_list, key=itemgetter("id")) def read_general_instruction_of_the_roman_missal() -> list: + """ + Reads the girm.pickle file. + :return: List of girm paragraphs + """ girm_from_pickle = pickle.load(open("pickles/girm.pickle", 'rb')) girm_ids = [girm_id for girm_id in girm_from_pickle]