├── helpers ├── __init__.py └── utils.py ├── pickles └── girm.pickle ├── CHANGELOG.md ├── main.py ├── .gitignore └── README.md /helpers/__init__.py: -------------------------------------------------------------------------------- 1 | __all__: [ 2 | "json" 3 | ] 4 | -------------------------------------------------------------------------------- /pickles/girm.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemsavio/catholicism-in-json/HEAD/pickles/girm.pickle -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # [v2.0.0]() 2 | 3 | --- 4 | ## Updates 5 | * Structure of Catechism of the Catholic Church JSON. 6 | 7 | # [v1.0.0]() 8 | 9 | --- 10 | ## Adds 11 | * Catechism of the Catholic Church in JSON format 12 | * The Canon Law in JSON format 13 | * General Instruction of The Roman Missal in JSON format -------------------------------------------------------------------------------- /helpers/utils.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | 4 | def create_json_file(destination_file_name: str, source_dict: dict): 5 | """ 6 | Creates a json file and writes it to the destination provided. 7 | 8 | :param destination_file_name: Destination file name 9 | :param source_dict: Source dictionary 10 | :return: None 11 | """ 12 | with open(destination_file_name, "w") as outfile: 13 | json.dump(source_dict, outfile) 14 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import json 2 | import pickle 3 | from operator import itemgetter 4 | 5 | from helpers.utils import create_json_file 6 | 7 | 8 | def read_canon_law() -> list: 9 | """ 10 | Reads the canon.pickle file. 11 | :return: a list of Canon Law 12 | """ 13 | canon_law_from_pickle = pickle.load(open("pickles/canon.pickle", 'rb')) 14 | law_numbers = [law for law in canon_law_from_pickle] 15 | 16 | canon_law_list = [] 17 | 18 | for law_num in law_numbers: 19 | law = canon_law_from_pickle[law_num] 20 | 21 | is_list = law[0] 22 | 23 | if is_list: 24 | sub_laws = law[1] 25 | 26 | sub_law_numbers = [sub_law for sub_law in sub_laws] 27 | 28 | individual_sub_laws = [] 29 | 30 | for n in sub_law_numbers: 31 | individual_sub_law = { 32 | "id": int(n), 33 | "text": sub_laws[n] 34 | } 35 | individual_sub_laws.append(individual_sub_law) 36 | 37 | sorted_individual_sub_laws = sorted(individual_sub_laws, key=itemgetter('id')) 38 | law_object = { 39 | "id": int(law_num), 40 | "sections": sorted_individual_sub_laws 41 | } 42 | 43 | canon_law_list.append(law_object) 44 | 45 | else: 46 | law_text = law[1] 47 | law_object = { 48 | "id": int(law_num), 49 | "text": law_text 50 | } 51 | canon_law_list.append(law_object) 52 | 53 | sorted_canon_law_list = sorted(canon_law_list, key=itemgetter("id")) 54 | return sorted_canon_law_list 55 | 56 | 57 | def read_catechism() -> list: 58 | """ 59 | Reads the catechism.pickle file. 60 | :return: a list of catechism paragraphs. 61 | """ 62 | catechism_from_pickle = pickle.load(open("pickles/catechism.pickle", 'rb')) 63 | catechism_paragraph_numbers = [number for number in catechism_from_pickle] 64 | 65 | catechism_list = [] 66 | 67 | for paragraph_number in catechism_paragraph_numbers: 68 | paragraph = catechism_from_pickle[paragraph_number] 69 | text = paragraph[0] 70 | paragraph_object = { 71 | "id": int(paragraph_number), 72 | "text": text 73 | } 74 | catechism_list.append(paragraph_object) 75 | 76 | return sorted(catechism_list, key=itemgetter("id")) 77 | 78 | 79 | def read_general_instruction_of_the_roman_missal() -> list: 80 | """ 81 | Reads the girm.pickle file. 82 | :return: List of girm paragraphs 83 | """ 84 | girm_from_pickle = pickle.load(open("pickles/girm.pickle", 'rb')) 85 | girm_ids = [girm_id for girm_id in girm_from_pickle] 86 | 87 | girm_list = [] 88 | 89 | for girm_id in girm_ids: 90 | single_girm_object = girm_from_pickle[girm_id] 91 | text = single_girm_object[0] 92 | girm_object = { 93 | "id": int(girm_id), 94 | "text": text 95 | } 96 | girm_list.append(girm_object) 97 | 98 | return sorted(girm_list, key=itemgetter("id")) 99 | 100 | 101 | if __name__ == '__main__': 102 | canon = read_canon_law() 103 | create_json_file("canon.json", canon) 104 | 105 | catechism = read_catechism() 106 | create_json_file("catechism.json", catechism) 107 | 108 | girm = read_general_instruction_of_the_roman_missal() 109 | create_json_file("girm.json", girm) 110 | 111 | print("The following files - canon.json, catechism.json, and girm.json have been created and stored at the " 112 | "project's root.") 113 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | 162 | .json 163 | 164 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ⛪️ catholicism-in-json 2 | 3 | This repository houses the following resources, all in usable JSON format. 4 | 5 | 1. 📒 __Catechism of the Catholic Church__ 6 | 2. 🇻🇦 __The Canon Law__ 7 | 3. ⛪️ __General Instruction of The Roman Missal__ 8 | 9 | This repo utilizes pickles from the 10 | well-known Catholic Reddit bot [/u/Catebot](https://www.reddit.com/user/Catebot/) to create the JSON files. Please refer 11 | to the [Catebot's GitHub repo](https://github.com/konohitowa/catebot) for more information. 12 | You can access the JSON files for your use from 13 | the [releases](https://github.com/aseemsavio/catholicism-in-json/releases) section. 14 | Note that the text in these files is in `markdown` style - with bold, italics, quotes, etc. 15 | 16 | ## Structure of the JSON files 17 | 18 | 1. `catechism.json` 19 | 20 | This file is straightforward. It is a JSON list consisting of all the paragraphs of the Catechism of The Church. 21 | 22 | ```json 23 | [ 24 | { 25 | "id": 1, 26 | "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" 27 | }, 28 | { 29 | "id": 2, 30 | "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" 31 | } 32 | ] 33 | ``` 34 | 35 | 2. `canon.json` 36 | 37 | The following is a snippet from the `canon.json` file. 38 | At the top level is an array, which houses all the Canon laws. 39 | Each law has an `id` and either a `text` or an array - `sections`. 40 | Each `sections` object contains an `id` and a `text`. 41 | 42 | ```json 43 | [ 44 | { 45 | "id": 4, 46 | "text": "Acquired rights and privileges granted to physical or juridic persons up to this time by the Apostolic See remain intact if they are in use and have not been revoked, unless the canons of this Code expressly revoke them.\n\n" 47 | }, 48 | { 49 | "id": 5, 50 | "sections": [ 51 | { 52 | "id": 1, 53 | "text": "Universal or particular customs presently in force which are contrary to the prescripts of these canons and are reprobated by the canons of this Code are absolutely suppressed and are not permitted to revive in the future. Other contrary customs are also considered suppressed unless the Code expressly provides otherwise or unless they are centenary or immemorial customs which can be tolerated if, in the judgment of the ordinary, they cannot be removed due to the circumstances of places and persons.\n\n" 54 | }, 55 | { 56 | "id": 2, 57 | "text": "Universal or particular customs beyond the law (*praeter ius*) which are in force until now are preserved.\n\n" 58 | } 59 | ] 60 | } 61 | ] 62 | ``` 63 | 64 | 3. `girm.json` 65 | 66 | The contents of The __General Instruction of The Roman Missal__ file look as follows. 67 | 68 | ```json 69 | [ 70 | { 71 | "id": 1, 72 | "text": "As Christ the Lord was about to celebrate with the disciples the paschal supper in which he instituted the Sacrifice of his Body and Blood, he commanded that a large, furnished upper room be prepared (Lk 22:12). Indeed, the Church has always judged that this command also applied to herself whenever she decided about things related to the disposition of people's minds, and of places, rites, and texts for the Celebration of the Most Holy Eucharist. The present norms, too, prescribed in keeping with the will of the Second Vatican Council, together with the new Missal with which the Church of the Roman Rite will henceforth celebrate the Mass, are again a demonstration of this same solicitude of the Church, of her faith and her unaltered love for the supreme mystery of the Eucharist, and also attest to her continuous and consistent tradition, even though certain new elements have been introduced.\n\n" 73 | } 74 | ] 75 | ``` 76 | 77 | ## Note to Contributors/Developers 78 | 79 | If you're feeling particularly nerdy, and hence wish to generate the JSON files by yourselves, 80 | you may run the following command from the root of this project. 81 | You need to have Python installed on your machine for this. 82 | 83 | ``` 84 | python main.py 85 | ``` 86 | 87 | Feel free to leave me a note when you end up using the JSONs from this project. 88 | It would be fun for me to learn how and where you put this project to use! 🤓 89 | 90 | --------------------------------------------------------------------------------