Skip to content

Commit

Permalink
Merge pull request #1417 from otseng/main
Browse files Browse the repository at this point in the history
Ver 35.28; Add install all to module downloading
  • Loading branch information
eliranwong committed Feb 20, 2024
2 parents 41010c7 + a4fae81 commit 9e13fbb
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,4 @@ tmpicns.rsrc
.stop_chatgpt
log.txt
.python-version
google-cloud-key.json
2 changes: 1 addition & 1 deletion UniqueBibleAppVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
35.27
35.28
2 changes: 1 addition & 1 deletion docker_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ click==8.0.3
cobble==0.1.3
colorama==0.4.4
contextlib2==0.6.0.post1
cryptography==42.0.0
cryptography==42.0.2
Deprecated==1.2.13
diff-match-patch==20200713
distlib==0.3.4
Expand Down
101 changes: 66 additions & 35 deletions gui/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,60 +1167,74 @@ def setStudyBibleToolBar(self):

# install marvel data
def installMarvelBibles(self):
items = [self.bibleInfo[bible][-1] for bible in self.bibleInfo.keys() if
not os.path.isfile(os.path.join(*self.bibleInfo[bible][0])) or self.isNewerAvailable(
installAll = "Install ALL Bibles"
bibles = DatafileLocation.marvelBibles
items = [bible for bible in bibles.keys() if
not os.path.isfile(os.path.join(os.getcwd(), *bibles[bible][0])) or self.isNewerAvailable(
self.bibleInfo[bible][0][-1])]
if not items:
if items:
items.append(installAll)
else:
items = ["[All Installed]"]
item, ok = QInputDialog.getItem(self, "UniqueBible",
config.thisTranslation["menu8_bibles"], items, 0, False)
if ok and item and not item == "[All Installed]":
for key, value in self.bibleInfo.items():
if item == value[-1]:
self.downloadHelper(self.bibleInfo[key])
break
if ok and item and not item in ("[All Installed]", installAll):
self.downloadHelper(bibles[item])
elif item == installAll:
self.installAllMarvelFiles(bibles, installAll)
self.reloadResources()

def installMarvelCommentaries(self):
installAll = "Install ALL Commentaries"
commentaries = DatafileLocation.marvelCommentaries
items = [commentary for commentary in commentaries.keys() if
not os.path.isfile(os.path.join(*commentaries[commentary][0]))]
not os.path.isfile(os.path.join(os.getcwd(), *commentaries[commentary][0]))]
if items:
commentaries["Install ALL Commentaries Listed Above"] = ""
items.append("Install ALL Commentaries Listed Above")
items.append(installAll)
else:
items = ["[All Installed]"]
item, ok = QInputDialog.getItem(self, "UniqueBible",
config.thisTranslation["menu8_commentaries"], items, 0, False)
if ok and item and not item in ("[All Installed]", "Install ALL Commentaries Listed Above"):
if ok and item and not item in ("[All Installed]", installAll):
self.downloadHelper(commentaries[item])
elif item == "Install ALL Commentaries Listed Above":
self.installAllMarvelCommentaries(commentaries)
self.reloadResources()
elif item == installAll:
self.installAllMarvelFiles(commentaries, installAll)

def installAllMarvelCommentaries(self, commentaries):
def installAllMarvelFiles(self, files, installAll):
if config.isDownloading:
self.displayMessage(config.thisTranslation["previousDownloadIncomplete"])
else:
toBeInstalled = [commentary for commentary in commentaries.keys() if
not commentary == "Install ALL Commentaries Listed Above" and not os.path.isfile(
os.path.join(*commentaries[commentary][0]))]
toBeInstalled = [file for file in files.keys() if
not file == installAll and not os.path.isfile(
os.path.join(os.getcwd(), *files[file][0]))]
self.displayMessage("{0} {1}".format(config.thisTranslation["message_downloadAllFiles"],
config.thisTranslation["message_willBeNoticed"]))
for commentary in toBeInstalled:
databaseInfo = commentaries[commentary]
print("Downloading {0} files".format(len(toBeInstalled)))
for file in toBeInstalled:
databaseInfo = files[file]
downloader = Downloader(self, databaseInfo)
print("Downloading " + file)
downloader.downloadFile(False)
# self.displayMessage(config.thisTranslation["message_done"])
self.reloadResources()
print("Downloading complete")
self.displayMessage(config.thisTranslation["message_installed"])

def installMarvelDatasets(self):
installAll = "Install ALL Datasets"
datasets = DatafileLocation.marvelData
items = [dataset for dataset in datasets.keys() if not os.path.isfile(os.path.join(*datasets[dataset][0]))]
if not items:
items = [dataset for dataset in datasets.keys() if not os.path.isfile(os.path.join(os.getcwd(), *datasets[dataset][0]))]
if items:
items.append(installAll)
else:
items = ["[All Installed]"]
item, ok = QInputDialog.getItem(self, "UniqueBible",
config.thisTranslation["menu8_datasets"], items, 0, False)
if ok and item and not item == "[All Installed]":
if ok and item and not item in ("[All Installed]", installAll):
self.downloadHelper(datasets[item])
elif item == installAll:
self.installAllMarvelFiles(datasets, installAll)
self.reloadResources()

def installGithubBibles(self):
self.installFromGitHub(GitHubRepoInfo.bibles)
Expand Down Expand Up @@ -1285,24 +1299,41 @@ def installFromGitHub(self, gitHubRepoInfo):
try:
from util.GithubUtil import GithubUtil

installAll = "Install ALL"
github = GithubUtil(repo)
repoData = github.getRepoData()
folder = os.path.join(config.marvelData, directory)
items = [item for item in repoData.keys() if not FileUtil.regexFileExists("^{0}.*".format(GithubUtil.getShortname(item).replace(".", "\\.")), folder)]
if not items:
if items:
items.append(installAll)
else:
items = ["[All Installed]"]
item, ok = QInputDialog.getItem(self, "UniqueBible",
selectedItem, ok = QInputDialog.getItem(self, "UniqueBible",
config.thisTranslation[title], items, 0, False)
if ok and item and not item in ("[All Installed]"):
file = os.path.join(folder, item+".zip")
github.downloadFile(file, repoData[item])
with zipfile.ZipFile(file, 'r') as zipped:
zipped.extractall(folder)
os.remove(file)
self.displayMessage(item + " " + config.thisTranslation["message_installed"])
if ok and selectedItem:
if selectedItem == installAll:
self.displayMessage("{0} {1}".format(config.thisTranslation["message_downloadAllFiles"],
config.thisTranslation["message_willBeNoticed"]))
items.remove(installAll)
print("Downloading {0} files".format(len(items)))
else:
self.displayMessage(selectedItem + " " + config.thisTranslation["message_installing"])
items = [selectedItem]
for index, item in enumerate(items):
file = os.path.join(folder, item+".zip")
print("Downloading {0}".format(file))
github.downloadFile(file, repoData[item])
with zipfile.ZipFile(file, 'r') as zipped:
zipped.extractall(folder)
os.remove(file)
print("Downloading complete")
self.reloadResources()
self.installFromGitHub(gitHubRepoInfo)
return True
if selectedItem == installAll:
self.displayMessage(config.thisTranslation["message_installed"])
else:
self.installFromGitHub(gitHubRepoInfo)
return True

except Exception as ex:
self.displayMessage(config.thisTranslation["couldNotAccess"] + " " + repo)
print(ex)
Expand Down
3 changes: 3 additions & 0 deletions latest_changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Changes in 35.28:
* Add "Install ALL" to module downloads

Changes in 35.27:
* Populate verse list if missing chapter in api server

Expand Down
12 changes: 6 additions & 6 deletions patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,6 @@
(26.30, "file", "music/Readme.md")
(26.30, "file", "video/Readme.md")
(26.49, "file", "util/CatalogUtil.py")
(28.06, "file", "util/DatafileLocation.py")
(28.07, "file", "htmlResources/expand.png")
(28.27, "file", "util/Languages.py")
(28.30, "file", "util/ScrapeSite.py")
Expand Down Expand Up @@ -1215,7 +1214,6 @@
(33.16, "file", "plugins/startup/customise_terminal_mode_commands.py")
(33.20, "file", "util/PromptValidator.py")
(33.25, "file", "util/LexicalData.py")
(33.28, "file", ".gitignore")
(33.48, "file", "gui/CentralWidget.py")
(33.50, "file", "gui/MiniControl.py")
(33.50, "file", "gui/NoteEditor.py")
Expand Down Expand Up @@ -1365,7 +1363,6 @@
(35.24, "file", "util/ShortcutUtil.py")
(35.25, "file", "db/StatisticsWordsSqlite.py")
(35.25, "file", "db/ToolsSqlite.py")
(35.25, "file", "gui/MainWindow.py")
(35.25, "file", "gui/MenuItems.py")
(35.25, "file", "lang/language_de.py")
(35.25, "file", "lang/language_el.py")
Expand Down Expand Up @@ -1394,6 +1391,9 @@
(35.26, "file", "util/terminal_system_command_prompt.py")
(35.26, "file", "util/TextEditorUtility.py")
(35.27, "file", "db/BiblesSqlite.py")
(35.27, "file", "latest_changes.txt")
(35.27, "file", "patches.txt")
(35.27, "file", "UniqueBibleAppVersion.txt")
(35.28, "file", ".gitignore")
(35.28, "file", "gui/MainWindow.py")
(35.28, "file", "util/DatafileLocation.py")
(35.28, "file", "patches.txt")
(35.28, "file", "latest_changes.txt")
(35.28, "file", "UniqueBibleAppVersion.txt")
1 change: 0 additions & 1 deletion util/DatafileLocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class DatafileLocation:
"Search Engine": ((config.marvelData, "search.sqlite"), "1A4s8ewpxayrVXamiva2l1y1AinAcIKAh"),
"Smart Indexes": ((config.marvelData, "indexes2.sqlite"), "1hY-QkBWQ8UpkeqM8lkB6q_FbaneU_Tg5"),
"Chapter & Verse Notes": ((config.marvelData, "note.sqlite"), "1OcHrAXLS-OLDG5Q7br6mt2WYCedk8lnW"),
"Bible Background Data": ((config.marvelData, "data", "exlb3.data"), "1gp2Unsab85Se-IB_tmvVZQ3JKGvXLyMP"),
"Bible Topics Data": ((config.marvelData, "data", "exlb3.data"), "1gp2Unsab85Se-IB_tmvVZQ3JKGvXLyMP"),
"Cross-reference Data": (
(config.marvelData, "cross-reference.sqlite"), "1fTf0L7l1k_o1Edt4KUDOzg5LGHtBS3w_"),
Expand Down

0 comments on commit 9e13fbb

Please sign in to comment.