-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlsandbox.py
More file actions
169 lines (150 loc) · 4.88 KB
/
lsandbox.py
File metadata and controls
169 lines (150 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import json;
import math;
import time;
import random as rng;
import sys;
import textwrap;
import urllib.request;
from datetime import datetime;
from datetime import timedelta;
import requests;
from bs4 import BeautifulSoup;
from PIL import Image;
today= datetime.today();
# dictionary to connect USCCB link keys to bible book names
booknames= {
'GN': "Genesis",
'EX': "Exodus",
'LV': "Leviticus",
'NM': "Numbers",
'DT': "Deuteronomy",
'JOS': "Joshua",
'JGS': "Judges",
'RU': "Ruth",
'1 SM': "1 Samuel",
'2 SM': "2 Samuel",
'1 KGS': "1 Kings",
'2 KGS': "2 Kings",
'1 CHR': "1 Chronicles",
'2 CHR': "2 Chronicles",
'EZR': "Ezra",
'NEH': "Nehemiah",
'TB': "Tobit",
'JDT': "Judith",
'JUDITH': "Judith", # weird bug
'EST': "Esther",
'1 MC': "1 Maccabees",
'2 MC': "2 Maccabees",
'JB': "Job",
'PS': "Psalms",
'PRV': "Proverbs",
'ECCL': "Ecclesiastes",
'SG': "Song of Songs",
'WIS': "Wisdom",
'SIR': "Sirach",
'IS': "Isaiah",
'1 IS': "Isaiah", # weird bug
'JER': "Jeremiah",
'LAM': "Lamentations",
'BAR': "Baruch",
'EZ': "Ezekiel",
'DN': "Daniel",
'HOS': "Hosea",
'JL': "Joel",
'AM': "Amos",
'OB': "Obadiah",
'JON': "Jonah",
'MI': "Micah",
'NA': "Nahum",
'HB': "Habakkuk",
'ZEP': "Zephaniah",
'HG': "Haggai",
'ZEC': "Zechariah",
'MAL': "Malachi",
'MT': "Matthew",
'MK': "Mark",
'LK': "Luke",
'JN': "John",
'ACTS': "Acts",
'ROM': "Romans",
'1 COR': "1 Corinthians",
'2 COR': "2 Corinthians",
'GAL': "Galatians",
'EPH': "Ephesians",
'PHIL': "Philippians",
'COL': "Colossians",
'1 THES': "1 Thessalonians",
'2 THES': "2 Thessalonians",
'1 TM': "1 Timothy",
'2 TM': "2 Timothy",
'TI': "Titus",
'PHLM': "Philemon",
'HEB': "Hebrews",
'JAS': "James",
'1 PT': "1 Peter",
'2 PT': "2 Peter",
'1 JN': "1 John",
'2 JN': "2 John",
'3 JN': "3 John",
'JUDE': "Jude",
'RV': "Revelation",
};
url_raw= "https://raw.githubusercontent.com/conciergewebco/weekly-readings/master/weekly-readings-api.json";
with urllib.request.urlopen(url_raw) as url_data:
reading_data= json.loads(url_data.read().decode());
# dig down to the data of interest
reading_data= reading_data['dates'];
# reading_data= reading_data["%04d" % today.year];
# reading_data= reading_data["%02d" % today.month];
# reading_data= reading_data["%02d" % today.day];
seasons= [];
# print stuff
def handler(reading_data):
output= {};
for key in reading_data.keys():
print("%s:" % key);
if key == 'readings':
for reading_key in reading_data['readings'].keys():
book= None;
chapverse= None;
print("\t%s:" % reading_key);
swapped= False;
for bk_key in booknames.keys():
if reading_data[key][reading_key].startswith(bk_key):
book= booknames[bk_key];
chapverse= reading_data[key][reading_key][(len(bk_key) + 1):];
print("\t\t%s" % reading_data[key][reading_key].replace(
bk_key, booknames[bk_key]));
print("\t\t\t%s" % book);
print("\t\t\t%s" % chapverse);
swapped= True;
break;
if not swapped:
raise Exception("invalid bible book key: %s" %
reading_data[key][reading_key]);
elif key == 'title':
width_matrix= 64;
width_char= 6;
buffer= 2;
numchars= math.floor((width_matrix - 2*buffer)/width_char);
title_printable= textwrap.wrap(reading_data['title'], numchars);
print("\t%s" % reading_data['title']);
for line in title_printable:
print("\t\t%s" % line);
elif key == 'lit_season':
if reading_data['lit_season'] not in seasons:
seasons.append(reading_data['lit_season']);
print("\t%s" % reading_data[key]);
else:
print("\t%s" % reading_data[key]);
output[key]= {}
for year_key in reading_data.keys():
for month_key in reading_data[year_key].keys():
for day_key in reading_data[year_key][month_key].keys():
# print(reading_data[year_key][month_key][day_key]);
handler(reading_data[year_key][month_key][day_key]);
# handler(reading_data);
print("\nseasons:")
for season in seasons:
print("\t%s" % season);
print();