diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 61640262b..828b0c566 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -88,6 +88,7 @@ JAVASCRIPT = """ } } """ +# TODO: Verify format() with variable templates CSS = """ #alert { position: absolute; @@ -244,6 +245,9 @@ class AlertsPlugin(Plugin): :param frame: The Web frame holding the page. """ align = VerticalType.Names[self.settings_tab.location] - frame.evaluateJavaScript('update_css("%s", "%s", "%s", "%s", "%s")' % - (align, self.settings_tab.font_face, self.settings_tab.font_size, - self.settings_tab.font_color, self.settings_tab.background_color)) + frame.evaluateJavaScript('update_css("{align}", "{face}", "{size}", "{color}", ' + '"{background}")'.format(align=align, + face=self.settings_tab.font_face, + size=self.settings_tab.font_size, + color=self.settings_tab.font_color, + background=self.settings_tab.background_color)) diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index fd9fbaf09..1bc3413f9 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -62,7 +62,7 @@ class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject, RegistryProperti :param text: The text to display """ - self.log_debug('display alert called %s' % text) + self.log_debug('display alert called {text}'.format(text=text)) if text: self.alert_list.append(text) if self.timer_id != 0: diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 2859a71ce..5240b7fa8 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -197,5 +197,6 @@ class AlertsTab(SettingsTab): font.setBold(True) font.setPointSize(self.font_size) self.font_preview.setFont(font) - self.font_preview.setStyleSheet('background-color: %s; color: %s' % (self.background_color, self.font_color)) + self.font_preview.setStyleSheet('background-color: {back}; color: {front}'.format(back=self.background_color, + front=self.font_color)) self.changed = True diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 3289e66e9..e1407404c 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -593,22 +593,27 @@ class BibleImportForm(OpenLPWizard): """ Show the file open dialog for the books CSV file. """ + # TODO: Verify format() with varible template self.get_file_name( - WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csv_books_edit, 'last directory import', '%s (*.csv)' % - translate('BiblesPlugin.ImportWizardForm', 'CSV File')) + WizardStrings.OpenTypeFile % WizardStrings.CSV, + self.csv_books_edit, + 'last directory import', + '{name} (*.csv)'.format(name=translate('BiblesPlugin.ImportWizardForm', 'CSV File'))) def on_csv_verses_browse_button_clicked(self): """ Show the file open dialog for the verses CSV file. """ + # TODO: Verify format() with variable template self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csv_verses_edit, - 'last directory import', '%s (*.csv)' % - translate('BiblesPlugin.ImportWizardForm', 'CSV File')) + 'last directory import', + '{name} (*.csv)'.format(name=translate('BiblesPlugin.ImportWizardForm', 'CSV File'))) def on_open_song_browse_button_clicked(self): """ Show the file open dialog for the OpenSong file. """ + # TODO: Verify format() with variable template self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OS, self.open_song_file_edit, 'last directory import') @@ -616,6 +621,7 @@ class BibleImportForm(OpenLPWizard): """ Show the file open dialog for the Zefania file. """ + # TODO: Verify format() with variable template self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.ZEF, self.zefania_file_edit, 'last directory import') @@ -631,6 +637,7 @@ class BibleImportForm(OpenLPWizard): self.web_progress_bar.setVisible(True) self.web_progress_bar.setValue(0) proxy_server = self.field('proxy_server') + # TODO: Where does critical_error_message_box get %s string from? for (download_type, extractor) in ((WebDownload.Crosswalk, CWExtract(proxy_server)), (WebDownload.BibleGateway, BGExtract(proxy_server)), (WebDownload.Bibleserver, BSExtract(proxy_server))): diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 11771e9aa..fc246b93d 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -209,7 +209,7 @@ class BibleUpgradeForm(OpenLPWizard): for number, filename in enumerate(self.files): bible = OldBibleDB(self.media_item, path=self.path, file=filename[0]) self.checkBox[number] = QtWidgets.QCheckBox(self.scrollAreaContents) - self.checkBox[number].setObjectName('checkBox[%d]' % number) + self.checkBox[number].setObjectName('checkBox[{count:d}]'.format(count=number)) self.checkBox[number].setText(bible.get_name()) self.checkBox[number].setCheckState(QtCore.Qt.Checked) self.formLayout.addWidget(self.checkBox[number]) @@ -364,7 +364,10 @@ class BibleUpgradeForm(OpenLPWizard): name = filename[1] self.progress_label.setText( translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nUpgrading ...') % (number + 1, max_bibles, name)) + 'Upgrading Bible {count} of {total}: "{name}"\n' + 'Upgrading ...').format(count=number + 1, + total=max_bibles, + name=name)) self.new_bibles[number] = BibleDB(self.media_item, path=self.path, name=name, file=filename[0]) self.new_bibles[number].register(self.plugin.upgrade_wizard) metadata = old_bible.get_metadata() @@ -394,17 +397,19 @@ class BibleUpgradeForm(OpenLPWizard): handler = BSExtract(proxy_server) books = handler.get_books_from_http(meta_data['download_name']) if not books: - log.error('Upgrading books from %s - download name: "%s" failed' % ( - meta_data['download_source'], meta_data['download_name'])) + log.error('Upgrading books from {uri} - ' + 'download name: "{name}" failed'.format(uri=meta_data['download_source'], + name=meta_data['download_name'])) self.new_bibles[number].session.close() del self.new_bibles[number] critical_error_message_box( translate('BiblesPlugin.UpgradeWizardForm', 'Download Error'), translate('BiblesPlugin.UpgradeWizardForm', 'To upgrade your Web Bibles an Internet connection is required.')) - self.increment_progress_bar(translate( - 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed') % - (number + 1, max_bibles, name), self.progress_bar.maximum() - self.progress_bar.value()) + text = translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible {count} of {total}: "{name}"\n' + 'Failed').format(count=number + 1, total=max_bibles, name=name) + self.increment_progress_bar(text, self.progress_bar.maximum() - self.progress_bar.value()) self.success[number] = False continue bible = BiblesResourcesDB.get_webbible( @@ -416,12 +421,13 @@ class BibleUpgradeForm(OpenLPWizard): else: language_id = self.new_bibles[number].get_language(name) if not language_id: - log.warning('Upgrading from "%s" failed' % filename[0]) + log.warning('Upgrading from "{name}" failed'.format(name=filename[0])) self.new_bibles[number].session.close() del self.new_bibles[number] self.increment_progress_bar( translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), + 'Upgrading Bible {count} of {total}: "{name}"\n' + 'Failed').format(count=number + 1, total=max_bibles, name=name), self.progress_bar.maximum() - self.progress_bar.value()) self.success[number] = False continue @@ -432,13 +438,15 @@ class BibleUpgradeForm(OpenLPWizard): break self.increment_progress_bar( translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % - (number + 1, max_bibles, name, book)) + 'Upgrading Bible {count} of {total}: "{name}"\n' + 'Upgrading {book} ...').format(count=number + 1, total=max_bibles, + name=name, book=book)) book_ref_id = self.new_bibles[number].\ get_book_ref_id_by_name(book, len(books), language_id) if not book_ref_id: - log.warning('Upgrading books from %s - download name: "%s" aborted by user' % ( - meta_data['download_source'], meta_data['download_name'])) + log.warning('Upgrading books from {source} - download name: "{name}" ' + 'aborted by user'.format(source=meta_data['download_source'], + name=meta_data['download_name'])) self.new_bibles[number].session.close() del self.new_bibles[number] self.success[number] = False @@ -450,7 +458,7 @@ class BibleUpgradeForm(OpenLPWizard): if oldbook: verses = old_bible.get_verses(oldbook['id']) if not verses: - log.warning('No verses found to import for book "%s"', book) + log.warning('No verses found to import for book "{book}"'.format(book=book)) continue for verse in verses: if self.stop_import_flag: @@ -465,12 +473,13 @@ class BibleUpgradeForm(OpenLPWizard): if not language_id: language_id = self.new_bibles[number].get_language(name) if not language_id: - log.warning('Upgrading books from "%s" failed' % name) + log.warning('Upgrading books from "{name}" failed'.format(name=name)) self.new_bibles[number].session.close() del self.new_bibles[number] self.increment_progress_bar( translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), + 'Upgrading Bible {count} of {total}: "{name}"\n' + 'Failed').format(count=number + 1, total=max_bibles, name=name), self.progress_bar.maximum() - self.progress_bar.value()) self.success[number] = False continue @@ -482,11 +491,12 @@ class BibleUpgradeForm(OpenLPWizard): break self.increment_progress_bar( translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % - (number + 1, max_bibles, name, book['name'])) + 'Upgrading Bible {count} of {total}: "{name}"\n' + 'Upgrading {book} ...').format(count=number + 1, total=max_bibles, + name=name, book=book['name'])) book_ref_id = self.new_bibles[number].get_book_ref_id_by_name(book['name'], len(books), language_id) if not book_ref_id: - log.warning('Upgrading books from %s " failed - aborted by user' % name) + log.warning('Upgrading books from {name} " failed - aborted by user'.format(name=name)) self.new_bibles[number].session.close() del self.new_bibles[number] self.success[number] = False @@ -496,7 +506,7 @@ class BibleUpgradeForm(OpenLPWizard): book_details['testament_id']) verses = old_bible.get_verses(book['id']) if not verses: - log.warning('No verses found to import for book "%s"', book['name']) + log.warning('No verses found to import for book "{book}"'.format(book=book['name'])) self.new_bibles[number].delete_book(db_book) continue for verse in verses: @@ -510,14 +520,16 @@ class BibleUpgradeForm(OpenLPWizard): if not self.success.get(number, True): self.increment_progress_bar( translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), + 'Upgrading Bible {count} of {total}: "{name}"\n' + 'Failed').format(count=number + 1, total=max_bibles, name=name), self.progress_bar.maximum() - self.progress_bar.value()) else: self.success[number] = True self.new_bibles[number].save_meta('name', name) self.increment_progress_bar( translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nComplete') % (number + 1, max_bibles, name)) + 'Upgrading Bible {count} of {total}: "{name}"\n' + 'Complete').format(count=number + 1, total=max_bibles, name=name)) if number in self.new_bibles: self.new_bibles[number].session.close() # Close the last bible's connection if possible. @@ -540,20 +552,22 @@ class BibleUpgradeForm(OpenLPWizard): # Copy not upgraded bible back. shutil.move(os.path.join(self.temp_dir, filename[0]), self.path) if failed_import > 0: - failed_import_text = translate('BiblesPlugin.UpgradeWizardForm', ', %s failed') % failed_import + failed_import_text = translate('BiblesPlugin.UpgradeWizardForm', + ', {name} failed').format(name=failed_import) else: failed_import_text = '' if successful_import > 0: if self.includeWebBible: self.progress_label.setText( translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible(s): %(success)d successful%(failed_text)s\nPlease note that verses ' - 'from Web Bibles will be downloaded on demand and so an Internet connection is required.') - % {'success': successful_import, 'failed_text': failed_import_text}) + 'Upgrading Bible(s): {count:d} successful{failed}\nPlease note that verses ' + 'from Web Bibles will be downloaded on demand and so an Internet connection is required.' + ).format(count=successful_import, failed=failed_import_text)) else: self.progress_label.setText( - translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible(s): %s successful%s') % ( - successful_import, failed_import_text)) + translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible(s): {count:d} successful{failed}').format(count=successful_import, + failed=failed_import_text)) else: self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade failed.')) # Remove temp directory. diff --git a/openlp/plugins/bibles/forms/editbibledialog.py b/openlp/plugins/bibles/forms/editbibledialog.py index 978f019ad..ca3bea4ed 100644 --- a/openlp/plugins/bibles/forms/editbibledialog.py +++ b/openlp/plugins/bibles/forms/editbibledialog.py @@ -103,9 +103,11 @@ class Ui_EditBibleDialog(object): self.book_name_edit = {} for book in BiblesResourcesDB.get_books(): self.book_name_label[book['abbreviation']] = QtWidgets.QLabel(self.book_name_widget) - self.book_name_label[book['abbreviation']].setObjectName('book_name_label[%s]' % book['abbreviation']) + self.book_name_label[book['abbreviation']].setObjectName( + 'book_name_label[{name}]'.format(book=book['abbreviation'])) self.book_name_edit[book['abbreviation']] = QtWidgets.QLineEdit(self.book_name_widget) - self.book_name_edit[book['abbreviation']].setObjectName('book_name_edit[%s]' % book['abbreviation']) + self.book_name_edit[book['abbreviation']].setObjectName( + 'book_name_edit[{name}]'.format(name=book['abbreviation'])) self.book_name_widget_layout.addRow( self.book_name_label[book['abbreviation']], self.book_name_edit[book['abbreviation']]) @@ -148,4 +150,5 @@ class Ui_EditBibleDialog(object): self.bible_tab_widget.indexOf(self.book_name_tab), translate('SongsPlugin.EditBibleForm', 'Custom Book Names')) for book in BiblesResourcesDB.get_books(): - self.book_name_label[book['abbreviation']].setText('%s:' % str(self.book_names[book['abbreviation']])) + self.book_name_label[book['abbreviation']].setText( + '{text}:'.format(text=self.book_names[book['abbreviation']])) diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index 9eb64ee19..c6afbabb6 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -39,7 +39,7 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties): """ Class to manage the editing of a bible """ - log.info('%s EditBibleForm loaded', __name__) + log.info('{name} EditBibleForm loaded'.format(name=__name__)) def __init__(self, media_item, parent, manager): """ @@ -168,16 +168,17 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties): self.book_name_edit[abbreviation].setFocus() critical_error_message_box( UiStrings().EmptyField, - translate('BiblesPlugin.BibleEditForm', 'You need to specify a book name for "%s".') % - self.book_names[abbreviation]) + translate('BiblesPlugin.BibleEditForm', + 'You need to specify a book name for "{text}".').format(text=self.book_names[abbreviation])) return False elif not book_regex.match(new_book_name): self.book_name_edit[abbreviation].setFocus() critical_error_message_box( UiStrings().EmptyField, translate('BiblesPlugin.BibleEditForm', - 'The book name "%s" is not correct.\nNumbers can only be used at the beginning and must\nbe ' - 'followed by one or more non-numeric characters.') % new_book_name) + 'The book name "{name}" is not correct.\n' + 'Numbers can only be used at the beginning and must\nbe ' + 'followed by one or more non-numeric characters.').format(name=new_book_name)) return False for abbr, book in self.books.items(): if book: @@ -187,7 +188,7 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties): self.book_name_edit[abbreviation].setFocus() critical_error_message_box( translate('BiblesPlugin.BibleEditForm', 'Duplicate Book Name'), - translate('BiblesPlugin.BibleEditForm', 'The Book Name "%s" has been entered more than once.') - % new_book_name) + translate('BiblesPlugin.BibleEditForm', + 'The Book Name "{name}" has been entered more than once.').format(name=new_book_name)) return False return True diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 2e95697e3..ef8616051 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -86,7 +86,7 @@ class CSVBible(BibleDB): success = True language_id = self.get_language(bible_name) if not language_id: - log.error('Importing books from "%s" failed' % self.filename) + log.error('Importing books from "{name}" failed'.format(name=self.filename)) return False books_file = None book_list = {} @@ -98,11 +98,11 @@ class CSVBible(BibleDB): for line in books_reader: if self.stop_import_flag: break - self.wizard.increment_progress_bar(translate('BiblesPlugin.CSVBible', 'Importing books... %s') - % line[2]) + self.wizard.increment_progress_bar(translate('BiblesPlugin.CSVBible', + 'Importing books... {text}').format(text=line[2])) book_ref_id = self.get_book_ref_id_by_name(line[2], 67, language_id) if not book_ref_id: - log.error('Importing books from "%s" failed' % self.books_file) + log.error('Importing books from "{name}" failed'.format(name=self.books_file)) return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) self.create_book(line[2], book_ref_id, book_details['testament_id']) @@ -134,9 +134,11 @@ class CSVBible(BibleDB): if book_ptr != line_book: book = self.get_book(line_book) book_ptr = book.name + # TODO: Check out this conversion in translations self.wizard.increment_progress_bar( translate('BiblesPlugin.CSVBible', - 'Importing verses from %s...' % book.name, 'Importing verses from ...')) + 'Importing verses from {name}...'.format(name=book.name), + 'Importing verses from ...')) self.session.commit() verse_text = line[3] self.create_verse(book.id, line[1], line[2], verse_text) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 8dcf8c042..c23ade4a7 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -185,7 +185,7 @@ class BibleDB(Manager, RegistryProperties): :param testament: *Defaults to 1.* The testament_reference_id from bibles_resources.sqlite of the testament this book belongs to. """ - log.debug('BibleDB.create_book("%s", "%s")' % (name, bk_ref_id)) + log.debug('BibleDB.create_book("{name}", "{number}")'.format(name=name, number=bk_ref_id)) book = Book.populate(name=name, book_reference_id=bk_ref_id, testament_reference_id=testament) self.save_object(book) return book @@ -196,7 +196,7 @@ class BibleDB(Manager, RegistryProperties): :param book: The book object """ - log.debug('BibleDB.update_book("%s")' % book.name) + log.debug('BibleDB.update_book("{name}")'.format(name=book.name)) return self.save_object(book) def delete_book(self, db_book): @@ -205,7 +205,7 @@ class BibleDB(Manager, RegistryProperties): :param db_book: The book object. """ - log.debug('BibleDB.delete_book("%s")' % db_book.name) + log.debug('BibleDB.delete_book("{name}")'.format(name=db_book.name)) if self.delete_object(Book, db_book.id): return True return False @@ -219,7 +219,7 @@ class BibleDB(Manager, RegistryProperties): :param text_list: A dict of the verses to be inserted. The key is the verse number, and the value is the verse text. """ - log.debug('BibleDBcreate_chapter("%s", "%s")' % (book_id, chapter)) + log.debug('BibleDBcreate_chapter("{number}", "{chapter}")'.format(number=book_id, chapter=chapter)) # Text list has book and chapter as first two elements of the array. for verse_number, verse_text in text_list.items(): verse = Verse.populate( @@ -266,7 +266,7 @@ class BibleDB(Manager, RegistryProperties): """ if not isinstance(value, str): value = str(value) - log.debug('BibleDB.save_meta("%s/%s")' % (key, value)) + log.debug('BibleDB.save_meta("{key}/{val}")'.format(key=key, val=value)) meta = self.get_object(BibleMeta, key) if meta: meta.value = value @@ -280,7 +280,7 @@ class BibleDB(Manager, RegistryProperties): :param book: The name of the book to return. """ - log.debug('BibleDB.get_book("%s")' % book) + log.debug('BibleDB.get_book("{book}")'.format(book=book)) return self.get_object_filtered(Book, Book.name.like(book + '%')) def get_books(self): @@ -297,11 +297,11 @@ class BibleDB(Manager, RegistryProperties): :param ref_id: The reference id of the book to return. """ - log.debug('BibleDB.get_book_by_book_ref_id("%s")' % ref_id) + log.debug('BibleDB.get_book_by_book_ref_id("{ref}")'.format(ref=ref_id)) return self.get_object_filtered(Book, Book.book_reference_id.like(ref_id)) def get_book_ref_id_by_name(self, book, maxbooks, language_id=None): - log.debug('BibleDB.get_book_ref_id_by_name:("%s", "%s")' % (book, language_id)) + log.debug('BibleDB.get_book_ref_id_by_name:("{book}", "{lang}")'.format(book=book, lang=language_id)) book_id = None if BiblesResourcesDB.get_book(book, True): book_temp = BiblesResourcesDB.get_book(book, True) @@ -327,13 +327,14 @@ class BibleDB(Manager, RegistryProperties): :param book: The name of the book, according to the selected language. :param language_selection: The language selection the user has chosen in the settings section of the Bible. """ - log.debug('get_book_ref_id_by_localised_name("%s", "%s")' % (book, language_selection)) + log.debug('get_book_ref_id_by_localised_name("{book}", "{lang}")'.format(book=book, lang=language_selection)) from openlp.plugins.bibles.lib import LanguageSelection, BibleStrings book_names = BibleStrings().BookNames # escape reserved characters book_escaped = book for character in RESERVED_CHARACTERS: book_escaped = book_escaped.replace(character, '\\' + character) + # TODO: Verify regex patters before using format() regex_book = re.compile('\s*%s\s*' % '\s*'.join( book_escaped.split()), re.UNICODE | re.IGNORECASE) if language_selection == LanguageSelection.Bible: @@ -374,14 +375,14 @@ class BibleDB(Manager, RegistryProperties): [('35', 1, 1, 1), ('35', 2, 2, 3)] :param show_error: """ - log.debug('BibleDB.get_verses("%s")' % reference_list) + log.debug('BibleDB.get_verses("{ref}")'.format(ref=reference_list)) verse_list = [] book_error = False for book_id, chapter, start_verse, end_verse in reference_list: db_book = self.get_book_by_book_ref_id(book_id) if db_book: book_id = db_book.book_reference_id - log.debug('Book name corrected to "%s"' % db_book.name) + log.debug('Book name corrected to "{book}"'.format(book=db_book.name)) if end_verse == -1: end_verse = self.get_verse_count(book_id, chapter) verses = self.session.query(Verse) \ @@ -393,7 +394,7 @@ class BibleDB(Manager, RegistryProperties): .all() verse_list.extend(verses) else: - log.debug('OpenLP failed to find book with id "%s"' % book_id) + log.debug('OpenLP failed to find book with id "{book}"'.format(book=book_id)) book_error = True if book_error and show_error: critical_error_message_box( @@ -412,8 +413,9 @@ class BibleDB(Manager, RegistryProperties): contains spaces, it will split apart and AND'd on the list of values. """ - log.debug('BibleDB.verse_search("%s")' % text) + log.debug('BibleDB.verse_search("{text}")'.format(text=text)) verses = self.session.query(Verse) + # TODO: Find out what this is doing before converting to format() if text.find(',') > -1: keywords = ['%%%s%%' % keyword.strip() for keyword in text.split(',')] or_clause = [Verse.text.like(keyword) for keyword in keywords] @@ -431,7 +433,7 @@ class BibleDB(Manager, RegistryProperties): :param book: The book object to get the chapter count for. """ - log.debug('BibleDB.get_chapter_count("%s")' % book.name) + log.debug('BibleDB.get_chapter_count("{book}")'.format(book=book.name)) count = self.session.query(func.max(Verse.chapter)).join(Book).filter( Book.book_reference_id == book.book_reference_id).scalar() if not count: @@ -445,7 +447,7 @@ class BibleDB(Manager, RegistryProperties): :param book_ref_id: The book reference id. :param chapter: The chapter to get the verse count for. """ - log.debug('BibleDB.get_verse_count("%s", "%s")' % (book_ref_id, chapter)) + log.debug('BibleDB.get_verse_count("{ref}", "{chapter}")'.format(ref=book_ref_id, chapter=chapter)) count = self.session.query(func.max(Verse.verse)).join(Book) \ .filter(Book.book_reference_id == book_ref_id) \ .filter(Verse.chapter == chapter) \ @@ -551,7 +553,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param name: The name or abbreviation of the book. :param lower: True if the comparison should be only lowercase """ - log.debug('BiblesResourcesDB.get_book("%s")' % name) + log.debug('BiblesResourcesDB.get_book("{name}")'.format(name=name)) if not isinstance(name, str): name = str(name) if lower: @@ -580,7 +582,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param string: The string to search for in the book names or abbreviations. """ - log.debug('BiblesResourcesDB.get_book_like("%s")' % string) + log.debug('BiblesResourcesDB.get_book_like("{text}")'.format(text=string)) if not isinstance(string, str): name = str(string) books = BiblesResourcesDB.run_sql( @@ -605,7 +607,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param book_id: The id of the book. """ - log.debug('BiblesResourcesDB.get_book_by_id("%s")' % book_id) + log.debug('BiblesResourcesDB.get_book_by_id("{book}")'.format(book=book_id)) if not isinstance(book_id, int): book_id = int(book_id) books = BiblesResourcesDB.run_sql( @@ -629,7 +631,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param book_ref_id: The id of a book. :param chapter: The chapter number. """ - log.debug('BiblesResourcesDB.get_chapter("%s", "%s")' % (book_ref_id, chapter)) + log.debug('BiblesResourcesDB.get_chapter("{book}", "{ref}")'.format(book=book_ref_id, ref=chapter)) if not isinstance(chapter, int): chapter = int(chapter) chapters = BiblesResourcesDB.run_sql( @@ -652,7 +654,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param book_ref_id: The id of the book. """ - log.debug('BiblesResourcesDB.get_chapter_count("%s")' % book_ref_id) + log.debug('BiblesResourcesDB.get_chapter_count("{ref}")'.format(ref=book_ref_id)) details = BiblesResourcesDB.get_book_by_id(book_ref_id) if details: return details['chapters'] @@ -666,7 +668,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param book_ref_id: The id of the book. :param chapter: The number of the chapter. """ - log.debug('BiblesResourcesDB.get_verse_count("%s", "%s")' % (book_ref_id, chapter)) + log.debug('BiblesResourcesDB.get_verse_count("{ref}", "{chapter}")'.format(ref=book_ref_id, chapter=chapter)) details = BiblesResourcesDB.get_chapter(book_ref_id, chapter) if details: return details['verse_count'] @@ -679,7 +681,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param source: The name or abbreviation of the book. """ - log.debug('BiblesResourcesDB.get_download_source("%s")' % source) + log.debug('BiblesResourcesDB.get_download_source("{source}")'.format(source=source)) if not isinstance(source, str): source = str(source) source = source.title() @@ -700,7 +702,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param source: The source of the web_bible. """ - log.debug('BiblesResourcesDB.get_webbibles("%s")' % source) + log.debug('BiblesResourcesDB.get_webbibles("{source}")'.format(source=source)) if not isinstance(source, str): source = str(source) source = BiblesResourcesDB.get_download_source(source) @@ -725,7 +727,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param abbreviation: The abbreviation of the web_bible. :param source: The source of the web_bible. """ - log.debug('BiblesResourcesDB.get_webbibles("%s", "%s")' % (abbreviation, source)) + log.debug('BiblesResourcesDB.get_webbibles("{text}", "{source}")'.format(text=abbreviation, source=source)) if not isinstance(abbreviation, str): abbreviation = str(abbreviation) if not isinstance(source, str): @@ -753,7 +755,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param name: The name to search the id. :param language_id: The language_id for which language should be searched """ - log.debug('BiblesResourcesDB.get_alternative_book_name("%s", "%s")' % (name, language_id)) + log.debug('BiblesResourcesDB.get_alternative_book_name("{name}", "{lang}")'.format(name=name, lang=language_id)) if language_id: books = BiblesResourcesDB.run_sql( 'SELECT book_reference_id, name FROM alternative_book_names WHERE language_id = ? ORDER BY id', @@ -772,7 +774,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param name: The name or abbreviation of the language. """ - log.debug('BiblesResourcesDB.get_language("%s")' % name) + log.debug('BiblesResourcesDB.get_language("{name}")'.format(name=name)) if not isinstance(name, str): name = str(name) language = BiblesResourcesDB.run_sql( @@ -868,7 +870,7 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): :param name: The name to search the id. :param language_id: The language_id for which language should be searched """ - log.debug('AlternativeBookNamesDB.get_book_reference_id("%s", "%s")' % (name, language_id)) + log.debug('AlternativeBookNamesDB.get_book_reference_id("{name}", "{ref}")'.format(name=name, ref=language_id)) if language_id: books = AlternativeBookNamesDB.run_sql( 'SELECT book_reference_id, name FROM alternative_book_names WHERE language_id = ?', (language_id, )) @@ -889,8 +891,8 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): :param book_reference_id: The book_reference_id of the book. :param language_id: The language to which the alternative book name belong. """ - log.debug('AlternativeBookNamesDB.create_alternative_book_name("%s", "%s", "%s")' % - (name, book_reference_id, language_id)) + log.debug('AlternativeBookNamesDB.create_alternative_book_name("{name}", ' + '"{ref}", "{lang}")'.format(name=name, ref=book_reference_id, lang=language_id)) return AlternativeBookNamesDB.run_sql( 'INSERT INTO alternative_book_names(book_reference_id, language_id, name) ' 'VALUES (?, ?, ?)', (book_reference_id, language_id, name), True) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 2076bec87..c50745c2f 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -90,7 +90,7 @@ class BGExtract(RegistryProperties): Extract verses from BibleGateway """ def __init__(self, proxy_url=None): - log.debug('BGExtract.init("%s")', proxy_url) + log.debug('BGExtract.init("{url}")'.format(url=proxy_url)) self.proxy_url = proxy_url socket.setdefaulttimeout(30) @@ -188,7 +188,7 @@ class BGExtract(RegistryProperties): if len(verse_parts) > 1: verse = int(verse_parts[0]) except TypeError: - log.warning('Illegal verse number: %s', str(verse)) + log.warning('Illegal verse number: {verse:d}'.format(verse=verse)) verses.append((verse, text)) verse_list = {} for verse, text in verses[::-1]: @@ -221,7 +221,7 @@ class BGExtract(RegistryProperties): if len(verse_parts) > 1: clean_verse_num = int(verse_parts[0]) except TypeError: - log.warning('Illegal verse number: %s', str(raw_verse_num)) + log.warning('Illegal verse number: {verse:d}'.format(verse=raw_verse_num)) if clean_verse_num: verse_text = raw_verse_num.next_element part = raw_verse_num.next_element.next_element @@ -244,11 +244,15 @@ class BGExtract(RegistryProperties): :param book_name: Name of the Book. :param chapter: Chapter number. """ - log.debug('BGExtract.get_bible_chapter("%s", "%s", "%s")', version, book_name, chapter) + log.debug('BGExtract.get_bible_chapter("{version}", "{name}", "{chapter}")'.format(version=version, + name=book_name, + chapter=chapter)) url_book_name = urllib.parse.quote(book_name.encode("utf-8")) - url_params = 'search=%s+%s&version=%s' % (url_book_name, chapter, version) + url_params = 'search={name}+{chapter}&version={version}'.format(name=url_book_name, + chapter=chapter, + version=version) soup = get_soup_for_bible_ref( - 'http://legacy.biblegateway.com/passage/?%s' % url_params, + 'http://legacy.biblegateway.com/passage/?{url}'.format(url=url_params), pre_parse_regex=r'', pre_parse_substitute='') if not soup: return None @@ -257,7 +261,7 @@ class BGExtract(RegistryProperties): return None self._clean_soup(div) span_list = div.find_all('span', 'text') - log.debug('Span list: %s', span_list) + log.debug('Span list: {span}'.format(span=span_list)) if not span_list: # If we don't get any spans then we must have the old HTML format verse_list = self._extract_verses_old(div) @@ -275,9 +279,9 @@ class BGExtract(RegistryProperties): :param version: The version of the Bible like NIV for New International Version """ - log.debug('BGExtract.get_books_from_http("%s")', version) - url_params = urllib.parse.urlencode({'action': 'getVersionInfo', 'vid': '%s' % version}) - reference_url = 'http://legacy.biblegateway.com/versions/?%s#books' % url_params + log.debug('BGExtract.get_books_from_http("{version}")'.format(version=version)) + url_params = urllib.parse.urlencode({'action': 'getVersionInfo', 'vid': '{version}'.format(version=version)}) + reference_url = 'http://legacy.biblegateway.com/versions/?{url}#books'.format(url=url_params) page = get_web_page(reference_url) if not page: send_error_message('download') @@ -353,7 +357,7 @@ class BSExtract(RegistryProperties): Extract verses from Bibleserver.com """ def __init__(self, proxy_url=None): - log.debug('BSExtract.init("%s")', proxy_url) + log.debug('BSExtract.init("{url}")'.format(url=proxy_url)) self.proxy_url = proxy_url socket.setdefaulttimeout(30) @@ -365,10 +369,14 @@ class BSExtract(RegistryProperties): :param book_name: Text name of bible book e.g. Genesis, 1. John, 1John or Offenbarung :param chapter: Chapter number """ - log.debug('BSExtract.get_bible_chapter("%s", "%s", "%s")', version, book_name, chapter) + log.debug('BSExtract.get_bible_chapter("{version}", "{book}", "{chapter}")'.format(version=version, + book=book_name, + chapter=chapter)) url_version = urllib.parse.quote(version.encode("utf-8")) url_book_name = urllib.parse.quote(book_name.encode("utf-8")) - chapter_url = 'http://m.bibleserver.com/text/%s/%s%d' % (url_version, url_book_name, chapter) + chapter_url = 'http://m.bibleserver.com/text/{version}/{name}{chapter:d}'.format(version=url_version, + name=url_book_name, + chapter=chapter) header = ('Accept-Language', 'en') soup = get_soup_for_bible_ref(chapter_url, header) if not soup: @@ -393,9 +401,9 @@ class BSExtract(RegistryProperties): :param version: The version of the Bible like NIV for New International Version """ - log.debug('BSExtract.get_books_from_http("%s")', version) + log.debug('BSExtract.get_books_from_http("{version}")'.format(version=version)) url_version = urllib.parse.quote(version.encode("utf-8")) - chapter_url = 'http://m.bibleserver.com/overlay/selectBook?translation=%s' % url_version + chapter_url = 'http://m.bibleserver.com/overlay/selectBook?translation={version}'.format(version=url_version) soup = get_soup_for_bible_ref(chapter_url) if not soup: return None @@ -450,7 +458,7 @@ class CWExtract(RegistryProperties): Extract verses from CrossWalk/BibleStudyTools """ def __init__(self, proxy_url=None): - log.debug('CWExtract.init("%s")', proxy_url) + log.debug('CWExtract.init("{url}")'.format(url=proxy_url)) self.proxy_url = proxy_url socket.setdefaulttimeout(30) @@ -462,11 +470,15 @@ class CWExtract(RegistryProperties): :param book_name: Text name of in english e.g. 'gen' for Genesis :param chapter: Chapter number """ - log.debug('CWExtract.get_bible_chapter("%s", "%s", "%s")', version, book_name, chapter) + log.debug('CWExtract.get_bible_chapter("{version}", "{book}", "{chapter}")'.format(version=version, + book=book_name, + chapter=chapter)) url_book_name = book_name.replace(' ', '-') url_book_name = url_book_name.lower() url_book_name = urllib.parse.quote(url_book_name.encode("utf-8")) - chapter_url = 'http://www.biblestudytools.com/%s/%s/%s.html' % (version, url_book_name, chapter) + chapter_url = 'http://www.biblestudytools.com/{version}/{book}/{chapter}.html'.format(version=version, + book=url_book_name, + chapter=chapter) soup = get_soup_for_bible_ref(chapter_url) if not soup: return None @@ -499,8 +511,8 @@ class CWExtract(RegistryProperties): :param version: The version of the bible like NIV for New International Version """ - log.debug('CWExtract.get_books_from_http("%s")', version) - chapter_url = 'http://www.biblestudytools.com/%s/' % version + log.debug('CWExtract.get_books_from_http("{version}")'.format(version=version)) + chapter_url = 'http://www.biblestudytools.com/{version}/'.format(version=version) soup = get_soup_for_bible_ref(chapter_url) if not soup: return None @@ -559,7 +571,7 @@ class CWExtract(RegistryProperties): class HTTPBible(BibleDB, RegistryProperties): - log.info('%s HTTPBible loaded', __name__) + log.info('{name} HTTPBible loaded'.format(name=__name__)) def __init__(self, parent, **kwargs): """ @@ -615,8 +627,8 @@ class HTTPBible(BibleDB, RegistryProperties): handler = BSExtract(self.proxy_server) books = handler.get_books_from_http(self.download_name) if not books: - log.error('Importing books from %s - download name: "%s" failed' % - (self.download_source, self.download_name)) + log.error('Importing books from {source} - download name: "{name}" ' + 'failed'.format(source=self.download_source, name=self.download_name)) return False self.wizard.progress_bar.setMaximum(len(books) + 2) self.wizard.increment_progress_bar(translate('BiblesPlugin.HTTPBible', 'Registering Language...')) @@ -625,21 +637,24 @@ class HTTPBible(BibleDB, RegistryProperties): else: self.language_id = self.get_language(bible_name) if not self.language_id: - log.error('Importing books from %s failed' % self.filename) + log.error('Importing books from {name} failed'.format(name=self.filename)) return False for book in books: if self.stop_import_flag: break - self.wizard.increment_progress_bar(translate( - 'BiblesPlugin.HTTPBible', 'Importing %s...', 'Importing ...') % book) + self.wizard.increment_progress_bar(translate('BiblesPlugin.HTTPBible', + 'Importing {book}...', + 'Importing ...').format(book=book)) book_ref_id = self.get_book_ref_id_by_name(book, len(books), self.language_id) if not book_ref_id: - log.error('Importing books from %s - download name: "%s" failed' % - (self.download_source, self.download_name)) + log.error('Importing books from {source} - download name: "{name}" ' + 'failed'.format(source=self.download_source, name=self.download_name)) return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) - log.debug('Book details: Name:%s; id:%s; testament_id:%s', - book, book_ref_id, book_details['testament_id']) + log.debug('Book details: Name:{book}; id:{ref}; ' + 'testament_id:{detail}'.format(book=book, + ref=book_ref_id, + detail=book_details['testament_id'])) self.create_book(book, book_ref_id, book_details['testament_id']) if self.stop_import_flag: return False @@ -664,7 +679,7 @@ class HTTPBible(BibleDB, RegistryProperties): [('35', 1, 1, 1), ('35', 2, 2, 3)] """ - log.debug('HTTPBible.get_verses("%s")', reference_list) + log.debug('HTTPBible.get_verses("{ref}")'.format(ref=reference_list)) for reference in reference_list: book_id = reference[0] db_book = self.get_book_by_book_ref_id(book_id) @@ -698,8 +713,8 @@ class HTTPBible(BibleDB, RegistryProperties): """ Receive the request and call the relevant handler methods. """ - log.debug('HTTPBible.get_chapter("%s", "%s")', book, chapter) - log.debug('source = %s', self.download_source) + log.debug('HTTPBible.get_chapter("{book}", "{chapter}")'.format(book=book, chapter=chapter)) + log.debug('source = {source}'.format(source=self.download_source)) if self.download_source.lower() == 'crosswalk': handler = CWExtract(self.proxy_server) elif self.download_source.lower() == 'biblegateway': @@ -712,7 +727,7 @@ class HTTPBible(BibleDB, RegistryProperties): """ Return the list of books. """ - log.debug('HTTPBible.get_books("%s")', Book.name) + log.debug('HTTPBible.get_books("{name}")'.format(name=Book.name)) return self.get_all_objects(Book, order_by_ref=Book.id) def get_chapter_count(self, book): @@ -721,7 +736,7 @@ class HTTPBible(BibleDB, RegistryProperties): :param book: The book object to get the chapter count for. """ - log.debug('HTTPBible.get_chapter_count("%s")', book.name) + log.debug('HTTPBible.get_chapter_count("{name}")'.format(name=book.name)) return BiblesResourcesDB.get_chapter_count(book.book_reference_id) def get_verse_count(self, book_id, chapter): @@ -731,7 +746,7 @@ class HTTPBible(BibleDB, RegistryProperties): :param book_id: The name of the book. :param chapter: The chapter whose verses are being counted. """ - log.debug('HTTPBible.get_verse_count("%s", %s)', book_id, chapter) + log.debug('HTTPBible.get_verse_count("{ref}", {chapter})'.format(ref=book_id, chapter=chapter)) return BiblesResourcesDB.get_verse_count(book_id, chapter) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 85521402c..d1465475d 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -122,7 +122,7 @@ class BibleManager(RegistryProperties): files = AppLocation.get_files(self.settings_section, self.suffix) if 'alternative_book_names.sqlite' in files: files.remove('alternative_book_names.sqlite') - log.debug('Bible Files %s', files) + log.debug('Bible Files {text}'.format(text=files)) self.db_cache = {} self.old_bible_databases = [] for filename in files: @@ -135,7 +135,7 @@ class BibleManager(RegistryProperties): bible.session.close() delete_file(os.path.join(self.path, filename)) continue - log.debug('Bible Name: "%s"', name) + log.debug('Bible Name: "{name}"'.format(name=name)) self.db_cache[name] = bible # Look to see if lazy load bible exists and get create getter. source = self.db_cache[name].get_object(BibleMeta, 'download_source') @@ -177,7 +177,7 @@ class BibleManager(RegistryProperties): :param name: The name of the bible. """ - log.debug('BibleManager.delete_bible("%s")', name) + log.debug('BibleManager.delete_bible("{name}")'.format(name=name)) bible = self.db_cache[name] bible.session.close() bible.session = None @@ -196,7 +196,7 @@ class BibleManager(RegistryProperties): :param bible: Unicode. The Bible to get the list of books from. """ - log.debug('BibleManager.get_books("%s")', bible) + log.debug('BibleManager.get_books("{bible}")'.format(bible=bible)) return [ { 'name': book.name, @@ -213,7 +213,7 @@ class BibleManager(RegistryProperties): :param bible: Unicode. The Bible to get the list of books from. :param id: Unicode. The book_reference_id to get the book for. """ - log.debug('BibleManager.get_book_by_id("%s", "%s")', bible, id) + log.debug('BibleManager.get_book_by_id("{bible}", "{ref}")'.format(bible=bible, ref=id)) return self.db_cache[bible].get_book_by_book_ref_id(id) def get_chapter_count(self, bible, book): @@ -223,14 +223,16 @@ class BibleManager(RegistryProperties): :param bible: Unicode. The Bible to get the list of books from. :param book: The book object to get the chapter count for. """ - log.debug('BibleManager.get_book_chapter_count ("%s", "%s")', bible, book.name) + log.debug('BibleManager.get_book_chapter_count ("{bible}", "{name}")'.format(bible=bible, name=book.name)) return self.db_cache[bible].get_chapter_count(book) def get_verse_count(self, bible, book, chapter): """ Returns all the number of verses for a given book and chapterMaxBibleBookVerses. """ - log.debug('BibleManager.get_verse_count("%s", "%s", %s)', bible, book, chapter) + log.debug('BibleManager.get_verse_count("{bible}", "{book}", {chapter})'.format(bible=bible, + book=book, + chapter=chapter)) language_selection = self.get_language_selection(bible) book_ref_id = self.db_cache[bible].get_book_ref_id_by_localised_name(book, language_selection) return self.db_cache[bible].get_verse_count(book_ref_id, chapter) @@ -240,7 +242,8 @@ class BibleManager(RegistryProperties): Returns all the number of verses for a given book_ref_id and chapterMaxBibleBookVerses. """ - log.debug('BibleManager.get_verse_count_by_book_ref_id("%s", "%s", "%s")', bible, book_ref_id, chapter) + log.debug('BibleManager.get_verse_count_by_book_ref_id("{bible}", ' + '"{book}", "{chapter}")'.format(bible=bible, book=book_ref_id, chapter=chapter)) return self.db_cache[bible].get_verse_count(book_ref_id, chapter) def get_verses(self, bible, verse_text, book_ref_id=False, show_error=True): @@ -264,7 +267,7 @@ class BibleManager(RegistryProperties): For second bible this is necessary. :param show_error: """ - log.debug('BibleManager.get_verses("%s", "%s")', bible, verse_text) + log.debug('BibleManager.get_verses("{bible}", "{verse}")'.format(bible=bible, verse=verse_text)) if not bible: if show_error: self.main_window.information_message( @@ -308,7 +311,7 @@ class BibleManager(RegistryProperties): :param bible: Unicode. The Bible to get the language selection from. """ - log.debug('BibleManager.get_language_selection("%s")', bible) + log.debug('BibleManager.get_language_selection("{bible}")'.format(bible=bible)) language_selection = self.get_meta_data(bible, 'book_name_language') if not language_selection or language_selection.value == "None" or language_selection.value == "-1": # If None is returned, it's not the singleton object but a @@ -330,7 +333,7 @@ class BibleManager(RegistryProperties): :param second_bible: The second bible (unicode). We do not search in this bible. :param text: The text to search for (unicode). """ - log.debug('BibleManager.verse_search("%s", "%s")', bible, text) + log.debug('BibleManager.verse_search("{bible}", "{text}")'.format(bible=bible, text=text)) if not bible: self.main_window.information_message( translate('BiblesPlugin.BibleManager', 'No Bibles Available'), @@ -365,7 +368,10 @@ class BibleManager(RegistryProperties): """ Saves the bibles meta data. """ - log.debug('save_meta data %s, %s, %s, %s', bible, version, copyright, permissions) + log.debug('save_meta data {bible}, {version}, {copyright}, {perms}'.format(bible=bible, + version=version, + cr=copyright, + perms=permissions)) self.db_cache[bible].save_meta('name', version) self.db_cache[bible].save_meta('copyright', copyright) self.db_cache[bible].save_meta('permissions', permissions) @@ -375,14 +381,14 @@ class BibleManager(RegistryProperties): """ Returns the meta data for a given key. """ - log.debug('get_meta %s,%s', bible, key) + log.debug('get_meta {bible},{key}'.format(bible=bible, key=key)) return self.db_cache[bible].get_object(BibleMeta, key) def update_book(self, bible, book): """ Update a book of the bible. """ - log.debug('BibleManager.update_book("%s", "%s")', bible, book.name) + log.debug('BibleManager.update_book("{bible}", "{name}")'.format(bible=bible, name=book.name)) self.db_cache[bible].update_book(book) def exists(self, name): @@ -392,7 +398,7 @@ class BibleManager(RegistryProperties): if not isinstance(name, str): name = str(name) for bible in list(self.db_cache.keys()): - log.debug('Bible from cache in is_new_bible %s', bible) + log.debug('Bible from cache in is_new_bible {bible}'.format(bible=bible)) if not isinstance(bible, str): bible = str(bible) if bible == name: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 1d7b5a897..d6e7eb62e 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -280,7 +280,7 @@ class BibleMediaItem(MediaManagerItem): def retranslateUi(self): log.debug('retranslateUi') self.quick_search_label.setText(translate('BiblesPlugin.MediaItem', 'Find:')) - self.quickVersionLabel.setText('%s:' % UiStrings().Version) + self.quickVersionLabel.setText('{version}:'.format(version=UiStrings().Version)) self.quickSecondLabel.setText(translate('BiblesPlugin.MediaItem', 'Second:')) self.quickStyleLabel.setText(UiStrings().LayoutStyle) self.quickStyleComboBox.setItemText(LayoutStyle.VersePerSlide, UiStrings().VersePerSlide) @@ -294,7 +294,7 @@ class BibleMediaItem(MediaManagerItem): self.advanced_verse_label.setText(translate('BiblesPlugin.MediaItem', 'Verse:')) self.advanced_from_label.setText(translate('BiblesPlugin.MediaItem', 'From:')) self.advanced_to_label.setText(translate('BiblesPlugin.MediaItem', 'To:')) - self.advancedVersionLabel.setText('%s:' % UiStrings().Version) + self.advancedVersionLabel.setText('{version}:'.format(version=UiStrings().Version)) self.advancedSecondLabel.setText(translate('BiblesPlugin.MediaItem', 'Second:')) self.advancedStyleLabel.setText(UiStrings().LayoutStyle) self.advancedStyleComboBox.setItemText(LayoutStyle.VersePerSlide, UiStrings().VersePerSlide) @@ -316,7 +316,8 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.MediaItem', 'Text Search'), translate('BiblesPlugin.MediaItem', 'Search Text...')) ]) - self.quick_search_edit.set_current_search_type(Settings().value('%s/last search type' % self.settings_section)) + text = self.settings_section + self.quick_search_edit.set_current_search_type(Settings().value('{text}/last search type'.format(text=text))) self.config_update() log.debug('bible manager initialise complete') @@ -364,7 +365,7 @@ class BibleMediaItem(MediaManagerItem): :param bible: The bible to initialise (unicode). :param last_book_id: The "book reference id" of the book which is chosen at the moment. (int) """ - log.debug('initialise_advanced_bible %s, %s', bible, last_book_id) + log.debug('initialise_advanced_bible {bible}, {ref}'.format(bible=bible, ref=last_book_id)) book_data = self.plugin.manager.get_books(bible) second_bible = self.advancedSecondComboBox.currentText() if second_bible != '': @@ -406,7 +407,7 @@ class BibleMediaItem(MediaManagerItem): self.initialise_chapter_verse(bible, first_book['name'], first_book['book_reference_id']) def initialise_chapter_verse(self, bible, book, book_ref_id): - log.debug('initialise_chapter_verse %s, %s, %s', bible, book, book_ref_id) + log.debug('initialise_chapter_verse {bible}, {book), {ref}'.format(bible=bible, book=book, ref=book_ref_id)) book = self.plugin.manager.get_book_by_id(bible, book_ref_id) self.chapter_count = self.plugin.manager.get_chapter_count(bible, book) verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible, book_ref_id, 1) @@ -427,9 +428,11 @@ class BibleMediaItem(MediaManagerItem): """ log.debug('update_auto_completer') # Save the current search type to the configuration. - Settings().setValue('%s/last search type' % self.settings_section, self.quick_search_edit.current_search_type()) + Settings().setValue('{section}/last search type'.format(section=self.settings_section), + self.quick_search_edit.current_search_type()) # Save the current bible to the configuration. - Settings().setValue(self.settings_section + '/quick bible', self.quickVersionComboBox.currentText()) + Settings().setValue('{section}/quick bible'.format(section=self.settings_section), + self.quickVersionComboBox.currentText()) books = [] # We have to do a 'Reference Search'. if self.quick_search_edit.current_search_type() == BibleSearch.Reference: @@ -502,9 +505,10 @@ class BibleMediaItem(MediaManagerItem): if bible: if QtWidgets.QMessageBox.question( self, UiStrings().ConfirmDelete, - translate('BiblesPlugin.MediaItem', 'Are you sure you want to completely delete "%s" Bible from ' - 'OpenLP?\n\nYou will need to re-import this Bible to use it ' - 'again.') % bible, + translate('BiblesPlugin.MediaItem', + 'Are you sure you want to completely delete "{bible}" Bible ' + 'from OpenLP?\n\nYou will need to re-import this Bible to use it ' + 'again.').format(bible=bible), QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No), QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.No: return @@ -606,7 +610,7 @@ class BibleMediaItem(MediaManagerItem): :param combo: The combo box itself (QComboBox). :param restore: If True, then the combo's currentText will be restored after adjusting (if possible). """ - log.debug('adjust_combo_box %s, %s, %s', combo, range_from, range_to) + log.debug('adjust_combo_box {box}, {start}, {end}'.format(box=combo, start=range_from, end=range_to)) if restore: old_text = combo.currentText() combo.clear() @@ -633,7 +637,7 @@ class BibleMediaItem(MediaManagerItem): range_separator = get_reference_separator('sep_r_display') verse_range = chapter_from + verse_separator + verse_from + range_separator + chapter_to + \ verse_separator + verse_to - verse_text = '%s %s' % (book, verse_range) + verse_text = '{book} {verse}'.format(book=book, verse=verse_range) self.application.set_busy_cursor() self.search_results = self.plugin.manager.get_verses(bible, verse_text, book_ref_id) if second_bible: @@ -678,8 +682,8 @@ class BibleMediaItem(MediaManagerItem): for verse in self.search_results: db_book = bibles[second_bible].get_book_by_book_ref_id(verse.book.book_reference_id) if not db_book: - log.debug('Passage "%s %d:%d" not found in Second Bible' % - (verse.book.name, verse.chapter, verse.verse)) + log.debug('Passage "{name} {chapter:d}:{verse:d}" not found in ' + 'Second Bible'.format(name=verse.book.name, chapter=verse.chapter, verse=verse.verse)) passage_not_found = True count += 1 continue @@ -688,9 +692,10 @@ class BibleMediaItem(MediaManagerItem): if passage_not_found: QtWidgets.QMessageBox.information( self, translate('BiblesPlugin.MediaItem', 'Information'), - translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses ' - 'that are in the main Bible. Only verses found in both Bibles will be shown. %d ' - 'verses have not been included in the results.') % count, + translate('BiblesPlugin.MediaItem', + 'The second Bible does not contain all the verses that are in the main Bible. ' + 'Only verses found in both Bibles will be shown. {count:d} verses have not been ' + 'included in the results.').format(count=count), QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok)) self.search_results = new_search_results self.second_search_results = bibles[second_bible].get_verses(text) @@ -767,10 +772,19 @@ class BibleMediaItem(MediaManagerItem): except TypeError: log.exception('The second_search_results does not have this book.') break - bible_text = '%s %d%s%d (%s, %s)' % (book, verse.chapter, verse_separator, verse.verse, version, - second_version) + bible_text = ('{book} {chapter:d}{sep}{verse:d} ' + '({version1}, {version2})').format(book=book, + chapter=verse.chapter, + sep=verse_separator, + verse=verse.verse, + version1=version, + version2=second_version) else: - bible_text = '%s %d%s%d (%s)' % (book, verse.chapter, verse_separator, verse.verse, version) + bible_text = '{book} {chapter:d}{sep}{verse:d} ({version})'.format(book=book, + chapter=verse.chapter, + sep=verse_separator, + verse=verse.verse, + version=version) bible_verse = QtWidgets.QListWidgetItem(bible_text) bible_verse.setData(QtCore.Qt.UserRole, data) items.append(bible_verse) @@ -817,20 +831,22 @@ class BibleMediaItem(MediaManagerItem): verses.add(book, chapter, verse, version, copyright, permissions) verse_text = self.format_verse(old_chapter, chapter, verse) if second_bible: - bible_text = '%s%s\n\n%s %s' % (verse_text, text, verse_text, second_text) + bible_text = '{verse}{text1}\n\n{verse} {text2}'.format(verse=verse_text, + text1=text, + text2=second_text) raw_slides.append(bible_text.rstrip()) bible_text = '' # If we are 'Verse Per Slide' then create a new slide. elif self.settings.layout_style == LayoutStyle.VersePerSlide: - bible_text = '%s%s' % (verse_text, text) + bible_text = '{verse}{text}'.format(verse=verse_text, text=text) raw_slides.append(bible_text.rstrip()) bible_text = '' # If we are 'Verse Per Line' then force a new line. elif self.settings.layout_style == LayoutStyle.VersePerLine: - bible_text = '%s%s%s\n' % (bible_text, verse_text, text) + bible_text = '{bible}{verse}{text}\n'.format(bible=bible_text, verse=verse_text, text=text) # We have to be 'Continuous'. else: - bible_text = '%s %s%s\n' % (bible_text, verse_text, text) + bible_text = '{bible} {verse}{text}\n'.format(bible=bible_text, verse=verse_text, text=text) bible_text = bible_text.strip(' ') if not old_item: start_item = bitem @@ -857,7 +873,7 @@ class BibleMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.CanWordSplit) service_item.add_capability(ItemCapabilities.CanEditTitle) # Service Item: Title - service_item.title = '%s %s' % (verses.format_verses(), verses.format_versions()) + service_item.title = '{verse} {version}'.format(verse=verses.format_verses(), version=verses.format_versions()) # Service Item: Theme if not self.settings.bible_theme: service_item.theme = None @@ -885,7 +901,7 @@ class BibleMediaItem(MediaManagerItem): start_bible = self._decode_qt_object(start_bitem, 'bible') start_second_bible = self._decode_qt_object(start_bitem, 'second_bible') if start_second_bible: - bibles = '%s, %s' % (start_bible, start_second_bible) + bibles = '{bible1}, {bible2}'.format(bible1=start_bible, bible2=start_second_bible) else: bibles = start_bible if start_chapter == old_chapter: @@ -896,7 +912,7 @@ class BibleMediaItem(MediaManagerItem): else: verse_range = start_chapter + verse_separator + start_verse + \ range_separator + old_chapter + verse_separator + old_verse - return '%s %s (%s)' % (start_book, verse_range, bibles) + return '{book} {verse} ({bible})'.format(book=start_book, verse=verse_range, bible=bibles) def check_title(self, bitem, old_bitem): """ @@ -949,12 +965,12 @@ class BibleMediaItem(MediaManagerItem): else: verse_text = str(verse) if self.settings.display_style == DisplayStyle.Round: - return '{su}(%s){/su} ' % verse_text + return '{{su}}({verse}){{/su}} '.format(verse=verse_text) if self.settings.display_style == DisplayStyle.Curly: - return '{su}{%s}{/su} ' % verse_text + return '{{su}}{{{verse}}}{{/su}} '.format(verse=verse_text) if self.settings.display_style == DisplayStyle.Square: - return '{su}[%s]{/su} ' % verse_text - return '{su}%s{/su} ' % verse_text + return '{{su}}[{verse}]{{/su}} '.format(verse=verse_text) + return '{{su}}{verse}{{/su}} '.format(verse=verse_text) def search(self, string, showError): """ diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index b2836dcd4..af3ef64c0 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -63,7 +63,7 @@ class OpenSongBible(BibleDB): """ Loads a Bible from file. """ - log.debug('Starting OpenSong import from "%s"' % self.filename) + log.debug('Starting OpenSong import from "{name}"'.format(name=self.filename)) if not isinstance(self.filename, str): self.filename = str(self.filename, 'utf8') import_file = None @@ -84,14 +84,14 @@ class OpenSongBible(BibleDB): # No language info in the opensong format, so ask the user language_id = self.get_language(bible_name) if not language_id: - log.error('Importing books from "%s" failed' % self.filename) + log.error('Importing books from "{name}" failed'.format(name=self.filename)) return False for book in bible.b: if self.stop_import_flag: break book_ref_id = self.get_book_ref_id_by_name(str(book.attrib['n']), len(bible.b), language_id) if not book_ref_id: - log.error('Importing books from "%s" failed' % self.filename) + log.error('Importing books from "{name}" failed'.format(name=self.filename)) return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) db_book = self.create_book(book.attrib['n'], book_ref_id, book_details['testament_id']) @@ -117,14 +117,14 @@ class OpenSongBible(BibleDB): if len(verse_parts) > 1: number = int(verse_parts[0]) except TypeError: - log.warning('Illegal verse number: %s', str(verse.attrib['n'])) + log.warning('Illegal verse number: {verse:d}'.format(verse.attrib['n'])) verse_number = number else: verse_number += 1 self.create_verse(db_book.id, chapter_number, verse_number, self.get_text(verse)) - self.wizard.increment_progress_bar( - translate('BiblesPlugin.Opensong', 'Importing %(bookname)s %(chapter)s...') % - {'bookname': db_book.name, 'chapter': chapter_number}) + self.wizard.increment_progress_bar(translate('BiblesPlugin.Opensong', + 'Importing {name} {chapter}...' + ).format(name=db_book.name, chapter=chapter_number)) self.session.commit() self.application.process_events() except etree.XMLSyntaxError as inst: diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index acba710c1..c0a3bec81 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -49,7 +49,7 @@ class OSISBible(BibleDB): """ Loads a Bible from file. """ - log.debug('Starting OSIS import from "%s"' % self.filename) + log.debug('Starting OSIS import from "{name}"'.format(name=self.filename)) if not isinstance(self.filename, str): self.filename = str(self.filename, 'utf8') import_file = None @@ -69,7 +69,7 @@ class OSISBible(BibleDB): if not language_id: language_id = self.get_language(bible_name) if not language_id: - log.error('Importing books from "%s" failed' % self.filename) + log.error('Importing books from "{name}" failed'.format(name=self.filename)) return False self.save_meta('language_id', language_id) num_books = int(osis_bible_tree.xpath("count(//ns:div[@type='book'])", namespaces=namespace)) @@ -129,7 +129,7 @@ class OSISBible(BibleDB): if not book_ref_id: book_ref_id = self.get_book_ref_id_by_localised_name(book.get('osisID')) if not book_ref_id: - log.error('Importing books from "%s" failed' % self.filename) + log.error('Importing books from "{name}" failed'.format(name=self.filename)) return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) db_book = self.create_book(book_details['name'], book_ref_id, book_details['testament_id']) @@ -187,7 +187,8 @@ class OSISBible(BibleDB): trace_error_handler(log) success = False critical_error_message_box(message=translate('BiblesPlugin.OsisImport', - 'The file is not a valid OSIS-XML file: \n%s' % e.msg)) + 'The file is not a valid OSIS-XML file:' + '\n{text}').format(text=e.msg)) finally: if import_file: import_file.close() diff --git a/openlp/plugins/bibles/lib/sword.py b/openlp/plugins/bibles/lib/sword.py index 6f91803a6..77f08cb47 100644 --- a/openlp/plugins/bibles/lib/sword.py +++ b/openlp/plugins/bibles/lib/sword.py @@ -51,7 +51,7 @@ class SwordBible(BibleDB): """ Loads a Bible from SWORD module. """ - log.debug('Starting SWORD import from "%s"' % self.sword_key) + log.debug('Starting SWORD import from "{key}"'.format(key=self.sword_key)) success = True try: pysword_modules = modules.SwordModules(self.sword_path) @@ -84,14 +84,14 @@ class SwordBible(BibleDB): verse_number += 1 self.create_verse(db_book.id, chapter_number, verse_number, verse) self.wizard.increment_progress_bar( - translate('BiblesPlugin.Sword', 'Importing %s...') % db_book.name) + translate('BiblesPlugin.Sword', 'Importing {name}...').format(name=db_book.name)) self.session.commit() self.application.process_events() except Exception as e: critical_error_message_box( message=translate('BiblesPlugin.SwordImport', 'An unexpected error happened while importing the SWORD ' 'bible, please report this to the OpenLP developers.\n' - '%s' % e)) + '{error}').format(error=e)) log.exception(str(e)) success = False if self.stop_import_flag: diff --git a/openlp/plugins/bibles/lib/upgrade.py b/openlp/plugins/bibles/lib/upgrade.py index 7cc58ef7b..aebd088e8 100644 --- a/openlp/plugins/bibles/lib/upgrade.py +++ b/openlp/plugins/bibles/lib/upgrade.py @@ -101,7 +101,7 @@ def upgrade_1(session, metadata): metadata_table.c.key == 'download source' ) ).scalar() - log.debug('download source: %s', value_count) + log.debug('download source: {count}'.format(count=value_count)) if value_count > 0: session.execute(insert(metadata_table).values( key='download_source', @@ -121,7 +121,7 @@ def upgrade_1(session, metadata): metadata_table.c.key == 'download name' ) ).scalar() - log.debug('download name: %s', value_count) + log.debug('download name: {count}'.format(count=value_count)) if value_count > 0: session.execute(insert(metadata_table).values( key='download_name', @@ -141,7 +141,7 @@ def upgrade_1(session, metadata): metadata_table.c.key == 'proxy server' ) ).scalar() - log.debug('proxy server: %s', value_count) + log.debug('proxy server: {count}'.format(count=value_count)) if value_count > 0: session.execute(insert(metadata_table).values( key='proxy_server', @@ -161,7 +161,7 @@ def upgrade_1(session, metadata): metadata_table.c.key == 'proxy username' ) ).scalar() - log.debug('proxy username: %s', value_count) + log.debug('proxy username: {count}'.format(count=value_count)) if value_count > 0: session.execute(insert(metadata_table).values( key='proxy_username', @@ -181,7 +181,7 @@ def upgrade_1(session, metadata): metadata_table.c.key == 'proxy password' ) ).scalar() - log.debug('proxy password: %s', value_count) + log.debug('proxy password: {count}'.format(count=value_count)) if value_count > 0: session.execute(insert(metadata_table).values( key='proxy_password', diff --git a/openlp/plugins/bibles/lib/versereferencelist.py b/openlp/plugins/bibles/lib/versereferencelist.py index a7f143b21..e46b8b357 100644 --- a/openlp/plugins/bibles/lib/versereferencelist.py +++ b/openlp/plugins/bibles/lib/versereferencelist.py @@ -61,23 +61,29 @@ class VerseReferenceList(object): result = '' for index, verse in enumerate(self.verse_list): if index == 0: - result = '%s %s%s%s' % (verse['book'], verse['chapter'], verse_sep, verse['start']) + result = '{book} {chapter}{sep}{verse}'.format(book=verse['book'], + chapter=verse['chapter'], + sep=verse_sep, + verse=verse['start']) if verse['start'] != verse['end']: - result = '%s%s%s' % (result, range_sep, verse['end']) + result = '{result}{sep}{end}'.format(result=result, sep=range_sep, end=verse['end']) continue prev = index - 1 if self.verse_list[prev]['version'] != verse['version']: - result = '%s (%s)' % (result, self.verse_list[prev]['version']) - result += '%s ' % list_sep + result = '{result} ({version})'.format(result=result, version=self.verse_list[prev]['version']) + result += '{sep} '.format(sep=list_sep) if self.verse_list[prev]['book'] != verse['book']: - result = '%s%s %s%s' % (result, verse['book'], verse['chapter'], verse_sep) + result = '{result}{book} {chapter}{sep}'.format(result=result, + book=verse['book'], + chapter=verse['chapter'], + sep=verse_sep) elif self.verse_list[prev]['chapter'] != verse['chapter']: - result = '%s%s%s' % (result, verse['chapter'], verse_sep) + result = '{result}{chapter}{sep}'.format(result=result, chapter=verse['chapter'], sep=verse_sep) result += str(verse['start']) if verse['start'] != verse['end']: - result = '%s%s%s' % (result, range_sep, verse['end']) + result = '{result}{sep}{end}'.format(result=result, sep=range_sep, end=verse['end']) if len(self.version_list) > 1: - result = '%s (%s)' % (result, verse['version']) + result = '{result} ({version})'.format(result=result, version=verse['version']) return result def format_versions(self, copyright=True, permission=True): diff --git a/openlp/plugins/bibles/lib/zefania.py b/openlp/plugins/bibles/lib/zefania.py index 9b44cdf26..0ea96a2a3 100644 --- a/openlp/plugins/bibles/lib/zefania.py +++ b/openlp/plugins/bibles/lib/zefania.py @@ -48,7 +48,7 @@ class ZefaniaBible(BibleDB): """ Loads a Bible from file. """ - log.debug('Starting Zefania import from "%s"' % self.filename) + log.debug('Starting Zefania import from "{name}"'.format(name=self.filename)) if not isinstance(self.filename, str): self.filename = str(self.filename, 'utf8') import_file = None @@ -67,7 +67,7 @@ class ZefaniaBible(BibleDB): if not language_id: language_id = self.get_language(bible_name) if not language_id: - log.error('Importing books from "%s" failed' % self.filename) + log.error('Importing books from "{name}" failed'.format(name=self.filename)) return False self.save_meta('language_id', language_id) num_books = int(zefania_bible_tree.xpath('count(//BIBLEBOOK)')) @@ -92,7 +92,7 @@ class ZefaniaBible(BibleDB): log.debug('Could not find a name, will use number, basically a guess.') book_ref_id = int(bnumber) if not book_ref_id: - log.error('Importing books from "%s" failed' % self.filename) + log.error('Importing books from "{name}" failed'.format(name=self.filename)) return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) db_book = self.create_book(book_details['name'], book_ref_id, book_details['testament_id']) @@ -104,8 +104,9 @@ class ZefaniaBible(BibleDB): verse_number = VERS.get("vnumber") self.create_verse(db_book.id, chapter_number, verse_number, VERS.text.replace('
', '\n')) self.wizard.increment_progress_bar( - translate('BiblesPlugin.Zefnia', 'Importing %(bookname)s %(chapter)s...') % - {'bookname': db_book.name, 'chapter': chapter_number}) + translate('BiblesPlugin.Zefnia', + 'Importing {book} {chapter}...').format(book=db_book.name, + chapter=chapter_number)) self.session.commit() self.application.process_events() except Exception as e: diff --git a/tests/functional/openlp_core_lib/test_projectordb.py b/tests/functional/openlp_core_lib/test_projectordb.py index a6ecb617d..7f3f927aa 100644 --- a/tests/functional/openlp_core_lib/test_projectordb.py +++ b/tests/functional/openlp_core_lib/test_projectordb.py @@ -29,6 +29,7 @@ import os from unittest import TestCase from openlp.core.lib.projector.db import Manufacturer, Model, Projector, ProjectorDB, ProjectorSource, Source +from openlp.core.lib.projector.constants import PJLINK_PORT from tests.functional import MagicMock, patch from tests.resources.projector.data import TEST_DB, TEST1_DATA, TEST2_DATA, TEST3_DATA @@ -195,7 +196,7 @@ class TestProjectorDB(TestCase): def manufacturer_repr_test(self): """ - Test manufacturer class __repr__ text + Test Manufacturer.__repr__ text """ # GIVEN: Test object manufacturer = Manufacturer() @@ -209,7 +210,7 @@ class TestProjectorDB(TestCase): def model_repr_test(self): """ - Test model class __repr__ text + Test Model.__repr__ text """ # GIVEN: Test object model = Model() @@ -223,7 +224,7 @@ class TestProjectorDB(TestCase): def source_repr_test(self): """ - Test source.__repr__ text + Test Source.__repr__ text """ # GIVEN: Test object source = Source() @@ -236,3 +237,31 @@ class TestProjectorDB(TestCase): # THEN: __repr__ should return a proper string self.assertEqual(str(source), '', 'Source.__repr__() should have returned a proper representation string') + + def projector_repr_test(self): + """ + Test Projector.__repr__() text + """ + # GIVEN: Test object + projector = Projector() + + # WHEN: projector() is populated + # NOTE: projector.pin, projector.other, projector.sources should all return None + # projector.source_list should return an empty list + projector.id = 0 + projector.ip = '127.0.0.1' + projector.port = PJLINK_PORT + projector.name = 'Test One' + projector.location = 'Somewhere over the rainbow' + projector.notes = 'Not again' + projector.pjlink_name = 'TEST' + projector.manufacturer = 'IN YOUR DREAMS' + projector.model = 'OpenLP' + + # THEN: __repr__ should return a proper string + self.assertEqual(str(projector), + '< Projector(id="0", ip="127.0.0.1", port="4352", pin="None", name="Test One", ' + 'location="Somewhere over the rainbow", notes="Not again", pjlink_name="TEST", ' + 'manufacturer="IN YOUR DREAMS", model="OpenLP", other="None", sources="None", ' + 'source_list="[]") >', + 'Projector.__repr__() should have returned a proper representation string') diff --git a/tests/functional/openlp_plugins/bibles/test_http.py b/tests/functional/openlp_plugins/bibles/test_http.py index 54289a163..56df57c3d 100644 --- a/tests/functional/openlp_plugins/bibles/test_http.py +++ b/tests/functional/openlp_plugins/bibles/test_http.py @@ -104,7 +104,7 @@ class TestBSExtract(TestCase): result = instance.get_books_from_http('NIV') # THEN: The rest mocks should be called with known values and get_books_from_http should return None - self.mock_log.debug.assert_called_once_with('BSExtract.get_books_from_http("%s")', 'NIV') + self.mock_log.debug.assert_called_once_with('BSExtract.get_books_from_http("{book}")'.format(book='NIV')) self.mock_urllib.parse.quote.assert_called_once_with(b'NIV') self.mock_get_soup_for_bible_ref.assert_called_once_with( 'http://m.bibleserver.com/overlay/selectBook?translation=NIV') @@ -132,7 +132,7 @@ class TestBSExtract(TestCase): result = instance.get_books_from_http('NIV') # THEN: The rest mocks should be called with known values and get_books_from_http should return None - self.mock_log.debug.assert_called_once_with('BSExtract.get_books_from_http("%s")', 'NIV') + self.mock_log.debug.assert_called_once_with('BSExtract.get_books_from_http("{book}")'.format(book='NIV')) self.mock_urllib.parse.quote.assert_called_once_with(b'NIV') self.mock_get_soup_for_bible_ref.assert_called_once_with( 'http://m.bibleserver.com/overlay/selectBook?translation=NIV') @@ -167,7 +167,7 @@ class TestBSExtract(TestCase): # THEN: The rest mocks should be called with known values and get_books_from_http should return the two books # in the test data - self.mock_log.debug.assert_called_once_with('BSExtract.get_books_from_http("%s")', 'NIV') + self.mock_log.debug.assert_called_once_with('BSExtract.get_books_from_http("{book}")'.format(book='NIV')) self.mock_urllib.parse.quote.assert_called_once_with(b'NIV') self.mock_get_soup_for_bible_ref.assert_called_once_with( 'http://m.bibleserver.com/overlay/selectBook?translation=NIV')