Here's my idea of how chapters, mp3 file locations and (coming up) text should be handled
I am adding King James text to the json file also, and will share all the code to create as soon as done:
do the following steps in order:
software:
__init__.py
I am adding King James text to the json file also, and will share all the code to create as soon as done:
do the following steps in order:
- Create a directory named src
- Save the __init__.py file to parent directory of src
- Copy all other .py files to the src directory
- run
python BiblePaths.py
once from command terminal to create sub directories
- save .json file (attached) to src/data/json
- run
python DisplayBibleIndex.py
software:
__init__.py
src\ __init__.py BiblePaths.py DisplayBibleIndex.pyBiblePaths.py
from pathlib import Path class BiblePaths: def __init__(self): self.homepage = Path('.') self.datapath = self.homepage / 'data' self.datapath.mkdir(exist_ok=True) self.jsonpath = self.datapath / 'json' self.jsonpath.mkdir(exist_ok=True) self.KingJamespath = self.datapath / 'KingJames' self.KingJamespath.mkdir(exist_ok=True) self.BibleIndex = self.jsonpath / 'BibleIndex.json' self.emptyinit = self.homepage / '__init__.py' self.emptyinit.touch(exist_ok=True) def onetime(): bp = BiblePaths() if __name__ == '__main__': onetime()DisplayBibleIndex.py
import BiblePaths import json class DisplayBibleIndex: def __init__(self): self.npath = BiblePaths.BiblePaths() with self.npath.BibleIndex.open() as f: self.BibleIndex = json.load(f) self.show_index() def show_index(self): for volume, contents in self.BibleIndex.items(): for book, detail in contents.items(): print() for chapter, description in detail.items(): if chapter == 'mp3': print(f'mp3 file is located here: {description}') else: print(f'volume: {volume}, book: {book}, chapter: {chapter} {description}') # This is an example of how to get info on a particular Book, chapter: print(f"\nLeviticus Chapter 5: {self.BibleIndex['Old Testament']['Leviticus']['5']}") print(f"Mp3 file for Leviticus is here: {self.BibleIndex['Old Testament']['Leviticus']['mp3']}") if __name__ == '__main__': DisplayBibleIndex()
Attached Files