Skip to content

Commit

Permalink
renamed json properties for catechism.json, added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aseemsavio committed Sep 22, 2022
1 parent b456e5c commit d7fe584
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
Expand Down
7 changes: 7 additions & 0 deletions helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
16 changes: 14 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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]

Expand All @@ -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]

Expand Down

0 comments on commit d7fe584

Please sign in to comment.