Skip to content

Commit 6950d25

Browse files
committed
added chapter::: and compare comparechapter:::
1 parent 799dec6 commit 6950d25

File tree

3 files changed

+80
-5
lines changed

3 files changed

+80
-5
lines changed

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
# https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/
4848
setup(
4949
name=package,
50-
version="0.1.43",
50+
version="0.1.45",
5151
python_requires=">=3.8, <3.13",
5252
description=f"UniqueBible App is a cross-platform & offline bible application, integrated with high-quality resources and unique features. Developers: Eliran Wong and Oliver Tseng",
5353
long_description=long_description,

uniquebible/db/BiblesSqlite.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def getVerses(self, b=config.mainB, c=config.mainC, text=""):
323323
return " ".join(["{0}{1}</ref>".format(self.formVerseTag(b, c, verse, text), verse) for verse in verseList])
324324

325325
def compareVerse(self, verseList, texts=["ALL"]):
326-
if len(verseList) == 1 and not texts == ["ALL"]:
326+
if len(verseList) == 1 and not texts == ["ALL"] and not config.rawOutput:
327327
b, c, v, *_ = verseList[0]
328328
return self.compareVerseChapter(b, c, v, texts)
329329
else:

uniquebible/util/TextCommandParser.py

+78-3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ def __init__(self, parent):
9191
# e.g. BIBLE:::Jn 3:16; Rm 5:8; Deu 6:4
9292
# e.g. BIBLE:::KJV:::John 3:16
9393
# e.g. BIBLE:::KJV:::Jn 3:16; Rm 5:8; Deu 6:4"""),
94+
"chapter": (self.textFormattedChapter, """
95+
# [KEYWORD] CHAPTER
96+
# Feature - Open bible versions of a single chapter.
97+
# Usage - CHAPTER:::[BIBLE_VERSION(S)]:::[BIBLE_CHAPTER]"""),
9498
"main": (self.textMain, """
9599
# [KEYWORD] MAIN
96100
# Feature - Open a bible chapter or multiples verses on main view.
@@ -143,6 +147,10 @@ def __init__(self, parent):
143147
# e.g. COMPARE:::John 3:16
144148
# e.g. COMPARE:::KJV_NET_CUV:::John 3:16
145149
# e.g. COMPARE:::KJV_NET_CUV:::John 3:16; Rm 5:8"""),
150+
"comparechapter": (self.textCompareChapter, """
151+
# [KEYWORD] COMPARECHAPTER
152+
# Feature - Compare bible versions of a single chapter.
153+
# Usage - COMPARECHAPTER:::[BIBLE_VERSION(S)]:::[BIBLE_CHAPTER]"""),
146154
"sidebyside": (self.textCompareSideBySide, """
147155
# [KEYWORD] SIDEBYSIDE
148156
# Feature - Compare bible versions side by side
@@ -1445,6 +1453,38 @@ def textFormattedBible(self, verse, text, source=""):
14451453
content = f"{content}<br>{config.mainWindow.divider}<br>{singleVerse}"
14461454
return content
14471455

1456+
def textFormattedChapter(self, command, source):
1457+
if command.count(":::") == 0:
1458+
if config.openBibleInMainViewOnly:
1459+
updateViewConfig, viewText, *_ = self.getViewConfig("main")
1460+
else:
1461+
updateViewConfig, viewText, *_ = self.getViewConfig(source)
1462+
command = "{0}:::{1}".format(viewText, command)
1463+
texts, references = self.splitCommand(command)
1464+
verseList = self.extractAllVerses(references)
1465+
if not verseList:
1466+
return self.invalidCommand()
1467+
texts = self.getConfirmedTexts(texts)
1468+
marvelBibles = self.getMarvelBibles()
1469+
if not texts:
1470+
return self.invalidCommand()
1471+
else:
1472+
self.cancelBibleParallels()
1473+
text = texts[0]
1474+
if text in marvelBibles:
1475+
fileItems = marvelBibles[text][0]
1476+
if os.path.isfile(os.path.join(*fileItems)):
1477+
content = self.textFormattedBible(verseList[0], text, source)
1478+
return ("main", content, {})
1479+
else:
1480+
databaseInfo = marvelBibles[text]
1481+
if self.parent is not None:
1482+
self.parent.downloadHelper(databaseInfo)
1483+
return ("", "", {})
1484+
else:
1485+
content = self.textFormattedBible(verseList[0], text, source)
1486+
return ("main", content, {})
1487+
14481488
# cmd:::
14491489
# run os command
14501490
def osCommand(self, command, source):
@@ -2540,10 +2580,13 @@ def distinctTranslation(self, command, source):
25402580
display = " | ".join(translations)
25412581
return ("study", display, {})
25422582

2583+
def getAllFavouriteBibles(self):
2584+
return sorted(set([config.mainText, config.favouriteBible, config.favouriteBible2, config.favouriteBible3, config.favouriteBiblePrivate, config.favouriteBiblePrivate2, config.favouriteBiblePrivate3]))
2585+
25432586
# COMPARE:::
25442587
def textCompare(self, command, source):
25452588
if command.count(":::") == 0:
2546-
confirmedTexts = ["ALL"]
2589+
confirmedTexts = self.getAllFavouriteBibles()
25472590
verseList = self.extractAllVerses(command)
25482591
else:
25492592
texts, references = self.splitCommand(command)
@@ -2559,8 +2602,9 @@ def textCompare(self, command, source):
25592602
config.mainCssBibleFontStyle = ""
25602603
texts = confirmedTexts
25612604
if confirmedTexts == ["ALL"]:
2562-
plainBibleList, formattedBibleList = biblesSqlite.getTwoBibleLists()
2563-
texts = set(plainBibleList + formattedBibleList)
2605+
#plainBibleList, formattedBibleList = biblesSqlite.getTwoBibleLists()
2606+
#texts = set(plainBibleList + formattedBibleList)
2607+
texts = self.getAllFavouriteBibles()
25642608
for text in texts:
25652609
(fontFile, fontSize, css) = Bible(text).getFontInfo()
25662610
config.mainCssBibleFontStyle += css
@@ -2569,6 +2613,37 @@ def textCompare(self, command, source):
25692613
updateViewConfig(viewText, verseList[-1])
25702614
return ("study" if config.compareOnStudyWindow else "main", verses, {})
25712615

2616+
# COMPARECHAPTER:::
2617+
def textCompareChapter(self, command, source):
2618+
if command.count(":::") == 0:
2619+
confirmedTexts = self.getAllFavouriteBibles()
2620+
verseList = self.extractAllVerses(command)
2621+
else:
2622+
texts, references = self.splitCommand(command)
2623+
confirmedTexts = self.getConfirmedTexts(texts)
2624+
verseList = self.extractAllVerses(references)
2625+
if not confirmedTexts or not verseList:
2626+
return self.invalidCommand()
2627+
else:
2628+
if config.runMode == "terminal" and not confirmedTexts == ["ALL"]:
2629+
config.compareParallelList = confirmedTexts
2630+
config.terminalBibleComparison = True
2631+
biblesSqlite = BiblesSqlite()
2632+
config.mainCssBibleFontStyle = ""
2633+
texts = confirmedTexts
2634+
if confirmedTexts == ["ALL"]:
2635+
#plainBibleList, formattedBibleList = biblesSqlite.getTwoBibleLists()
2636+
texts = self.getAllFavouriteBibles()
2637+
for text in texts:
2638+
(fontFile, fontSize, css) = Bible(text).getFontInfo()
2639+
config.mainCssBibleFontStyle += css
2640+
#verses = biblesSqlite.compareVerse(verseList, confirmedTexts)
2641+
b, c, v, *_ = verseList[0]
2642+
verses = biblesSqlite.compareVerseChapter(b, c, v, confirmedTexts)
2643+
updateViewConfig, viewText, *_ = self.getViewConfig(source)
2644+
updateViewConfig(viewText, verseList[0])
2645+
return ("study" if config.compareOnStudyWindow else "main", verses, {})
2646+
25722647
# SIDEBYSIDE:::
25732648
def textCompareSideBySide(self, command, source):
25742649
if command.count(":::") == 0:

0 commit comments

Comments
 (0)