aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Moch2018-02-24 09:38:00 -0500
committerDaniel Moch2018-02-24 09:38:00 -0500
commit848900be544ae5aa09f22fd35ac4f39520932fd2 (patch)
treeab5cfc913589059225c6a2f3204f6cbb5c12b1c5
parentda54e3f22d220b340afbf7ea543863d82229726a (diff)
downloadcbr-schedule-848900be544ae5aa09f22fd35ac4f39520932fd2.tar.gz
Initial generate_readings and associated inputs
Create initial generate_readings script to take semi-structured input files and "compile" them into more rationally structured outputs. Outputs will be fed into another script that generates the actual readings for a given year.
-rwxr-xr-xgenerate_readings59
-rw-r--r--sections/new_testament.in29
-rw-r--r--sections/old_testament.in38
-rw-r--r--sections/psalms.in3
4 files changed, 129 insertions, 0 deletions
diff --git a/generate_readings b/generate_readings
new file mode 100755
index 0000000..c6e18a1
--- /dev/null
+++ b/generate_readings
@@ -0,0 +1,59 @@
+#!/usr/bin/env python3
+#
+# The MIT License (MIT)
+#
+# Copyright (c) 2018 Daniel Moch
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+import json
+from sys import argv
+
+def generate_readings(infilename):
+ with open(infilename, 'r') as infile:
+ section = json.load(infile)
+
+ filename = str.join('.', infilename.split('.')[0:-1]) + '.json'
+ readings = []
+ idx = 0
+ for book, info in section:
+ 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
+
+ with open(filename, 'w') as outfile:
+ json.dump(readings, outfile)
+
+def print_usage():
+ print('Usage: generate_readings infile')
+ print('\tinfile: JSON-encoded input file')
+
+if __name__ == '__main__':
+ if len(argv) != 2:
+ print_usage()
+ exit(1)
+ else:
+ generate_readings(argv[1])
diff --git a/sections/new_testament.in b/sections/new_testament.in
new file mode 100644
index 0000000..739beea
--- /dev/null
+++ b/sections/new_testament.in
@@ -0,0 +1,29 @@
+[
+ ["Luke", [24]],
+ ["Acts", [28]],
+ ["Romans", [16]],
+ ["1 Corinthians", [16]],
+ ["2 Corinthians", [13]],
+ ["Galatians", [6]],
+ ["Ephesians", [6]],
+ ["Philippians", [4]],
+ ["Colossians", [4]],
+ ["1 Thessalonians", [5]],
+ ["2 Thessalonians", [3]],
+ ["1 Timothy", [6]],
+ ["2 Timothy", [4]],
+ ["Titus", [3]],
+ ["Philemon", [1]],
+ ["John", [21]],
+ ["1 John", [5]],
+ ["2 John", [1]],
+ ["3 John", [1]],
+ ["Revelation", [22]],
+ ["Mark", [16]],
+ ["1 Peter", [5]],
+ ["2 Peter", [3]],
+ ["Hebrews", [13]],
+ ["James", [5]],
+ ["Matthew", [28]],
+ ["Jude", [1]]
+]
diff --git a/sections/old_testament.in b/sections/old_testament.in
new file mode 100644
index 0000000..8d3c2fc
--- /dev/null
+++ b/sections/old_testament.in
@@ -0,0 +1,38 @@
+[
+ ["Genesis", [50]],
+ ["Exodus", [40]],
+ ["Leviticus", [27]],
+ ["Numbers", [36]],
+ ["Deuteronomy", [34]],
+ ["Joshua", [24]],
+ ["Judges", [21]],
+ ["Ruth", [4]],
+ ["1 Samuel", [31]],
+ ["2 Samuel", [24]],
+ ["1 Kings", [22]],
+ ["2 Kings", [25]],
+ ["1 Chronicles", [29]],
+ ["2 Chronicles", [36]],
+ ["Ezra", [10]],
+ ["Job", [42]],
+ ["Proverbs", [31]],
+ ["Ecclesiastes", [12]],
+ ["Song of Solomon", [8]],
+ ["Isaiah", [66]],
+ ["Jeremiah", [52]],
+ ["Lamentations", [5]],
+ ["Ezekiel", [48]],
+ ["Daniel", [12]],
+ ["Hosea", [14]],
+ ["Joel", [3]],
+ ["Amos", [9]],
+ ["Obadiah", [1]],
+ ["Jonah", [4]],
+ ["Micah", [7]],
+ ["Nahum", [3]],
+ ["Habakkuk", [3]],
+ ["Zephaniah", [3]],
+ ["Haggai", [2]],
+ ["Zechariah", [14]],
+ ["Malachi", [4]]
+]
diff --git a/sections/psalms.in b/sections/psalms.in
new file mode 100644
index 0000000..e1f0f3b
--- /dev/null
+++ b/sections/psalms.in
@@ -0,0 +1,3 @@
+[
+ ["Psalms", [150, {"119": ["1-24", "25-48", "49-72", "73-96", "97-120", "121-144", "145-168", "169-176"]}]]
+]