scripts for my gemini capsule
web, oeb: fix small passage selection in python script
Zach DeCook 2021-04-22
parent ebf3e79 · commit 9618a31
-rwxr-xr-xoeb.py6
-rwxr-xr-xwebp.py6
2 files changed, 6 insertions, 6 deletions
diff --git a/oeb.py b/oeb.py
index ce4718c..7d8c786 100755
--- a/oeb.py
+++ b/oeb.py
@@ -23,6 +23,7 @@ def main(qs):
print('=> gemini://gemini.zachdecook.com/usfm2gmi/ and rendered with usfm2gmi')
for passage in passages:
printing = 0
+ inendc = False
book=passage.start.format('b').upper()
eprint(book)
fname=sco(['find', 'oeb/', '-iname', f'*-{book}*']).strip()
@@ -37,15 +38,14 @@ def main(qs):
startv= passage.start.verse
endc = passage.end.chapter
endv= passage.end.verse
- endmark = passage.end.format('a c:v')
for line in f:
if f'\\c {startc}' == line.strip():
printing = 1
if printing == 1 and (f'\\v {startv} ') in line:
printing =2
if (f'\\c {endc}') == line.strip():
- printing = 3
- if printing == 3 and (f'\\v {endv+1} ') in line:
+ inendc = True
+ if inendc and (f'\\v {endv+1} ') in line:
printing =0
if (f'\\c {endc+1}') in line.strip():
printing =0
diff --git a/webp.py b/webp.py
index b747d0d..49f9f2d 100755
--- a/webp.py
+++ b/webp.py
@@ -31,6 +31,7 @@ def main(qs):
for passage in passages:
print("# " + passage.format())
printing = 0
+ inendc = False
bookabbrev=passage.start.format('a').upper()
fname = subprocess.check_output([f"find", "webp/", "-name", f'*-{bookabbrev}*']).strip()
eprint(fname)
@@ -39,15 +40,14 @@ def main(qs):
startv= passage.start.verse
endc = passage.end.chapter
endv= passage.end.verse
- endmark = passage.end.format('a c:v')
for line in f:
if f'\\c {startc} ' in line:
printing = 1
if printing == 1 and (f'\\v {startv} ') in line:
printing =2
if (f'\\c {endc} ') in line:
- printing = 3
- if printing == 3 and (f'\\v {endv+1} ') in line:
+ inendc = True
+ if inendc and (f'\\v {endv+1} ') in line:
printing =0
if (f'\\c {endc+1} ') in line:
printing =0