5
2
mirror of https://github.com/getbible/v2_builder.git synced 2024-11-22 02:35:09 +00:00

initial commit

This commit is contained in:
Jake Wasdin 2017-12-30 11:22:50 -05:00
commit fe6a98c602
2 changed files with 53 additions and 0 deletions

1
kjv.json Normal file

File diff suppressed because one or more lines are too long

52
sword_to_json.py Normal file
View File

@ -0,0 +1,52 @@
from pysword.modules import SwordModules
import argparse, json
def generate_dict(source_file, bible_version):
modules = SwordModules(source_file)
found_modules = modules.parse_modules()
bible = modules.get_bible_from_module(bible_version)
books = bible.get_structure()._books['ot'] + bible.get_structure()._books['nt']
bib = {}
bib['books'] = []
for book in books:
chapters = []
for chapter in xrange(1, book.num_chapters+1):
verses = []
for verse in xrange(1, len(book.get_indicies(chapter))+1 ):
verses.append({
'verse': verse,
'chapter': chapter,
'name': book.name + " " + str(chapter) + ":" + str(verse),
'text': bible.get(books=[book.name], chapters=[chapter], verses=[verse])
})
chapters.append({
'chapter': chapter,
'name': book.name + " " + str(chapter),
'verses': verses
})
bib['books'].append({
'name': book.name,
'chapters': chapters
})
return bib
def write_json(bible_dict, output_file):
with open(output_file, 'w') as outfile:
json.dump(bible_dict, outfile)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--source_file')
parser.add_argument('--bible_version')
parser.add_argument('--output_file')
args = parser.parse_args()
bible_dict = generate_dict(args.source_file, args.bible_version)
write_json(bible_dict, args.output_file)
if __name__ == "__main__": main()