Skip to content

Commit 0f045a4

Browse files
committed
improved API output
1 parent 91afa9f commit 0f045a4

File tree

5 files changed

+31
-18
lines changed

5 files changed

+31
-18
lines changed

README.md

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
# Migration to pip package in progress
1+
# Migration to PIP Package
22

3-
We are migrating the distribution of UniqueBible App via pip package. Something may not work as usual. Please kindly report issues at https://github.com/eliranwong/UniqueBible/issues
3+
We've recently published pip packages for distributing UniqueBible App.
44

5-
To install:
6-
7-
> pip install --upgrade uniquebible
8-
9-
To run:
10-
11-
> uniquebible
5+
Read latest instructions for installation at: https://github.com/eliranwong/UniqueBible/wiki/installation#latest-updates
126

137
# UniqueBible
148

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.37",
50+
version="0.1.41",
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/latest_changes.txt

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
PIP package:
22

3+
0.1.38-0.1.41
4+
5+
* improved raw output with API endpoints
6+
7+
* output command suggestions
8+
39
0.1.37
410

511
* support user plugins, stored in ~/UniqueBible/plugins

uniquebible/util/LocalCliHandler.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1085,11 +1085,11 @@ def getCommandCompleterSuggestions(self, textCommandSuggestion=None):
10851085
elif i in ("_commentary:::",):
10861086
suggestions[i] = self.getDummyDict(self.crossPlatform.commentaryList, ".")
10871087
elif i in ("crossreference:::", "difference:::", "diff:::", "passages:::", "overview:::", "summary:::", "index:::", "chapterindex:::", "map:::", "tske:::", "combo:::", "translation:::", "discourse:::", "words:::", "openbooknote:::", "openchapternote:::", "openversenote:::", "editbooknote:::", "editchapternote:::", "editversenote:::", "_imvr:::"):
1088-
suggestions[i] = self.allKJVreferences
1088+
suggestions[i] = None if config.terminalUseLighterCompleter else self.allKJVreferences
10891089
elif i in ("_imv:::", "_instantverse:::", "_menu:::", "_openbooknote:::", "_openchapternote:::", "_openversenote:::", "_editbooknote:::", "_editchapternote:::", "_editversenote:::"):
1090-
suggestions[i] = self.allKJVreferencesBcv1
1090+
suggestions[i] = None if config.terminalUseLighterCompleter else self.allKJVreferencesBcv1
10911091
elif i in ("clause:::",):
1092-
suggestions[i] = self.allKJVreferencesBcv2
1092+
suggestions[i] = None if config.terminalUseLighterCompleter else self.allKJVreferencesBcv2
10931093
elif i in ("dictionary:::",):
10941094
suggestions[i] = self.getDummyDict(self.crossPlatform.dictionaryListAbb, ":::")
10951095
elif i in ("encyclopedia:::",):

