From 87fe92cf2360f10f0e9288ec3334829394345289 Mon Sep 17 00:00:00 2001 From: laurajauch Date: Thu, 8 Mar 2018 20:08:48 -0500 Subject: [PATCH 1/3] python 3 range modified to work with python 3 --- sword_to_json.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sword_to_json.py b/sword_to_json.py index 9ae071c..6980efa 100644 --- a/sword_to_json.py +++ b/sword_to_json.py @@ -13,9 +13,9 @@ def generate_dict(source_file, bible_version): for book in books: chapters = [] - for chapter in xrange(1, book.num_chapters+1): + for chapter in range(1, book.num_chapters+1): verses = [] - for verse in xrange(1, len(book.get_indicies(chapter))+1 ): + for verse in range(1, len(book.get_indicies(chapter))+1 ): verses.append({ 'verse': verse, 'chapter': chapter, @@ -49,4 +49,4 @@ def main(): bible_dict = generate_dict(args.source_file, args.bible_version) write_json(bible_dict, args.output_file) -if __name__ == "__main__": main() \ No newline at end of file +if __name__ == "__main__": main() From 2b0b6da6f0cebdb297d85b42698572750148746c Mon Sep 17 00:00:00 2001 From: laurajauch Date: Thu, 8 Mar 2018 20:13:53 -0500 Subject: [PATCH 2/3] py 2 AND 3 support Now it works for both! --- sword_to_json.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sword_to_json.py b/sword_to_json.py index 6980efa..e59529f 100644 --- a/sword_to_json.py +++ b/sword_to_json.py @@ -1,4 +1,5 @@ from pysword.modules import SwordModules +from past.builtins import xrange import argparse, json def generate_dict(source_file, bible_version): @@ -13,9 +14,9 @@ def generate_dict(source_file, bible_version): for book in books: chapters = [] - for chapter in range(1, book.num_chapters+1): + for chapter in xrange(1, book.num_chapters+1): verses = [] - for verse in range(1, len(book.get_indicies(chapter))+1 ): + for verse in xrange(1, len(book.get_indicies(chapter))+1 ): verses.append({ 'verse': verse, 'chapter': chapter, From 2ca5daff45147ca587047f48cf255b51cbedd515 Mon Sep 17 00:00:00 2001 From: laurajauch Date: Thu, 8 Mar 2018 20:37:14 -0500 Subject: [PATCH 3/3] Version check Check python version and import from past if necessary --- sword_to_json.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sword_to_json.py b/sword_to_json.py index e59529f..caf3dcb 100644 --- a/sword_to_json.py +++ b/sword_to_json.py @@ -1,6 +1,9 @@ from pysword.modules import SwordModules -from past.builtins import xrange -import argparse, json +import argparse, json, sys + +if sys.version_info > (3, 0): + from past.builtins import xrange + def generate_dict(source_file, bible_version): modules = SwordModules(source_file)