From 623b56742c291cec32263d8ea6b198f75dc4ebf7 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 7 Jul 2011 19:03:12 +0100 Subject: [PATCH 1/5] Cleanups --- openlp/core/lib/pluginmanager.py | 2 +- openlp/core/lib/spelltextedit.py | 2 +- openlp/core/lib/theme.py | 3 +-- openlp/core/ui/displaytagdialog.py | 2 +- openlp/core/ui/firsttimewizard.py | 6 +++--- openlp/core/ui/settingsform.py | 2 +- openlp/core/ui/slidecontroller.py | 4 ++-- openlp/plugins/alerts/alertsplugin.py | 2 +- openlp/plugins/bibles/forms/bibleimportform.py | 3 +-- openlp/plugins/bibles/forms/bibleupgradeform.py | 3 +-- openlp/plugins/bibles/lib/db.py | 2 +- openlp/plugins/bibles/lib/http.py | 4 +--- openlp/plugins/bibles/lib/manager.py | 2 +- openlp/plugins/songs/lib/db.py | 2 +- openlp/plugins/songs/lib/easislidesimport.py | 3 --- openlp/plugins/songs/lib/ewimport.py | 1 - openlp/plugins/songs/lib/songbeamerimport.py | 1 - openlp/plugins/songs/lib/songimport.py | 3 +-- openlp/plugins/songs/lib/wowimport.py | 1 - openlp/plugins/songusage/songusageplugin.py | 2 +- 20 files changed, 19 insertions(+), 31 deletions(-) diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 7a54b4c64..2248d0ddd 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -31,7 +31,7 @@ import os import sys import logging -from openlp.core.lib import Plugin, StringContent, PluginStatus +from openlp.core.lib import Plugin, PluginStatus log = logging.getLogger(__name__) diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py index 57a176a69..0d277b9fe 100644 --- a/openlp/core/lib/spelltextedit.py +++ b/openlp/core/lib/spelltextedit.py @@ -57,7 +57,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit): self.dictionary = enchant.Dict() self.highlighter = Highlighter(self.document()) self.highlighter.spellingDictionary = self.dictionary - except Error, DictNotFoundError: + except (Error, DictNotFoundError): ENCHANT_AVAILABLE = False log.debug(u'Could not load default dictionary') diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 7ad50490d..c87f9aa2e 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -34,8 +34,7 @@ import logging from xml.dom.minidom import Document from lxml import etree, objectify -from openlp.core.lib import str_to_bool, translate -from openlp.core.lib.ui import UiStrings +from openlp.core.lib import str_to_bool log = logging.getLogger(__name__) diff --git a/openlp/core/ui/displaytagdialog.py b/openlp/core/ui/displaytagdialog.py index 65e900bbb..328fcd137 100644 --- a/openlp/core/ui/displaytagdialog.py +++ b/openlp/core/ui/displaytagdialog.py @@ -28,7 +28,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import UiStrings, create_accept_reject_button_box +from openlp.core.lib.ui import UiStrings class Ui_DisplayTagDialog(object): diff --git a/openlp/core/ui/firsttimewizard.py b/openlp/core/ui/firsttimewizard.py index 3644ed07b..59fe41537 100644 --- a/openlp/core/ui/firsttimewizard.py +++ b/openlp/core/ui/firsttimewizard.py @@ -49,7 +49,7 @@ class Ui_FirstTimeWizard(object): FirstTimeWizard.resize(550, 386) FirstTimeWizard.setModal(True) FirstTimeWizard.setWizardStyle(QtGui.QWizard.ModernStyle) - FirstTimeWizard.setOptions(QtGui.QWizard.IndependentPages| + FirstTimeWizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage | QtGui.QWizard.NoBackButtonOnLastPage) self.finishButton = self.button(QtGui.QWizard.FinishButton) @@ -81,9 +81,9 @@ class Ui_FirstTimeWizard(object): self.pluginLayout.addWidget(self.imageCheckBox) self.presentationCheckBox = QtGui.QCheckBox(self.pluginPage) if sys.platform == "darwin": - self.presentationCheckBox.setChecked(False) + self.presentationCheckBox.setChecked(False) else: - self.presentationCheckBox.setChecked(True) + self.presentationCheckBox.setChecked(True) self.presentationCheckBox.setObjectName(u'presentationCheckBox') self.pluginLayout.addWidget(self.presentationCheckBox) self.mediaCheckBox = QtGui.QCheckBox(self.pluginPage) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 711cac7c2..49d27a466 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -29,7 +29,7 @@ The :mod:`settingsform` provides a user interface for the OpenLP settings """ import logging -from PyQt4 import QtGui, QtCore +from PyQt4 import QtGui from openlp.core.lib import Receiver, build_icon, PluginStatus from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 8e2c199a1..03a35b1fb 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -31,8 +31,8 @@ import os from PyQt4 import QtCore, QtGui from PyQt4.phonon import Phonon -from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \ - ItemCapabilities, translate +from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, \ + translate from openlp.core.lib.ui import UiStrings, shortcut_action from openlp.core.ui import HideMode, MainDisplay, ScreenList from openlp.core.utils.actions import ActionList, CategoryOrder diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 41c2e2211..19d5107f2 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -27,7 +27,7 @@ import logging -from PyQt4 import QtCore, QtGui +from PyQt4 import QtCore from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.lib.db import Manager diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index de1574eaa..b5478e514 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -27,7 +27,6 @@ """ The bible import functions for OpenLP """ -import csv import logging import os import os.path @@ -39,7 +38,7 @@ from openlp.core.lib import Receiver, translate from openlp.core.lib.db import delete_database from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings -from openlp.core.utils import AppLocation, string_is_unicode +from openlp.core.utils import AppLocation from openlp.plugins.bibles.lib.manager import BibleFormat from openlp.plugins.bibles.lib.db import BiblesResourcesDB, clean_filename diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 14936a340..d396bce8d 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -28,7 +28,6 @@ The bible import functions for OpenLP """ import logging import os.path -import re import shutil from PyQt4 import QtCore, QtGui @@ -39,7 +38,7 @@ from openlp.core.lib.db import delete_database from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.utils import AppLocation, delete_file -from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, OldBibleDB,\ +from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, OldBibleDB, \ BiblesResourcesDB, clean_filename from openlp.plugins.bibles.lib.http import BSExtract, BGExtract, CWExtract diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 68f105dff..5273f670c 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -36,7 +36,7 @@ from sqlalchemy import Column, ForeignKey, or_, Table, types from sqlalchemy.orm import class_mapper, mapper, relation from sqlalchemy.orm.exc import UnmappedClassError -from openlp.core.lib import Receiver, translate, check_directory_exists +from openlp.core.lib import Receiver, translate from openlp.core.lib.db import BaseModel, init_db, Manager from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 03b094e82..8a46b75c4 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -29,9 +29,7 @@ The :mod:`http` module enables OpenLP to retrieve scripture from bible websites. """ import logging -import os import re -import sqlite3 import socket import urllib from HTMLParser import HTMLParseError @@ -40,7 +38,7 @@ from BeautifulSoup import BeautifulSoup, NavigableString, Tag from openlp.core.lib import Receiver, translate from openlp.core.lib.ui import critical_error_message_box -from openlp.core.utils import AppLocation, get_web_page +from openlp.core.utils import get_web_page from openlp.plugins.bibles.lib import SearchResults from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB, \ Book diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 9a0b20820..354332083 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -34,7 +34,7 @@ from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, delete_file from openlp.plugins.bibles.lib import parse_reference -from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, OldBibleDB +from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta from csvbible import CSVBible from http import HTTPBible from opensong import OpenSongBible diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index 93d56a05a..c5c019c3c 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -29,7 +29,7 @@ The :mod:`db` module provides the database and schema that is the backend for the Songs plugin """ -from sqlalchemy import Column, ForeignKey, Index, Table, types +from sqlalchemy import Column, ForeignKey, Table, types from sqlalchemy.orm import mapper, relation from openlp.core.lib.db import BaseModel, init_db diff --git a/openlp/plugins/songs/lib/easislidesimport.py b/openlp/plugins/songs/lib/easislidesimport.py index b1eaceeaf..b24287130 100644 --- a/openlp/plugins/songs/lib/easislidesimport.py +++ b/openlp/plugins/songs/lib/easislidesimport.py @@ -26,13 +26,10 @@ ############################################################################### import logging -import os import re from lxml import etree, objectify -from openlp.core.lib import translate -from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import VerseType from openlp.plugins.songs.lib.songimport import SongImport diff --git a/openlp/plugins/songs/lib/ewimport.py b/openlp/plugins/songs/lib/ewimport.py index 09f84fbe2..251068fb4 100644 --- a/openlp/plugins/songs/lib/ewimport.py +++ b/openlp/plugins/songs/lib/ewimport.py @@ -33,7 +33,6 @@ import os import struct from openlp.core.lib import translate -from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import VerseType from openlp.plugins.songs.lib import retrieve_windows_encoding from songimport import SongImport diff --git a/openlp/plugins/songs/lib/songbeamerimport.py b/openlp/plugins/songs/lib/songbeamerimport.py index 3a8d63783..400db8f9a 100644 --- a/openlp/plugins/songs/lib/songbeamerimport.py +++ b/openlp/plugins/songs/lib/songbeamerimport.py @@ -36,7 +36,6 @@ import re from openlp.plugins.songs.lib import VerseType from openlp.plugins.songs.lib.songimport import SongImport -from openlp.plugins.songs.lib.ui import SongStrings log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 781321fe4..dc45764e4 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -29,9 +29,8 @@ import re from PyQt4 import QtCore -from openlp.core.lib import Receiver, translate, check_directory_exists +from openlp.core.lib import Receiver, translate from openlp.core.ui.wizard import WizardStrings -from openlp.core.utils import AppLocation from openlp.plugins.songs.lib import clean_song, VerseType from openlp.plugins.songs.lib.db import Song, Author, Topic, Book, MediaFile from openlp.plugins.songs.lib.ui import SongStrings diff --git a/openlp/plugins/songs/lib/wowimport.py b/openlp/plugins/songs/lib/wowimport.py index 0648abe66..e2a5820a5 100644 --- a/openlp/plugins/songs/lib/wowimport.py +++ b/openlp/plugins/songs/lib/wowimport.py @@ -31,7 +31,6 @@ Worship songs into the OpenLP database. import os import logging -from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib.songimport import SongImport BLOCK_TYPES = (u'V', u'C', u'B') diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 7304b5196..c94b70554 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, StringContent, Receiver, build_icon, \ translate from openlp.core.lib.db import Manager -from openlp.core.lib.ui import base_action, shortcut_action, UiStrings +from openlp.core.lib.ui import base_action, shortcut_action from openlp.core.utils.actions import ActionList from openlp.plugins.songusage.forms import SongUsageDetailForm, \ SongUsageDeleteForm From 1899961965967246797083071f1da707099e6d18 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 7 Jul 2011 22:22:41 +0100 Subject: [PATCH 2/5] Long lines --- openlp/core/ui/mainwindow.py | 6 +++--- openlp/core/ui/shortcutlistform.py | 6 ++++-- openlp/plugins/bibles/lib/mediaitem.py | 3 ++- openlp/plugins/remotes/lib/httpserver.py | 3 ++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index e850ef335..b182452bc 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -291,9 +291,9 @@ class Ui_MainWindow(object): self.onHelpLocalHelpClicked, u':/system/system_about.png', category=UiStrings().Help) self.helpOnlineHelpItem = shortcut_action( - mainWindow, u'helpOnlineHelpItem', [QtGui.QKeySequence(u'Alt+F1')], - self.onHelpOnlineHelpClicked, u':/system/system_online_help.png', - category=UiStrings().Help) + mainWindow, u'helpOnlineHelpItem', + [QtGui.QKeySequence(u'Alt+F1')], self.onHelpOnlineHelpClicked, + u':/system/system_online_help.png', category=UiStrings().Help) else: self.helpOnlineHelpItem = shortcut_action( mainWindow, u'helpOnlineHelpItem', [QtGui.QKeySequence(u'F1')], diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 6bdcc46bc..1eccddc95 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -247,7 +247,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): alternate_label_text = action.defaultShortcuts[1].toString() shortcuts = self._actionShortcuts(action) # We do not want to loose pending changes, that is why we have to - # keep the text when, this function has not been triggered by a signal. + # keep the text when, this function has not been triggered by a + # signal. if item is None: primary_text = self.primaryPushButton.text() alternate_text = self.alternatePushButton.text() @@ -280,7 +281,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ Restores all default shortcuts. """ - if self.buttonBox.buttonRole(button) != QtGui.QDialogButtonBox.ResetRole: + if self.buttonBox.buttonRole(button) != \ + QtGui.QDialogButtonBox.ResetRole: return if QtGui.QMessageBox.question(self, translate('OpenLP.ShortcutListDialog', 'Restore Default Shortcuts'), diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index cb8273327..1c731ec6e 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -983,7 +983,8 @@ class BibleMediaItem(MediaManagerItem): Search for some Bible verses (by reference). """ bible = unicode(self.quickVersionComboBox.currentText()) - search_results = self.plugin.manager.get_verses(bible, string, False, False) + search_results = self.plugin.manager.get_verses( + bible, string, False, False) if search_results: versetext = u' '.join([verse.text for verse in search_results]) return [[string, versetext]] diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 34271019d..836b3d0ae 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -357,7 +357,8 @@ class HttpConnection(object): if ext == u'.html': mimetype = u'text/html' variables = self.template_vars - html = Template(filename=path, input_encoding=u'utf-8', output_encoding=u'utf-8').render(**variables) + html = Template(filename=path, input_encoding=u'utf-8', + output_encoding=u'utf-8').render(**variables) elif ext == u'.css': mimetype = u'text/css' elif ext == u'.js': From 42acff98abd19c13b40dbc90f60f712fabedb267 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 13 Jul 2011 22:00:35 +0100 Subject: [PATCH 3/5] Unused import --- openlp/core/lib/serviceitem.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 1245988b4..2aa1efbc2 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -36,7 +36,6 @@ import os import uuid from openlp.core.lib import build_icon, clean_tags, expand_tags, translate -from openlp.core.lib.ui import UiStrings log = logging.getLogger(__name__) From 0f89b9f771fa3210353b28512e98ff3b6124c372 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 17 Jul 2011 13:59:26 +0100 Subject: [PATCH 4/5] Unused import --- openlp/plugins/songs/lib/opensongimport.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/songs/lib/opensongimport.py b/openlp/plugins/songs/lib/opensongimport.py index 834255fd0..7fca88262 100644 --- a/openlp/plugins/songs/lib/opensongimport.py +++ b/openlp/plugins/songs/lib/opensongimport.py @@ -26,7 +26,6 @@ ############################################################################### import logging -import os import re from lxml import objectify From 4ae1a12b59305ed8e31296631b82462380e0f93b Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 17 Jul 2011 16:09:30 +0100 Subject: [PATCH 5/5] Unused function: string_is_unicode --- openlp/core/utils/__init__.py | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 081870587..b0a28962c 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -459,25 +459,6 @@ def file_is_unicode(filename): return None return ucsfile -def string_is_unicode(test_string): - """ - Makes sure a string is unicode. - - ``test_string`` - The string to confirm is unicode. - """ - return_string = u'' - if not test_string: - return return_string - if isinstance(test_string, unicode): - return_string = test_string - if not isinstance(test_string, unicode): - try: - return_string = unicode(test_string, u'utf-8') - except UnicodeError: - log.exception("Error encoding string to unicode") - return return_string - def get_uno_command(): """ Returns the UNO command to launch an openoffice.org instance. @@ -510,5 +491,5 @@ from actions import ActionList __all__ = [u'AppLocation', u'get_application_version', u'check_latest_version', u'add_actions', u'get_filesystem_encoding', u'LanguageManager', - u'ActionList', u'get_web_page', u'file_is_unicode', u'string_is_unicode', - u'get_uno_command', u'get_uno_instance', u'delete_file'] + u'ActionList', u'get_web_page', u'file_is_unicode', u'get_uno_command', + u'get_uno_instance', u'delete_file']