~earboxer/cgi-bin

6e07db43e3efb4b9eb176ae0229bff0cc81737b3 — Zach DeCook 2 months ago c07fe9c master
biblestudy: add hboWLC
6 files changed, 75 insertions(+), 3 deletions(-)

M .gitignore
M Open-English-Bible
M biblestudy.py
M getscriptures.sh
A hboWLC.py
M usfm2gmi
M .gitignore => .gitignore +2 -0
@@ 2,3 2,5 @@ __pycache__
webp
lsv.txt
bsb
tcgnt
hboWLC

M Open-English-Bible => Open-English-Bible +1 -1
@@ 1,1 1,1 @@
Subproject commit 7a6ba3802d9d1281a4e330892ffdac2262085182
Subproject commit 2370ba8b161fff645b22a9501c33ba7a603c62c6

M biblestudy.py => biblestudy.py +3 -1
@@ 9,6 9,7 @@ from oeb import printoeb
from webp import printwebp
from bsb import printbsb
from tcgnt import printtcgnt
from hboWLC import printhboWLC

def main(qs):
  if not qs:


@@ 29,7 30,8 @@ def main(qs):
  print()
  printtcgnt([passages[0]], False, False)
  printtcgnt([passages[0]], False, False, printStrongs=True)

  printhboWLC([passages[0]], False, False)
  printhboWLC([passages[0]], False, False, printStrongs=True)




M getscriptures.sh => getscriptures.sh +7 -0
@@ 11,6 11,12 @@ gettcgnt() {
	unzip grctcgnt_usfm.zip -d tcgnt
	rm grctcgnt_usfm.zip
}
gethboWLC() {
	wget https://ebible.org/Scriptures/hboWLC_usfm.zip
	mkdir -p hboWLC
	unzip hboWLC_usfm.zip -d hboWLC
	rm hboWLC_usfm.zip
}
getlsv() {
	url="$(wget -O - https://www.lsvbible.com/p/get-lsv.html | grep Plain\ Text | grep -o 'https://[^"]*' | sed 's/amp;//g')"
	wget -O lsv.zip "$url"


@@ 28,3 34,4 @@ test -d webp || getweb
test -f lsv.txt || getlsv
test -d bsb || getbsb
test -d tcgnt || gettcgnt
test -d hboWLC || gethboWLC

A hboWLC.py => hboWLC.py +61 -0
@@ 0,0 1,61 @@
#!/usr/bin/env python3
# pip3 install bible-passage-reference-parser
from bible import parse_string
import usfm2gmi.usfm2gmi as usfm2gmi
import os
import sys
import subprocess
from webp import printf
from webp import eprint

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")
  printhboWLC(passages)

def printhboWLC(passages, title=True, plug=True, printStrongs=False):
  books=subprocess.check_output([f"find", "hboWLC/", "-name", f'??-*.usfm']).strip().split(b"\n")
  books.sort()
  if plug:
    print('=>https://ebible.org/find/details.php?id=grctcgnt This content from Westminster Leningrad Codex Hebrew OT (public domain)')
    print('=> gemini://gemini.zachdecook.com/usfm2gmi/ and rendered with usfm2gmi')
  for passage in passages:
    if title:
      print("# " + passage.format())
    printing = 0
    inendc = False
    bookn = passage.start.book
    #eprint(bookn)
    if bookn > 66-27:
      return
    f = open(books[bookn-1])
    startc = passage.start.chapter
    startv= passage.start.verse
    endc = passage.end.chapter
    endv= passage.end.verse
    for line in f:
      if f'\\c ' in line and f' {startc} ' in line:
        printing = 1
      if printing == 1 and (f'\\v {startv} ') in line:
        printing =2
      if f'\\c ' in line and f' {endc} ' in line:
        inendc = True
      if inendc and (f'\\v {endv+1} ') in line:
        printing =0
      if f'\\c ' in line and f' {endc+1} ' in line:
        printing =0

      if printing>=2:
        printf(line, printStrongs)
    print('(hboWLC)') #end in newline

if __name__ == '__main__':
  qs = os.getenv("QUERY_STRING") or (sys.argv[1] if len(sys.argv) >= 2 else '')
  main(qs)

M usfm2gmi => usfm2gmi +1 -1
@@ 1,1 1,1 @@
Subproject commit 55ed7b33bb8f11aafe68167e310b8df7b6b06413
Subproject commit a9e497dbee245754bceed9bc773485309986845e