uniquebible/util/RemoteHttpHandler.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from uniquebible.util.GitHubRepoInfo import GitHubRepoInfo
1919
from uniquebible.util.TextCommandParser import TextCommandParser
2020
from uniquebible.util.RemoteCliMainWindow import RemoteCliMainWindow
21+
from uniquebible.util.LocalCliHandler import LocalCliHandler
2122
from uniquebible.util.TextUtil import TextUtil
2223
from urllib.parse import urlparse, parse_qs
2324
from uniquebible.util.FileUtil import FileUtil
@@ -153,7 +154,7 @@ def refineCommand(self, command, mainVerse):
153154
if command in self.textCommandParser.parent.textList:
154155
command = f"TEXT:::{command}"
155156
# match a bible reference, started with book number, e.g. 43.3.16
156-
elif re.search("^[0-9]+?\.[0-9]+?\.[0-9]+?$", command):
157+
elif re.search(r"^[0-9]+?\.[0-9]+?\.[0-9]+?$", command):
157158
b, c, v = [int(i) for i in command.split(".")]
158159
command = self.textCommandParser.bcvToVerseReference(b, c, v)
159160
else:
@@ -351,9 +352,20 @@ def do_GET(self):
351352
if cmd:
352353
self.command = query_components["cmd"][0].strip()
353354
self.command = self.command.replace("+", " ")
355+
if self.command == ".suggestions":
356+
self.commonHeader()
357+
textCommandSuggestion = [key + ":::" for key in self.textCommandParser.interpreters.keys()]
358+
terminalUseLighterCompleter = config.terminalUseLighterCompleter
359+
config.terminalUseLighterCompleter = True
360+
content = LocalCliHandler(allowPrivateData=allowPrivateData).getCommandCompleterSuggestions(textCommandSuggestion=textCommandSuggestion)
361+
config.terminalUseLighterCompleter = terminalUseLighterCompleter
362+
self.wfile.write(bytes(json.dumps(content), "utf8"))
363+
return
354364
else:
355365
self.command = "John 3:16-16"
356366
# tweak configs
367+
displayChapterMenuTogetherWithBibleChapter = config.displayChapterMenuTogetherWithBibleChapter
368+
config.displayChapterMenuTogetherWithBibleChapter = False
357369
addFavouriteToMultiRef = config.addFavouriteToMultiRef
358370
config.addFavouriteToMultiRef = False
359371
# output
@@ -375,6 +387,7 @@ def do_GET(self):
375387
self.wfile.write(bytes(content, "utf8"))
376388
# restore user config
377389
config.addFavouriteToMultiRef = addFavouriteToMultiRef
390+
config.displayChapterMenuTogetherWithBibleChapter = displayChapterMenuTogetherWithBibleChapter
378391
elif self.ignoreCommand(self.path):
379392
print(f"Ignoring command: {self.path}")
380393
self.blankPage()
@@ -1628,7 +1641,7 @@ def helpContent(self):
16281641
<p>"""
16291642
content = "\n".join(
16301643
[re.sub(" #", "#", value[-1]) for value in self.textCommandParser.interpreters.values()])
1631-
content = re.sub("(\[KEYWORD\] )(.*?)$", r"""\1<ref onclick="displayCommand('\2:::')">\2</ref>""", content, flags=re.M)
1644+
content = re.sub(r"(\[KEYWORD\] )(.*?)$", r"""\1<ref onclick="displayCommand('\2:::')">\2</ref>""", content, flags=re.M)
16321645
content = dotCommands + re.sub(r"\n", "<br/>", content) + "</p>"
16331646
return content
16341647

@@ -1684,14 +1697,14 @@ def getQrCodeCommand(self):
16841697
def getPlaylistFromHTML(self, html):
16851698
playlist = []
16861699
#searchPattern = """[Rr][Ee][Aa][Dd][Cc][Hh][Aa][Pp][Tt][Ee][Rr]:::([A-Za-z0-9]+?)\.([0-9]+?)\.([0-9]+?)[\."']"""
1687-
searchPattern = """_[Cc][Hh][Aa][Pp][Tt][Ee][Rr][Ss]:::([^\.>]+?)_([0-9]+?)\.([0-9]+?)["'].*onclick=["']rC\("""
1700+
searchPattern = r"""_[Cc][Hh][Aa][Pp][Tt][Ee][Rr][Ss]:::([^\.>]+?)_([0-9]+?)\.([0-9]+?)["'].*onclick=["']rC\("""
16881701
found = re.search(searchPattern, html)
16891702
if found:
16901703
text, b, c = found[1], found[2], found[3]
16911704
text = FileUtil.getMP3TextFile(text)
16921705
playlist = RemoteCliMainWindow().playAudioBibleChapterVerseByVerse(text, b, c)
16931706
else:
1694-
searchPattern = """[Rr][Ee][Aa][Dd][Vv][Ee][Rr][Ss][Ee]:::([A-Za-z0-9]+?)\.([0-9]+?)\.([0-9]+?)\.([0-9]+?)["']"""
1707+
searchPattern = r"""[Rr][Ee][Aa][Dd][Vv][Ee][Rr][Ss][Ee]:::([A-Za-z0-9]+?)\.([0-9]+?)\.([0-9]+?)\.([0-9]+?)["']"""
16951708
found = re.findall(searchPattern, html)
16961709
if found:
16971710
for entry in found:
@@ -1702,7 +1715,7 @@ def getPlaylistFromHTML(self, html):
17021715
if os.path.isfile(audioFilePath):
17031716
playlist.append((audioFile, audioFilePath))
17041717
else:
1705-
searchPattern = """[Rr][Ee][Aa][Dd]([Ww][Oo][Rr][Dd]|[Ll][Ee][Xx][Ee][Mm][Ee]):::([A-Za-z0-9]+?)\.([0-9]+?)\.([0-9]+?)\.([0-9]+?)\.([0-9]+?)["']"""
1718+
searchPattern = r"""[Rr][Ee][Aa][Dd]([Ww][Oo][Rr][Dd]|[Ll][Ee][Xx][Ee][Mm][Ee]):::([A-Za-z0-9]+?)\.([0-9]+?)\.([0-9]+?)\.([0-9]+?)\.([0-9]+?)["']"""
17061719
found = re.findall(searchPattern, html)
17071720
if found:
17081721
for entry in found:

0 commit comments

Comments
 (0)