diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 1c9c13bcc..1996706ec 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -65,18 +65,18 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils): self.bible_versions[p[0]] = p[1].replace('\n', '') self.BibleComboBox.addItem(str(p[0])) - ############### Combo Boxes + #Combo Boxes QtCore.QObject.connect(self.LocationComboBox, QtCore.SIGNAL("activated(int)"), self.onLocationComboBoxSelected) QtCore.QObject.connect(self.BibleComboBox, QtCore.SIGNAL("activated(int)"), self.onBibleComboBoxSelected) - ############### Buttons + #Buttons QtCore.QObject.connect(self.ImportButton, QtCore.SIGNAL("pressed()"), self.onImportButtonClicked) QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("pressed()"), self.onCancelButtonClicked) QtCore.QObject.connect(self.VersesFileButton, QtCore.SIGNAL("pressed()"), self.onVersesFileButtonClicked) QtCore.QObject.connect(self.BooksFileButton, QtCore.SIGNAL("pressed()"), self.onBooksFileButtonClicked) QtCore.QObject.connect(self.OsisFileButton, QtCore.SIGNAL("pressed()"), self.onOsisFileButtonClicked) - ############### Lost Focus + #Lost Focus QtCore.QObject.connect(self.OSISLocationEdit, QtCore.SIGNAL("lostFocus()"), self.onOSISLocationEditLostFocus) QtCore.QObject.connect(self.BooksLocationEdit, QtCore.SIGNAL("lostFocus()"),self.onBooksLocationEditLostFocus) QtCore.QObject.connect(self.VerseLocationEdit, QtCore.SIGNAL("lostFocus()"), self.onVerseLocationEditLostFocus) @@ -90,35 +90,35 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils): if filename != "": self.VerseLocationEdit.setText(filename) self._save_last_directory(filename, 1) - self.set_cvs() + self.setCsv() def onBooksFileButtonClicked(self): filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir(2)) if filename != "": self.BooksLocationEdit.setText(filename) self._save_last_directory(filename, 2) - self.set_cvs() + self.setCsv() def onOsisFileButtonClicked(self): filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir(3)) if filename != "": self.OSISLocationEdit.setText(filename) self._save_last_directory(filename, 3) - self.set_osis() + self.setOsis() def onOSISLocationEditLostFocus(self): if len(self.OSISLocationEdit.displayText() ) > 0: - self.set_osis() + self.setOsis() else: if self.bible_type == "OSIS": # Was OSIS and is not any more stops lostFocus running mad self.bible_type = None - self.free_all() + self.freeAll() def onBooksLocationEditLostFocus(self): - self.check_osis() + self.checkOsis() def onVerseLocationEditLostFocus(self): - self.check_osis() + self.checkOsis() def onProxyAddressEditLostFocus(self): self.config.set_config("proxy_address", str(self.AddressEdit.displayText())) @@ -130,14 +130,17 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils): self.config.set_config("proxy_password", str(self.PasswordEdit.displayText())) def onLocationComboBoxSelected(self): - self.check_http() + self.checkHttp() def onBibleComboBoxSelected(self): - self.check_http() + self.checkHttp() self.BibleNameEdit.setText(str(self.BibleComboBox.currentText())) def onCancelButtonClicked(self): + # tell import to stop Receiver().send_message("openlpstopimport") + # tell bibleplugin to reload the bibles + Receiver().send_message("openlpreloadbibles") self.close() def onImportButtonClicked(self): @@ -145,32 +148,33 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils): if not self.bible_type == None and len(self.BibleNameEdit.displayText()) > 0: self.MessageLabel.setText("Import Started") self.ProgressBar.setMinimum(0) - self.set_max(65) + self.setMax(65) self.ProgressBar.setValue(0) self.biblemanager.process_dialog(self) - self._import_bible() + self.importBible() self.MessageLabel.setText("Import Complete") self.ProgressBar.setValue(self.barmax) - Receiver().send_message("openlpreloadbibles") # tell bibleplugin to reload the bibles + # tell bibleplugin to reload the bibles + Receiver().send_message("openlpreloadbibles") - def set_max(self, max): + def setMax(self, max): log.debug("set Max %s", max) self.barmax = max self.ProgressBar.setMaximum(max) - def increment_progress_bar(self, text ): + def incrementProgressBar(self, text ): log.debug("IncrementBar %s", text) self.MessageLabel.setText("Import processing " + text) self.ProgressBar.setValue(self.ProgressBar.value()+1) - def _import_bible(self): + def importBible(self): log.debug("Import Bible ") if self.bible_type == "OSIS": self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText()) elif self.bible_type == "CSV": self.biblemanager.register_csv_file_bible(str(self.BibleNameEdit.displayText()), self.BooksLocationEdit.displayText(), self.VerseLocationEdit.displayText()) else: - self.set_max(1) # set a value as it will not be needed + self.setMax(1) # set a value as it will not be needed bible = self.bible_versions[str(self.BibleComboBox.currentText())] self.biblemanager.register_http_bible(str(self.BibleComboBox.currentText()), \ str(self.LocationComboBox.currentText()), \ @@ -180,64 +184,63 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils): str(self.PasswordEdit.displayText())) self.biblemanager.save_meta_data(str(self.BibleNameEdit.displayText()), str(self.VersionNameEdit.displayText()), str(self.CopyrightEdit.displayText()), str(self.PermisionEdit.displayText())) self.bible_type = None - self.free_all() # free the screen state restrictions - self.reset_all() # reset all the screen fields + self.freeAll() # free the screen state restrictions + self.resetAll() # reset all the screen fields - def check_osis(self): + def checkOsis(self): if len(self.BooksLocationEdit.displayText()) > 0 or len(self.VerseLocationEdit.displayText()) > 0: - self.set_cvs() + self.setCsv() else: if self.bible_type == "CSV": # Was CSV and is not any more stops lostFocus running mad self.bible_type = None - self.free_all() + self.freeAll() - def check_http(self): + def checkHttp(self): if self.BibleComboBox.currentIndex() != 0 : # First slot is blank so no bible - self.set_http() + self.setHttp() else: if self.bible_type == "HTTP": # Was HTTP and is not any more stops lostFocus running mad self.bible_type = None - self.free_all() + self.freeAll() - - def block_csv(self): + def blockCsv(self): self.BooksLocationEdit.setReadOnly(True) self.VerseLocationEdit.setReadOnly(True) self.BooksFileButton.setEnabled(False) self.VersesFileButton.setEnabled(False) - def set_cvs(self): + def setCsv(self): self.bible_type = "CSV" self.BooksLocationEdit.setReadOnly(False) self.VerseLocationEdit.setReadOnly(False) self.BooksFileButton.setEnabled(True) self.VersesFileButton.setEnabled(True) - self.block_osis() - self.block_http() + self.blockOsis() + self.blockHttp() - def set_osis(self): + def setOsis(self): self.bible_type = "OSIS" self.OSISLocationEdit.setReadOnly(False) self.OsisFileButton.setEnabled(True) - self.block_csv() - self.block_http() + self.blockCsv() + self.blockHttp() - def block_osis(self): + def blockOsis(self): self.OSISLocationEdit.setReadOnly(True) self.OsisFileButton.setEnabled(False) - def set_http(self): + def setHttp(self): self.bible_type = "HTTP" self.LocationComboBox.setEnabled(True) self.BibleComboBox.setEnabled(True) - self.block_csv() - self.block_osis() + self.blockCsv() + self.blockOsis() - def block_http(self): + def blockHttp(self): self.LocationComboBox.setEnabled(False) self.BibleComboBox.setEnabled(False) - def free_all(self): + def freeAll(self): if self.bible_type == None: # only reset if no bible type set. self.BooksLocationEdit.setReadOnly(False) self.VerseLocationEdit.setReadOnly(False) @@ -248,7 +251,7 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils): self.LocationComboBox.setEnabled(True) self.BibleComboBox.setEnabled(True) - def reset_all(self): + def resetAll(self): self.BooksLocationEdit.setText("") self.VerseLocationEdit.setText("") self.OSISLocationEdit.setText("") diff --git a/openlp/plugins/bibles/lib/bibleCSVimpl.py b/openlp/plugins/bibles/lib/bibleCSVimpl.py index e05b07a40..fb2c75b00 100644 --- a/openlp/plugins/bibles/lib/bibleCSVimpl.py +++ b/openlp/plugins/bibles/lib/bibleCSVimpl.py @@ -72,7 +72,7 @@ class BibleCSVImpl(BibleCommon): if book_ptr is not p0: book = self.bibledb.get_bible_book(p0) book_ptr = book.name - dialogobject.increment_progress_bar(book.name) # increament the progress bar + dialogobject.incrementProgressBar(book.name) # increament the progress bar self.bibledb.add_verse(book.id, p[1], p[2], p3) count += 1 if count % 3 == 0: #Every x verses repaint the screen diff --git a/openlp/plugins/bibles/lib/bibleOSISimpl.py b/openlp/plugins/bibles/lib/bibleOSISimpl.py index d85098345..db9ae8213 100644 --- a/openlp/plugins/bibles/lib/bibleOSISimpl.py +++ b/openlp/plugins/bibles/lib/bibleOSISimpl.py @@ -52,39 +52,95 @@ class BibleOSISImpl(): count = 0 verseText = "", s) - ref = f[s+15:e-1] # Book Reference +# print file + pos = file.find(verseText) + if pos > -1: # we have a verse + epos= file.find(">", pos) + ref = file[pos+15:epos-1] # Book Reference #lets find the bible text - s = e + 1 # find start of text - e = f.find("", s) # end of text - t = f[s:e] - #print s, e, f[s:e] # Found Basic Text + pos = epos + 1 # find start of text + epos = file.find("", pos) # end of text + text = file[pos : epos] + #print pos, e, f[pos:e] # Found Basic Text #remove tags of extra information - - s = t.find("") - while s > -1: - e = t.find("", s) - if e == -1: # TODO - #print "Y", s, e - s = -1 + + pos = text.find(" -1: + epos = text.find("", pos) + if epos == -1: # TODO + #print "Y", pos, epos + pos = -1 else: - t = t[:s] + t[e + 4: ] - s = t.find("") + text = text[:pos] + text[epos + 8: ] + pos = text.find(" -1: + epos = text.find("", pos) + if epos == -1: # TODO + #print "Y", pos, epos + pos = -1 + else: + text = text[:pos] + text[epos + 13: ] + pos = text.find("") - while s > -1: - e = t.find("", s) - t = t[:s] + t[e + 4: ] - #print "X", s, e, t - s = t.find("") + pos = text.find(" -1: + epos = text.find("", pos) + if epos == -1: # TODO + #print "Y", pos, epos + pos = -1 + else: + text = text[:pos] + text[epos + 7: ] + pos = text.find(" -1: + epos = text.find("/>", pos) + text = text[:pos] + text[epos + 2: ] + pos = text.find(" -1: + epos = text.find("/>", pos) + text = text[:pos] + text[epos + 2: ] + pos = text.find(" -1: + epos = text.find("/>", pos) + text = text[:pos] + text[epos + 2: ] + pos = text.find(" -1: + epos = text.find("/>", pos) + text = text[:pos] + text[epos + 2: ] + pos = text.find("") + while pos > -1: + epos = text.find("", pos) + if epos == -1: # TODO + #print "Y", search_text, e + pos = -1 + else: + text = text[:pos] + text[epos + 4: ] + pos = text.find("") + + pos = text.find("") + while pos > -1: + epos = text.find("", pos) + text = text[:pos] + text[epos + 4: ] + #print "X", pos, epos, text + pos = text.find("") p = ref.split(".", 3) # split up the reference + #print p, ">>>", text + if book_ptr != p[0]: if book_ptr == None: # first time through if p[0] == "Gen": # set the max book size depending on the first book read @@ -95,10 +151,10 @@ class BibleOSISImpl(): testament += 1 book_ptr = p[0] book = self.bibledb.create_book(self.booksOfBible[p[0]] , self.abbrevOfBible[p[0]], testament) - dialogobject.increment_progress_bar(self.booksOfBible[p[0]] ) + dialogobject.incrementProgressBar(self.booksOfBible[p[0]] ) Receiver().send_message("openlpprocessevents") count = 0 - self.bibledb.add_verse(book.id, p[1], p[2], t) + self.bibledb.add_verse(book.id, p[1], p[2], text) count += 1 if count % 3 == 0: #Every x verses repaint the screen Receiver().send_message("openlpprocessevents") diff --git a/openlp/plugins/bibles/lib/biblemediaitem.py b/openlp/plugins/bibles/lib/biblemediaitem.py index ae1ce3029..6653bea58 100644 --- a/openlp/plugins/bibles/lib/biblemediaitem.py +++ b/openlp/plugins/bibles/lib/biblemediaitem.py @@ -263,7 +263,7 @@ class BibleMediaItem(MediaManagerItem): self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info def onBibleNewClick(self): - self.bibleimportform = BibleImportForm(self.config, self.parent.biblemanager, self) + self.bibleimportform = BibleImportForm(self.parent.config, self.parent.biblemanager, self) self.bibleimportform.exec_() pass @@ -365,7 +365,8 @@ class BibleMediaItem(MediaManagerItem): def reloadBibles(self): log.debug("Reloading Bibles") self.parent.biblemanager.reload_bibles() - self.initialiseForm() + #self.initialiseForm() + self.loadBibles() def initialiseBible(self, bible): log.debug('initialiseBible %s', bible)