From 2f840944e9b3a3a7b8361799723a63084ddb1beb Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 21 Mar 2010 15:55:45 +0000 Subject: [PATCH 1/6] Unused variable fixes --- openlp/plugins/songs/forms/editsongform.py | 2 -- openlp/plugins/songs/lib/mediaitem.py | 2 +- scripts/bible-1to2-converter.py | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 183af6a44..fedd18759 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -498,7 +498,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): sxml = SongXMLBuilder() sxml.new_document() sxml.add_lyrics_to_song() - count = 1 text = u' ' for i in range (0, self.VerseListWidget.count()): item = self.VerseListWidget.item(i) @@ -506,7 +505,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): bits = verseId.split(u':') sxml.add_verse_to_lyrics(bits[0], bits[1], unicode(item.text())) text = text + unicode(self.VerseListWidget.item(i).text()) + u' ' - count += 1 text = text.replace(u'\'', u'') text = text.replace(u',', u'') text = text.replace(u';', u'') diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index cd440e54f..5090b845c 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -282,7 +282,7 @@ class SongMediaItem(MediaManagerItem): raw_footer = [] author_list = u'' author_audit = [] - ccl = u'' + ccli = u'' if self.remoteTriggered is None: item = self.ListView.currentItem() if item is None: diff --git a/scripts/bible-1to2-converter.py b/scripts/bible-1to2-converter.py index b1e9b6897..19d8ec9e8 100755 --- a/scripts/bible-1to2-converter.py +++ b/scripts/bible-1to2-converter.py @@ -206,7 +206,6 @@ def import_bible(): rows = old_cursor.fetchall() if debug or verbose: print 'done.' - song_map = {} for row in rows: book_id = int(row[1]) chapter = int(row[2]) From c4b49a15116a6c33aa4949b8d0e8d42e59978a19 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 23 Mar 2010 16:00:52 +0000 Subject: [PATCH 2/6] Import fixes --- openlp/migration/migratebibles.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openlp/migration/migratebibles.py b/openlp/migration/migratebibles.py index b73b016cf..c0d47fdb8 100644 --- a/openlp/migration/migratebibles.py +++ b/openlp/migration/migratebibles.py @@ -27,9 +27,9 @@ import os import sys import sqlite3 -from sqlalchemy import * +from sqlalchemy import * from sqlalchemy import create_engine -from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation +from sqlalchemy.orm import scoped_session, sessionmaker, mapper from openlp.core.lib import PluginConfig from openlp.plugins.bibles.lib.models import * @@ -223,4 +223,3 @@ class MigrateBibles(): conn.commit() conn.execute(u'vacuum;') conn.commit() - From 6578fb529e46d9baf166677fe672ebb02fff6751 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 23 Mar 2010 21:51:20 +0000 Subject: [PATCH 3/6] Test tweaks and remove unused variables --- openlp/plugins/presentations/lib/impresscontroller.py | 5 ++--- openlp/plugins/presentations/lib/powerpointcontroller.py | 5 ++--- openlp/plugins/presentations/lib/pptviewcontroller.py | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 637e629c0..14e98273e 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -147,9 +147,8 @@ class ImpressController(PresentationController): Called at system exit to clean up any running presentations """ log.debug(u'Kill OpenOffice') - for i in range(len(self.docs)): - self.docs[0].close_presentation() # Yes, always the zeroth one - # as close removes item from array + while self.docs: + self.docs[0].close_presentation() if os.name != u'nt': desktop = self.get_uno_desktop() else: diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index 3dedcec75..67870574d 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -82,9 +82,8 @@ class PowerpointController(PresentationController): Called at system exit to clean up any running presentations """ log.debug(u'Kill powerpoint') - for i in range(len(self.docs)): - self.docs[0].close_presentation() # Yes, always the zeroth one - # as close removes item from array + while self.docs: + self.docs[0].close_presentation() if self.process is None: return if self.process.Presentations.Count > 0: diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index 5646c7258..455e1c601 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -89,9 +89,8 @@ class PptviewController(PresentationController): Called at system exit to clean up any running presentations """ log.debug(u'Kill pptviewer') - for i in range(len(self.docs)): - self.docs[0].close_presentation() # Yes, always the zeroth one - # as close removes item from array + while self.docs: + self.docs[0].close_presentation() def add_doc(self, name): log.debug(u'Add Doc PPTView') From a091c8f3b665a313ea6128ab2d9401366a7901cb Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 24 Mar 2010 19:15:25 +0000 Subject: [PATCH 4/6] Fix Quick bible enter --- openlp/plugins/bibles/lib/mediaitem.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 9b286eb1a..3bcc0b426 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -253,6 +253,8 @@ class BibleMediaItem(MediaManagerItem): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configUpdated) # Other stuff + QtCore.QObject.connect(self.QuickSearchEdit, + QtCore.SIGNAL(u'returnPressed()'), self.onQuickSearchButton) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'bible_showprogress'), self.onSearchProgressShow) QtCore.QObject.connect(Receiver.get_receiver(), From 2eaadffea0034fc4bba0e81e3c481b4a2f335653 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 24 Mar 2010 23:00:43 +0200 Subject: [PATCH 5/6] Fixed two bugs in the web downloads import dealing with non-latin characters. --- .../plugins/bibles/forms/importwizardform.py | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py index 2efbcdf1e..22fea28f4 100644 --- a/openlp/plugins/bibles/forms/importwizardform.py +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -37,7 +37,7 @@ from openlp.plugins.bibles.lib.manager import BibleFormat log = logging.getLogger(__name__) -class DownloadLocation(object): +class WebDownload(object): Unknown = -1 Crosswalk = 0 BibleGateway = 1 @@ -282,7 +282,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): self.setField(u'csv_booksfile', QtCore.QVariant('')) self.setField(u'csv_versefile', QtCore.QVariant('')) self.setField(u'opensong_file', QtCore.QVariant('')) - self.setField(u'web_location', QtCore.QVariant(DownloadLocation.Crosswalk)) + self.setField(u'web_location', QtCore.QVariant(WebDownload.Crosswalk)) self.setField(u'web_biblename', QtCore.QVariant(self.BibleComboBox)) self.setField(u'proxy_server', QtCore.QVariant(self.config.get_config(u'proxy address', ''))) @@ -293,7 +293,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): self.setField(u'license_version', QtCore.QVariant(self.VersionNameEdit)) self.setField(u'license_copyright', QtCore.QVariant(self.CopyrightEdit)) self.setField(u'license_permission', QtCore.QVariant(self.PermissionEdit)) - self.onLocationComboBoxChanged(DownloadLocation.Crosswalk) + self.onLocationComboBoxChanged(WebDownload.Crosswalk) def loadWebBibles(self): """ @@ -304,13 +304,13 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): filepath = os.path.join(filepath, u'bibles', u'resources') fbibles = None try: - self.web_bible_list[DownloadLocation.Crosswalk] = {} + self.web_bible_list[WebDownload.Crosswalk] = {} books_file = open(os.path.join(filepath, u'crosswalkbooks.csv'), 'r') dialect = csv.Sniffer().sniff(books_file.read(1024)) books_file.seek(0) books_reader = csv.reader(books_file, dialect) for line in books_reader: - self.web_bible_list[DownloadLocation.Crosswalk][line[0]] = \ + self.web_bible_list[WebDownload.Crosswalk][line[0]] = \ unicode(line[1], u'utf8').strip() except: log.exception(u'Crosswalk resources missing') @@ -319,14 +319,19 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): books_file.close() #Load and store BibleGateway Bibles try: - self.web_bible_list[DownloadLocation.BibleGateway] = {} + self.web_bible_list[WebDownload.BibleGateway] = {} books_file = open(os.path.join(filepath, u'biblegateway.csv'), 'r') dialect = csv.Sniffer().sniff(books_file.read(1024)) books_file.seek(0) books_reader = csv.reader(books_file, dialect) for line in books_reader: - self.web_bible_list[DownloadLocation.BibleGateway][line[0]] = \ - unicode(line[1], u'utf-8').strip() + ver = line[0] + name = line[1] + if not isinstance(ver, unicode): + ver = unicode(ver, u'utf8') + if not isinstance(name, unicode): + name = unicode(name, u'utf8') + self.web_bible_list[WebDownload.BibleGateway][ver] = name.strip() except: log.exception(u'Biblegateway resources missing') finally: @@ -383,16 +388,17 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): # Import a bible from the web self.ImportProgressBar.setMaximum(1) download_location = self.field(u'web_location').toInt()[0] - if download_location == DownloadLocation.Crosswalk: - bible = self.web_bible_list[DownloadLocation.Crosswalk][ - unicode(self.BibleComboBox.currentText(), u'utf8')] - elif download_location == DownloadLocation.BibleGateway: - bible = self.web_bible_list[DownloadLocation.BibleGateway][ - unicode(self.BibleComboBox.currentText(), u'utf8')] + bible_version = self.BibleComboBox.currentText() + if not isinstance(bible_version, unicode): + bible_version = unicode(bible_version, u'utf8') + if download_location == WebDownload.Crosswalk: + bible = self.web_bible_list[WebDownload.Crosswalk][bible_version] + elif download_location == WebDownload.BibleGateway: + bible = self.web_bible_list[WebDownload.BibleGateway][bible_version] importer = self.manager.import_bible( BibleFormat.WebDownload, name=license_version, - download_source=DownloadLocation.get_name(download_location), + download_source=WebDownload.get_name(download_location), download_name=bible, proxy_server=variant_to_unicode(self.field(u'proxy_server')), proxy_username=variant_to_unicode(self.field(u'proxy_username')), From 0b596dab473b72914753ed4ef2c9788115531121 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 24 Mar 2010 23:18:36 +0200 Subject: [PATCH 6/6] Fixed another possible bug. --- openlp/plugins/bibles/forms/importwizardform.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py index 22fea28f4..a717a4f44 100644 --- a/openlp/plugins/bibles/forms/importwizardform.py +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -310,8 +310,13 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): books_file.seek(0) books_reader = csv.reader(books_file, dialect) for line in books_reader: - self.web_bible_list[WebDownload.Crosswalk][line[0]] = \ - unicode(line[1], u'utf8').strip() + ver = line[0] + name = line[1] + if not isinstance(ver, unicode): + ver = unicode(ver, u'utf8') + if not isinstance(name, unicode): + name = unicode(name, u'utf8') + self.web_bible_list[WebDownload.Crosswalk][ver] = name.strip() except: log.exception(u'Crosswalk resources missing') finally: