aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Moch2018-02-24 10:27:49 -0500
committerDaniel Moch2018-02-24 10:27:49 -0500
commit875b62f9bc36a73b76bfc9f3f756b353a09b4747 (patch)
tree00e354062e0c88007ed2168190caa4c8f7aeb825
parent848900be544ae5aa09f22fd35ac4f39520932fd2 (diff)
downloadcbr-schedule-875b62f9bc36a73b76bfc9f3f756b353a09b4747.tar.gz
Handle edge case in generate_readings
The initial commit failed to handle an edge case where a chapter is not read in a single day (currently the only case of this is Psalm 119). This version of generate_readings accounts for this.
-rwxr-xr-xgenerate_readings30
1 files changed, 23 insertions, 7 deletions
diff --git a/generate_readings b/generate_readings
index c6e18a1..02dde1e 100755
--- a/generate_readings
+++ b/generate_readings
@@ -33,16 +33,32 @@ def generate_readings(infilename):
readings = []
idx = 0
for book, info in section:
+ subchapter_readings = ()
+ if len(info) > 1:
+ subchapter_readings = info[1]
chapters = info[0]
chapter = 1
while chapter <= chapters:
- reading = {}
- reading['index'] = idx
- reading['book'] = book
- reading['chapter'] = chapter
- readings.append(reading)
- idx += 1
- chapter += 1
+ chapter_str = str(chapter)
+ if chapter_str in subchapter_readings:
+ for subchapter_reading in \
+ subchapter_readings[chapter_str]:
+ reading = {}
+ reading['index'] = idx
+ reading['book'] = book
+ reading['reading'] = chapter_str + ':' + \
+ subchapter_reading
+ readings.append(reading)
+ idx += 1
+ chapter += 1
+ else:
+ reading = {}
+ reading['index'] = idx
+ reading['book'] = book
+ reading['reading'] = chapter_str
+ readings.append(reading)
+ idx += 1
+ chapter += 1
with open(filename, 'w') as outfile:
json.dump(readings, outfile)