From 6e07db43e3efb4b9eb176ae0229bff0cc81737b3 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Mon, 11 Dec 2023 20:04:39 -0500 Subject: [PATCH] biblestudy: add hboWLC --- .gitignore | 2 ++ Open-English-Bible | 2 +- biblestudy.py | 4 ++- getscriptures.sh | 7 ++++++ hboWLC.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++ usfm2gmi | 2 +- 6 files changed, 75 insertions(+), 3 deletions(-) create mode 100755 hboWLC.py diff --git a/.gitignore b/.gitignore index e786896..aca85cb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ __pycache__ webp lsv.txt bsb +tcgnt +hboWLC diff --git a/Open-English-Bible b/Open-English-Bible index 7a6ba38..2370ba8 160000 --- a/Open-English-Bible +++ b/Open-English-Bible @@ -1 +1 @@ -Subproject commit 7a6ba3802d9d1281a4e330892ffdac2262085182 +Subproject commit 2370ba8b161fff645b22a9501c33ba7a603c62c6 diff --git a/biblestudy.py b/biblestudy.py index 71cea74..65f55e2 100755 --- a/biblestudy.py +++ b/biblestudy.py @@ -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) diff --git a/getscriptures.sh b/getscriptures.sh index 1d0f843..2c1e8e8 100644 --- a/getscriptures.sh +++ b/getscriptures.sh @@ -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 diff --git a/hboWLC.py b/hboWLC.py new file mode 100755 index 0000000..ecdb9e1 --- /dev/null +++ b/hboWLC.py @@ -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) diff --git a/usfm2gmi b/usfm2gmi index 55ed7b3..a9e497d 160000 --- a/usfm2gmi +++ b/usfm2gmi @@ -1 +1 @@ -Subproject commit 55ed7b33bb8f11aafe68167e310b8df7b6b06413 +Subproject commit a9e497dbee245754bceed9bc773485309986845e -- 2.45.2