scripts for my gemini capsule
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
|
#!/usr/bin/env python3
# pip3 install bible-passage-reference-parser
from bible import parse_string
import os
import sys
def printf(line):
if line.strip():
notref = ' '.join(line.split(' ')[2:]).strip()
notref = notref.replace('||', "\n")
print(notref, end=' ')
else:
print()
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
def main(qs):
if not qs:
print("10 Enter a scripture reference\r\n")
return
passages = parse_string(qs)
# TODO: Also handle "john 3, tomato 2" errors?
if type(passages[0]) == tuple:
print("51 " + str(passages[0][0]) + "'\r\n")
return
print("20 text/gemini\r\n")
print("=> https://www.lsvbible.com/p/get-lsv.html Literal Standard Version text from lsvbible.com (CC-BY-ND-NC)")
for passage in passages:
print("# " + passage.format())
printing = False
f = open('lsv.txt')
startmark = passage.start.format('a c:v')
eprint(startmark)
endmark = passage.end.format('a c:v')
for line in f:
if (startmark+' ') in line:
printing = True
elif endmark in line:
printf(line)
printing = False
if printing:
printf(line)
print('(LSV)') #end in newline
if __name__ == '__main__':
qs = os.getenv("QUERY_STRING") or (sys.argv[1] if len(sys.argv) >= 2 else '')
main(qs)
|