Skip to content

Commit

Permalink
added chapter::: and compare comparechapter:::
Browse files Browse the repository at this point in the history
  • Loading branch information
eliranwong committed Oct 31, 2024
1 parent 799dec6 commit 6950d25
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
# https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/
setup(
name=package,
version="0.1.43",
version="0.1.45",
python_requires=">=3.8, <3.13",
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",
long_description=long_description,
Expand Down
2 changes: 1 addition & 1 deletion uniquebible/db/BiblesSqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def getVerses(self, b=config.mainB, c=config.mainC, text=""):
return " ".join(["{0}{1}</ref>".format(self.formVerseTag(b, c, verse, text), verse) for verse in verseList])

def compareVerse(self, verseList, texts=["ALL"]):
if len(verseList) == 1 and not texts == ["ALL"]:
if len(verseList) == 1 and not texts == ["ALL"] and not config.rawOutput:
b, c, v, *_ = verseList[0]
return self.compareVerseChapter(b, c, v, texts)
else:
Expand Down
81 changes: 78 additions & 3 deletions uniquebible/util/TextCommandParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def __init__(self, parent):
# e.g. BIBLE:::Jn 3:16; Rm 5:8; Deu 6:4
# e.g. BIBLE:::KJV:::John 3:16
# e.g. BIBLE:::KJV:::Jn 3:16; Rm 5:8; Deu 6:4"""),
"chapter": (self.textFormattedChapter, """
# [KEYWORD] CHAPTER
# Feature - Open bible versions of a single chapter.
# Usage - CHAPTER:::[BIBLE_VERSION(S)]:::[BIBLE_CHAPTER]"""),
"main": (self.textMain, """
# [KEYWORD] MAIN
# Feature - Open a bible chapter or multiples verses on main view.
Expand Down Expand Up @@ -143,6 +147,10 @@ def __init__(self, parent):
# e.g. COMPARE:::John 3:16
# e.g. COMPARE:::KJV_NET_CUV:::John 3:16
# e.g. COMPARE:::KJV_NET_CUV:::John 3:16; Rm 5:8"""),
"comparechapter": (self.textCompareChapter, """
# [KEYWORD] COMPARECHAPTER
# Feature - Compare bible versions of a single chapter.
# Usage - COMPARECHAPTER:::[BIBLE_VERSION(S)]:::[BIBLE_CHAPTER]"""),
"sidebyside": (self.textCompareSideBySide, """
# [KEYWORD] SIDEBYSIDE
# Feature - Compare bible versions side by side
Expand Down Expand Up @@ -1445,6 +1453,38 @@ def textFormattedBible(self, verse, text, source=""):
content = f"{content}<br>{config.mainWindow.divider}<br>{singleVerse}"
return content

def textFormattedChapter(self, command, source):
if command.count(":::") == 0:
if config.openBibleInMainViewOnly:
updateViewConfig, viewText, *_ = self.getViewConfig("main")
else:
updateViewConfig, viewText, *_ = self.getViewConfig(source)
command = "{0}:::{1}".format(viewText, command)
texts, references = self.splitCommand(command)
verseList = self.extractAllVerses(references)
if not verseList:
return self.invalidCommand()
texts = self.getConfirmedTexts(texts)
marvelBibles = self.getMarvelBibles()
if not texts:
return self.invalidCommand()
else:
self.cancelBibleParallels()
text = texts[0]
if text in marvelBibles:
fileItems = marvelBibles[text][0]
if os.path.isfile(os.path.join(*fileItems)):
content = self.textFormattedBible(verseList[0], text, source)
return ("main", content, {})
else:
databaseInfo = marvelBibles[text]
if self.parent is not None:
self.parent.downloadHelper(databaseInfo)
return ("", "", {})
else:
content = self.textFormattedBible(verseList[0], text, source)
return ("main", content, {})

# cmd:::
# run os command
def osCommand(self, command, source):
Expand Down Expand Up @@ -2540,10 +2580,13 @@ def distinctTranslation(self, command, source):
display = " | ".join(translations)
return ("study", display, {})

def getAllFavouriteBibles(self):
return sorted(set([config.mainText, config.favouriteBible, config.favouriteBible2, config.favouriteBible3, config.favouriteBiblePrivate, config.favouriteBiblePrivate2, config.favouriteBiblePrivate3]))

# COMPARE:::
def textCompare(self, command, source):
if command.count(":::") == 0:
confirmedTexts = ["ALL"]
confirmedTexts = self.getAllFavouriteBibles()
verseList = self.extractAllVerses(command)
else:
texts, references = self.splitCommand(command)
Expand All @@ -2559,8 +2602,9 @@ def textCompare(self, command, source):
config.mainCssBibleFontStyle = ""
texts = confirmedTexts
if confirmedTexts == ["ALL"]:
plainBibleList, formattedBibleList = biblesSqlite.getTwoBibleLists()
texts = set(plainBibleList + formattedBibleList)
#plainBibleList, formattedBibleList = biblesSqlite.getTwoBibleLists()
#texts = set(plainBibleList + formattedBibleList)
texts = self.getAllFavouriteBibles()
for text in texts:
(fontFile, fontSize, css) = Bible(text).getFontInfo()
config.mainCssBibleFontStyle += css
Expand All @@ -2569,6 +2613,37 @@ def textCompare(self, command, source):
updateViewConfig(viewText, verseList[-1])
return ("study" if config.compareOnStudyWindow else "main", verses, {})

# COMPARECHAPTER:::
def textCompareChapter(self, command, source):
if command.count(":::") == 0:
confirmedTexts = self.getAllFavouriteBibles()
verseList = self.extractAllVerses(command)
else:
texts, references = self.splitCommand(command)
confirmedTexts = self.getConfirmedTexts(texts)
verseList = self.extractAllVerses(references)
if not confirmedTexts or not verseList:
return self.invalidCommand()
else:
if config.runMode == "terminal" and not confirmedTexts == ["ALL"]:
config.compareParallelList = confirmedTexts
config.terminalBibleComparison = True
biblesSqlite = BiblesSqlite()
config.mainCssBibleFontStyle = ""
texts = confirmedTexts
if confirmedTexts == ["ALL"]:
#plainBibleList, formattedBibleList = biblesSqlite.getTwoBibleLists()
texts = self.getAllFavouriteBibles()
for text in texts:
(fontFile, fontSize, css) = Bible(text).getFontInfo()
config.mainCssBibleFontStyle += css
#verses = biblesSqlite.compareVerse(verseList, confirmedTexts)
b, c, v, *_ = verseList[0]
verses = biblesSqlite.compareVerseChapter(b, c, v, confirmedTexts)
updateViewConfig, viewText, *_ = self.getViewConfig(source)
updateViewConfig(viewText, verseList[0])
return ("study" if config.compareOnStudyWindow else "main", verses, {})

# SIDEBYSIDE:::
def textCompareSideBySide(self, command, source):
if command.count(":::") == 0:
Expand Down

0 comments on commit 6950d25

Please sign in to comment.