Moved code base to python3

bzr-revno: 2290
This commit is contained in:
Andreas Preikschat 2013-08-31 20:16:33 +02:00
commit f8299ec309
114 changed files with 290 additions and 316 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
@ -27,15 +27,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
import sip
import sys import sys
sip.setapi(u'QDate', 2)
sip.setapi(u'QDateTime', 2)
sip.setapi(u'QString', 2)
sip.setapi(u'QTextStream', 2)
sip.setapi(u'QTime', 2)
sip.setapi(u'QUrl', 2)
sip.setapi(u'QVariant', 2)
from openlp.core import main from openlp.core import main

View File

@ -30,7 +30,7 @@
The :mod:`openlp` module contains all the project produced OpenLP functionality The :mod:`openlp` module contains all the project produced OpenLP functionality
""" """
import core import openlp.core
import plugins import openlp.plugins
__all__ = [u'core', u'plugins'] __all__ = [u'core', u'plugins']

View File

@ -121,20 +121,19 @@ def get_text_file_string(text_file):
if not os.path.isfile(text_file): if not os.path.isfile(text_file):
return False return False
file_handle = None file_handle = None
content_string = None content = None
try: try:
file_handle = open(text_file, u'r') file_handle = open(text_file, u'r')
if not file_handle.read(3) == '\xEF\xBB\xBF': if not file_handle.read(3) == '\xEF\xBB\xBF':
# no BOM was found # no BOM was found
file_handle.seek(0) file_handle.seek(0)
content = file_handle.read() content = file_handle.read()
content_string = content.decode(u'utf-8')
except (IOError, UnicodeError): except (IOError, UnicodeError):
log.exception(u'Failed to open text file %s' % text_file) log.exception(u'Failed to open text file %s' % text_file)
finally: finally:
if file_handle: if file_handle:
file_handle.close() file_handle.close()
return content_string return content
def str_to_bool(string_value): def str_to_bool(string_value):
@ -186,7 +185,7 @@ def image_to_byte(image):
image.save(buffie, "PNG") image.save(buffie, "PNG")
log.debug(u'image_to_byte - end') log.debug(u'image_to_byte - end')
# convert to base64 encoding so does not get missed! # convert to base64 encoding so does not get missed!
return byte_array.toBase64() return bytes(byte_array.toBase64()).decode('utf-8')
def create_thumb(image_path, thumb_path, return_icon=True, size=None): def create_thumb(image_path, thumb_path, return_icon=True, size=None):

View File

@ -49,7 +49,7 @@ class OpenLPDockWidget(QtGui.QDockWidget):
Initialise the DockWidget Initialise the DockWidget
""" """
log.debug(u'Initialise the %s widget' % name) log.debug(u'Initialise the %s widget' % name)
QtGui.QDockWidget.__init__(self, parent) super(OpenLPDockWidget, self).__init__(parent)
if name: if name:
self.setObjectName(name) self.setObjectName(name)
if icon: if icon:

View File

@ -62,9 +62,6 @@ class FormattingTags(object):
# Remove key 'temporary' from tags. It is not needed to be saved. # Remove key 'temporary' from tags. It is not needed to be saved.
if u'temporary' in tag: if u'temporary' in tag:
del tag[u'temporary'] del tag[u'temporary']
for element in tag:
if isinstance(tag[element], unicode):
tag[element] = tag[element].encode('utf8')
# Formatting Tags were also known as display tags. # Formatting Tags were also known as display tags.
Settings().setValue(u'formattingTags/html_tags', json.dumps(tags) if tags else u'') Settings().setValue(u'formattingTags/html_tags', json.dumps(tags) if tags else u'')
@ -156,15 +153,10 @@ class FormattingTags(object):
u'end html': u'', u'protected': True, u'temporary': False}) u'end html': u'', u'protected': True, u'temporary': False})
FormattingTags.add_html_tags(base_tags) FormattingTags.add_html_tags(base_tags)
FormattingTags.add_html_tags(temporary_tags) FormattingTags.add_html_tags(temporary_tags)
# Formatting Tags were also known as display tags.
user_expands_string = str(Settings().value(u'formattingTags/html_tags')) user_expands_string = str(Settings().value(u'formattingTags/html_tags'))
# If we have some user ones added them as well
if user_expands_string: if user_expands_string:
user_tags = json.loads(user_expands_string) user_tags = json.loads(user_expands_string)
for tag in user_tags:
for element in tag:
if isinstance(tag[element], str):
tag[element] = tag[element].decode('utf8')
# If we have some user ones added them as well
FormattingTags.add_html_tags(user_tags) FormattingTags.add_html_tags(user_tags)
@staticmethod @staticmethod

View File

@ -56,7 +56,7 @@ class ImageThread(QtCore.QThread):
``manager`` ``manager``
The image manager. The image manager.
""" """
QtCore.QThread.__init__(self, None) super(ImageThread, self).__init__(None)
self.image_manager = manager self.image_manager = manager
def run(self): def run(self):
@ -183,7 +183,7 @@ class ImageManager(QtCore.QObject):
""" """
Constructor for the image manager. Constructor for the image manager.
""" """
QtCore.QObject.__init__(self) super(ImageManager, self).__init__()
Registry().register(u'image_manager', self) Registry().register(u'image_manager', self)
current_screen = ScreenList().current current_screen = ScreenList().current
self.width = current_screen[u'size'].width() self.width = current_screen[u'size'].width()

View File

@ -44,7 +44,7 @@ class ListWidgetWithDnD(QtGui.QListWidget):
""" """
Initialise the list widget Initialise the list widget
""" """
QtGui.QListWidget.__init__(self, parent) super(ListWidgetWithDnD, self).__init__(parent)
self.mimeDataText = name self.mimeDataText = name
assert(self.mimeDataText) assert(self.mimeDataText)

View File

@ -82,7 +82,7 @@ class MediaManagerItem(QtGui.QWidget):
""" """
Constructor to create the media manager item. Constructor to create the media manager item.
""" """
QtGui.QWidget.__init__(self) super(MediaManagerItem, self).__init__()
self.hide() self.hide()
self.whitespace = re.compile(r'[\W_]+', re.UNICODE) self.whitespace = re.compile(r'[\W_]+', re.UNICODE)
self.plugin = plugin self.plugin = plugin

View File

@ -128,7 +128,7 @@ class Plugin(QtCore.QObject):
class MyPlugin(Plugin): class MyPlugin(Plugin):
def __init__(self): def __init__(self):
Plugin.__init__(self, u'MyPlugin', version=u'0.1') super(MyPlugin, self).__init__('MyPlugin', version=u'0.1')
``name`` ``name``
Defaults to *None*. The name of the plugin. Defaults to *None*. The name of the plugin.
@ -146,7 +146,7 @@ class Plugin(QtCore.QObject):
Defaults to *None*, which means that the same version number is used as OpenLP's version number. Defaults to *None*, which means that the same version number is used as OpenLP's version number.
""" """
log.debug(u'Plugin %s initialised' % name) log.debug(u'Plugin %s initialised' % name)
QtCore.QObject.__init__(self) super(Plugin, self).__init__()
self.name = name self.name = name
self.text_strings = {} self.text_strings = {}
self.set_plugin_text_strings() self.set_plugin_text_strings()

View File

@ -46,7 +46,7 @@ class SearchEdit(QtGui.QLineEdit):
""" """
Constructor. Constructor.
""" """
QtGui.QLineEdit.__init__(self, parent) super(SearchEdit, self).__init__(parent)
self._current_search_type = -1 self._current_search_type = -1
self.clear_button = QtGui.QToolButton(self) self.clear_button = QtGui.QToolButton(self)
self.clear_button.setIcon(build_icon(u':/system/clear_shortcut.png')) self.clear_button.setIcon(build_icon(u':/system/clear_shortcut.png'))

View File

@ -52,7 +52,7 @@ class SettingsTab(QtGui.QWidget):
``visible_title`` ``visible_title``
The title of the tab, which is usually displayed on the tab. The title of the tab, which is usually displayed on the tab.
""" """
QtGui.QWidget.__init__(self, parent) super(SettingsTab, self).__init__(parent)
self.tab_title = title self.tab_title = title
self.tab_title_visible = visible_title self.tab_title_visible = visible_title
self.settings_section = self.tab_title.lower() self.settings_section = self.tab_title.lower()

View File

@ -60,7 +60,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
Constructor. Constructor.
""" """
global ENCHANT_AVAILABLE global ENCHANT_AVAILABLE
QtGui.QPlainTextEdit.__init__(self, parent) super(SpellTextEdit, self).__init__(parent)
self.formatting_tags_allowed = formatting_tags_allowed self.formatting_tags_allowed = formatting_tags_allowed
# Default dictionary based on the current locale. # Default dictionary based on the current locale.
if ENCHANT_AVAILABLE: if ENCHANT_AVAILABLE:
@ -177,7 +177,7 @@ class Highlighter(QtGui.QSyntaxHighlighter):
""" """
Constructor Constructor
""" """
QtGui.QSyntaxHighlighter.__init__(self, *args) super(Highlighter, self).__init__(*args)
self.spelling_dictionary = None self.spelling_dictionary = None
def highlightBlock(self, text): def highlightBlock(self, text):
@ -205,5 +205,5 @@ class SpellAction(QtGui.QAction):
""" """
Constructor Constructor
""" """
QtGui.QAction.__init__(self, *args) super(SpellAction, self).__init__(*args)
self.triggered.connect(lambda x: self.correct.emit(self.text())) self.triggered.connect(lambda x: self.correct.emit(self.text()))

View File

@ -473,7 +473,7 @@ class ThemeXML(object):
Pull out the XML string formatted for human consumption Pull out the XML string formatted for human consumption
""" """
self._build_xml_from_attrs() self._build_xml_from_attrs()
return self.theme_xml.toprettyxml(indent=u' ', newl=u'\n', encoding=u'utf-8') return self.theme_xml.toprettyxml(indent=' ', newl='\n', encoding='utf-8')
def parse(self, xml): def parse(self, xml):
""" """

View File

@ -47,7 +47,7 @@ class OpenLPToolbar(QtGui.QToolBar):
""" """
Initialise the toolbar. Initialise the toolbar.
""" """
QtGui.QToolBar.__init__(self, parent) super(OpenLPToolbar, self).__init__(parent)
# useful to be able to reuse button icons... # useful to be able to reuse button icons...
self.setIconSize(QtCore.QSize(20, 20)) self.setIconSize(QtCore.QSize(20, 20))
self.actions = {} self.actions = {}

View File

@ -44,7 +44,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget):
""" """
Initialise the tree widget Initialise the tree widget
""" """
QtGui.QTreeWidget.__init__(self, parent) super(TreeWidgetWithDnD, self).__init__(parent)
self.mimeDataText = name self.mimeDataText = name
self.allow_internal_dnd = False self.allow_internal_dnd = False
self.header().close() self.header().close()

View File

@ -46,7 +46,7 @@ class AboutForm(QtGui.QDialog, Ui_AboutDialog):
""" """
Do some initialisation stuff Do some initialisation stuff
""" """
QtGui.QDialog.__init__(self, parent) super(AboutForm, self).__init__(parent)
application_version = get_application_version() application_version = get_application_version()
self.setupUi(self) self.setupUi(self)
about_text = self.about_text_edit.toPlainText() about_text = self.about_text_edit.toPlainText()

View File

@ -57,14 +57,14 @@ class AdvancedTab(SettingsTab):
self.data_exists = False self.data_exists = False
self.icon_path = u':/system/system_settings.png' self.icon_path = u':/system/system_settings.png'
advanced_translated = translate('OpenLP.AdvancedTab', 'Advanced') advanced_translated = translate('OpenLP.AdvancedTab', 'Advanced')
SettingsTab.__init__(self, parent, u'Advanced', advanced_translated) super(AdvancedTab, self).__init__(parent, u'Advanced', advanced_translated)
def setupUi(self): def setupUi(self):
""" """
Configure the UI elements for the tab. Configure the UI elements for the tab.
""" """
self.setObjectName(u'AdvancedTab') self.setObjectName(u'AdvancedTab')
SettingsTab.setupUi(self) super(AdvancedTab, self).setupUi()
self.ui_group_box = QtGui.QGroupBox(self.left_column) self.ui_group_box = QtGui.QGroupBox(self.left_column)
self.ui_group_box.setObjectName(u'ui_group_box') self.ui_group_box.setObjectName(u'ui_group_box')
self.ui_layout = QtGui.QFormLayout(self.ui_group_box) self.ui_layout = QtGui.QFormLayout(self.ui_group_box)

View File

@ -107,7 +107,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
""" """
Constructor. Constructor.
""" """
QtGui.QDialog.__init__(self, self.main_window) super(ExceptionForm, self).__init__(self.main_window)
self.setupUi(self) self.setupUi(self)
self.settings_section = u'crashreport' self.settings_section = u'crashreport'
@ -276,4 +276,4 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
self._main_window = Registry().get(u'main_window') self._main_window = Registry().get(u'main_window')
return self._main_window return self._main_window
main_window = property(_get_main_window) main_window = property(_get_main_window)

View File

@ -45,7 +45,7 @@ class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, self.main_window) super(FileRenameForm, self).__init__(Registry().get(u'main_window'))
self.setupUi(self) self.setupUi(self)
def exec_(self, copy=False): def exec_(self, copy=False):

View File

@ -29,20 +29,20 @@
""" """
This module contains the first time wizard. This module contains the first time wizard.
""" """
import io
import logging import logging
import os import os
import sys import sys
import time import time
import urllib import urllib.request
import urllib2 import urllib.parse
import urllib.error
from tempfile import gettempdir from tempfile import gettempdir
from ConfigParser import SafeConfigParser from ConfigParser import SafeConfigParser
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import PluginStatus, Settings, Registry, build_icon, check_directory_exists, translate from openlp.core.lib import PluginStatus, Settings, Registry, build_icon, check_directory_exists, translate
from openlp.core.utils import AppLocation, get_web_page, get_filesystem_encoding from openlp.core.utils import AppLocation, get_web_page
from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -67,7 +67,7 @@ class ThemeScreenshotThread(QtCore.QThread):
filename = config.get(u'theme_%s' % theme, u'filename') filename = config.get(u'theme_%s' % theme, u'filename')
screenshot = config.get(u'theme_%s' % theme, u'screenshot') screenshot = config.get(u'theme_%s' % theme, u'screenshot')
urllib.urlretrieve(u'%s%s' % (self.parent().web, screenshot), urllib.urlretrieve(u'%s%s' % (self.parent().web, screenshot),
os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp', screenshot)) os.path.join(gettempdir(), u'openlp', screenshot))
item = QtGui.QListWidgetItem(title, self.parent().themes_list_widget) item = QtGui.QListWidgetItem(title, self.parent().themes_list_widget)
item.setData(QtCore.Qt.UserRole, filename) item.setData(QtCore.Qt.UserRole, filename)
item.setCheckState(QtCore.Qt.Unchecked) item.setCheckState(QtCore.Qt.Unchecked)
@ -93,7 +93,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
self.web_access = get_web_page(u'%s%s' % (self.web, u'download.cfg')) self.web_access = get_web_page(u'%s%s' % (self.web, u'download.cfg'))
if self.web_access: if self.web_access:
files = self.web_access.read() files = self.web_access.read()
self.config.readfp(io.BytesIO(files)) self.config.read_string(files.decode())
self.update_screen_list_combo() self.update_screen_list_combo()
self.was_download_cancelled = False self.was_download_cancelled = False
self.theme_screenshot_thread = None self.theme_screenshot_thread = None
@ -115,7 +115,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
Set up display at start of theme edit. Set up display at start of theme edit.
""" """
self.restart() self.restart()
check_directory_exists(os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp')) check_directory_exists(os.path.join(gettempdir(), u'openlp'))
self.no_internet_finish_button.setVisible(False) self.no_internet_finish_button.setVisible(False)
# Check if this is a re-run of the wizard. # Check if this is a re-run of the wizard.
self.has_run_wizard = Settings().value(u'core/has run wizard') self.has_run_wizard = Settings().value(u'core/has run wizard')
@ -124,8 +124,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
songs = self.config.get(u'songs', u'languages') songs = self.config.get(u'songs', u'languages')
songs = songs.split(u',') songs = songs.split(u',')
for song in songs: for song in songs:
title = unicode(self.config.get(u'songs_%s' % song, u'title'), u'utf8') title = self.config.get(u'songs_%s' % song, u'title')
filename = unicode(self.config.get(u'songs_%s' % song, u'filename'), u'utf8') filename = self.config.get(u'songs_%s' % song, u'filename')
item = QtGui.QListWidgetItem(title, self.songs_list_widget) item = QtGui.QListWidgetItem(title, self.songs_list_widget)
item.setData(QtCore.Qt.UserRole, filename) item.setData(QtCore.Qt.UserRole, filename)
item.setCheckState(QtCore.Qt.Unchecked) item.setCheckState(QtCore.Qt.Unchecked)
@ -133,13 +133,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
bible_languages = self.config.get(u'bibles', u'languages') bible_languages = self.config.get(u'bibles', u'languages')
bible_languages = bible_languages.split(u',') bible_languages = bible_languages.split(u',')
for lang in bible_languages: for lang in bible_languages:
language = unicode(self.config.get(u'bibles_%s' % lang, u'title'), u'utf8') language = self.config.get(u'bibles_%s' % lang, u'title')
langItem = QtGui.QTreeWidgetItem(self.bibles_tree_widget, [language]) langItem = QtGui.QTreeWidgetItem(self.bibles_tree_widget, [language])
bibles = self.config.get(u'bibles_%s' % lang, u'translations') bibles = self.config.get(u'bibles_%s' % lang, u'translations')
bibles = bibles.split(u',') bibles = bibles.split(u',')
for bible in bibles: for bible in bibles:
title = unicode(self.config.get(u'bible_%s' % bible, u'title'), u'utf8') title = self.config.get(u'bible_%s' % bible, u'title')
filename = unicode(self.config.get(u'bible_%s' % bible, u'filename')) filename = self.config.get(u'bible_%s' % bible, u'filename')
item = QtGui.QTreeWidgetItem(langItem, [title]) item = QtGui.QTreeWidgetItem(langItem, [title])
item.setData(0, QtCore.Qt.UserRole, filename) item.setData(0, QtCore.Qt.UserRole, filename)
item.setCheckState(0, QtCore.Qt.Unchecked) item.setCheckState(0, QtCore.Qt.Unchecked)
@ -292,8 +292,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
item = self.themes_list_widget.item(index) item = self.themes_list_widget.item(index)
if item.data(QtCore.Qt.UserRole) == filename: if item.data(QtCore.Qt.UserRole) == filename:
break break
item.setIcon(build_icon(os.path.join(unicode(gettempdir(), item.setIcon(build_icon(os.path.join(gettempdir(), u'openlp', screenshot)))
get_filesystem_encoding()), u'openlp', screenshot)))
def _getFileSize(self, url): def _getFileSize(self, url):
""" """
@ -302,9 +301,9 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
``url`` ``url``
The URL of the file we want to download. The URL of the file we want to download.
""" """
site = urllib.urlopen(url) site = urllib.request.urlopen(url)
meta = site.info() meta = site.info()
return int(meta.getheaders("Content-Length")[0]) return int(meta.get("Content-Length"))
def _download_progress(self, count, block_size): def _download_progress(self, count, block_size):
""" """
@ -426,8 +425,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
self._set_plugin_status(self.alert_check_box, u'alerts/status') self._set_plugin_status(self.alert_check_box, u'alerts/status')
if self.web_access: if self.web_access:
# Build directories for downloads # Build directories for downloads
songs_destination = os.path.join( songs_destination = os.path.join(gettempdir(), u'openlp')
unicode(gettempdir(), get_filesystem_encoding()), u'openlp')
bibles_destination = AppLocation.get_section_data_path(u'bibles') bibles_destination = AppLocation.get_section_data_path(u'bibles')
themes_destination = AppLocation.get_section_data_path(u'themes') themes_destination = AppLocation.get_section_data_path(u'themes')
# Download songs # Download songs

View File

@ -44,7 +44,7 @@ class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, parent) super(FirstTimeLanguageForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
self.qmList = LanguageManager.get_qm_list() self.qmList = LanguageManager.get_qm_list()
self.language_combo_box.addItem(u'Autodetect') self.language_combo_box.addItem(u'Autodetect')

View File

@ -46,7 +46,7 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, parent) super(FormattingTagForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
self.tag_table_widget.itemSelectionChanged.connect(self.on_row_selected) self.tag_table_widget.itemSelectionChanged.connect(self.on_row_selected)
self.new_push_button.clicked.connect(self.on_new_clicked) self.new_push_button.clicked.connect(self.on_new_clicked)

View File

@ -49,14 +49,14 @@ class GeneralTab(SettingsTab):
self.screens = ScreenList() self.screens = ScreenList()
self.icon_path = u':/icon/openlp-logo-16x16.png' self.icon_path = u':/icon/openlp-logo-16x16.png'
general_translated = translate('OpenLP.GeneralTab', 'General') general_translated = translate('OpenLP.GeneralTab', 'General')
SettingsTab.__init__(self, parent, u'Core', general_translated) super(GeneralTab, self).__init__(parent, u'Core', general_translated)
def setupUi(self): def setupUi(self):
""" """
Create the user interface for the general settings tab Create the user interface for the general settings tab
""" """
self.setObjectName(u'GeneralTab') self.setObjectName(u'GeneralTab')
SettingsTab.setupUi(self) super(GeneralTab, self).setupUi()
self.tab_layout.setStretch(1, 1) self.tab_layout.setStretch(1, 1)
# Monitors # Monitors
self.monitor_group_box = QtGui.QGroupBox(self.left_column) self.monitor_group_box = QtGui.QGroupBox(self.left_column)

View File

@ -65,11 +65,11 @@ class Display(QtGui.QGraphicsView):
Constructor Constructor
""" """
if live: if live:
QtGui.QGraphicsView.__init__(self) super(Display, self).__init__()
# Overwrite the parent() method. # Overwrite the parent() method.
self.parent = lambda: parent self.parent = lambda: parent
else: else:
QtGui.QGraphicsView.__init__(self, parent) super(Display, self).__init__(parent)
self.is_live = live self.is_live = live
self.controller = controller self.controller = controller
self.screen = {} self.screen = {}
@ -126,7 +126,7 @@ class MainDisplay(Display):
""" """
Constructor Constructor
""" """
Display.__init__(self, parent, live, controller) super(MainDisplay, self).__init__(parent, live, controller)
self.screens = ScreenList() self.screens = ScreenList()
self.rebuild_css = False self.rebuild_css = False
self.hide_mode = None self.hide_mode = None
@ -536,7 +536,7 @@ class AudioPlayer(QtCore.QObject):
The parent widget. The parent widget.
""" """
log.debug(u'AudioPlayer Initialisation started') log.debug(u'AudioPlayer Initialisation started')
QtCore.QObject.__init__(self, parent) super(AudioPlayer, self).__init__(parent)
self.currentIndex = -1 self.currentIndex = -1
self.playlist = [] self.playlist = []
self.repeat = False self.repeat = False

View File

@ -47,8 +47,7 @@ from openlp.core.lib.ui import UiStrings, create_action
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \
MediaDockManager, ShortcutListForm, FormattingTagForm MediaDockManager, ShortcutListForm, FormattingTagForm
from openlp.core.ui.media import MediaController from openlp.core.ui.media import MediaController
from openlp.core.utils import AppLocation, LanguageManager, add_actions, get_application_version, \ from openlp.core.utils import AppLocation, LanguageManager, add_actions, get_application_version
get_filesystem_encoding
from openlp.core.utils.actions import ActionList, CategoryOrder from openlp.core.utils.actions import ActionList, CategoryOrder
from openlp.core.ui.firsttimeform import FirstTimeForm from openlp.core.ui.firsttimeform import FirstTimeForm
@ -476,7 +475,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
""" """
This constructor sets up the interface, the various managers, and the plugins. This constructor sets up the interface, the various managers, and the plugins.
""" """
QtGui.QMainWindow.__init__(self) super(MainWindow, self).__init__()
Registry().register(u'main_window', self) Registry().register(u'main_window', self)
self.clipboard = self.application.clipboard() self.clipboard = self.application.clipboard()
self.arguments = self.application.args self.arguments = self.application.args
@ -903,7 +902,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
# Make sure it's a .conf file. # Make sure it's a .conf file.
if not export_file_name.endswith(u'conf'): if not export_file_name.endswith(u'conf'):
export_file_name += u'.conf' export_file_name += u'.conf'
temp_file = os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp', u'exportConf.tmp') temp_file = os.path.join(gettempdir(), u'openlp', u'exportConf.tmp')
self.save_settings() self.save_settings()
setting_sections = [] setting_sections = []
# Add main sections. # Add main sections.

View File

@ -53,7 +53,7 @@ class MediaSlider(QtGui.QSlider):
""" """
Constructor Constructor
""" """
QtGui.QSlider.__init__(self, direction) super(MediaSlider, self).__init__(direction)
self.manager = manager self.manager = manager
self.controller = controller self.controller = controller

View File

@ -87,7 +87,7 @@ class PhononPlayer(MediaPlayer):
""" """
Constructor Constructor
""" """
MediaPlayer.__init__(self, parent, u'phonon') super(PhononPlayer, self).__init__(parent, u'phonon')
self.original_name = u'Phonon' self.original_name = u'Phonon'
self.display_name = u'&Phonon' self.display_name = u'&Phonon'
self.parent = parent self.parent = parent

View File

@ -55,18 +55,18 @@ class PlayerTab(SettingsTab):
""" """
Constructor Constructor
""" """
self.media_players = self.media_controller.media_players self.media_players = Registry().get('media_controller').media_players
self.saved_used_players = None self.saved_used_players = None
self.icon_path = u':/media/multimedia-player.png' self.icon_path = u':/media/multimedia-player.png'
player_translated = translate('OpenLP.PlayerTab', 'Players') player_translated = translate('OpenLP.PlayerTab', 'Players')
SettingsTab.__init__(self, parent, u'Players', player_translated) super(PlayerTab, self).__init__(parent, u'Players', player_translated)
def setupUi(self): def setupUi(self):
""" """
Set up the UI Set up the UI
""" """
self.setObjectName(u'MediaTab') self.setObjectName(u'MediaTab')
SettingsTab.setupUi(self) super(PlayerTab, self).setupUi()
self.background_color_group_box = QtGui.QGroupBox(self.left_column) self.background_color_group_box = QtGui.QGroupBox(self.left_column)
self.background_color_group_box.setObjectName(u'background_color_group_box') self.background_color_group_box.setObjectName(u'background_color_group_box')
self.form_layout = QtGui.QFormLayout(self.background_color_group_box) self.form_layout = QtGui.QFormLayout(self.background_color_group_box)

View File

@ -58,10 +58,12 @@ except OSError, e:
if VLC_AVAILABLE: if VLC_AVAILABLE:
try: try:
VERSION = vlc.libvlc_get_version() VERSION = vlc.libvlc_get_version().decode('UTF-8')
except: except:
VERSION = u'0.0.0' VERSION = u'0.0.0'
if LooseVersion(VERSION) < LooseVersion('1.1.0'): # LooseVersion does not work when a string contains letter and digits (e. g. 2.0.5 Twoflower).
# http://bugs.python.org/issue14894
if LooseVersion(VERSION.split()[0]) < LooseVersion('1.1.0'):
VLC_AVAILABLE = False VLC_AVAILABLE = False
log.debug(u'VLC could not be loaded, because the vlc version is too old: %s' % VERSION) log.debug(u'VLC could not be loaded, because the vlc version is too old: %s' % VERSION)
@ -96,15 +98,14 @@ VIDEO_EXT = [
class VlcPlayer(MediaPlayer): class VlcPlayer(MediaPlayer):
""" """
A specialised version of the MediaPlayer class, which provides a VLC A specialised version of the MediaPlayer class, which provides a VLC display.
display.
""" """
def __init__(self, parent): def __init__(self, parent):
""" """
Constructor Constructor
""" """
MediaPlayer.__init__(self, parent, u'vlc') super(VlcPlayer, self).__init__(parent, u'vlc')
self.original_name = u'VLC' self.original_name = u'VLC'
self.display_name = u'&VLC' self.display_name = u'&VLC'
self.parent = parent self.parent = parent

View File

@ -213,7 +213,7 @@ class WebkitPlayer(MediaPlayer):
""" """
Constructor Constructor
""" """
MediaPlayer.__init__(self, parent, u'webkit') super(WebkitPlayer, self).__init__(parent, u'webkit')
self.original_name = u'WebKit' self.original_name = u'WebKit'
self.display_name = u'&WebKit' self.display_name = u'&WebKit'
self.parent = parent self.parent = parent

View File

@ -48,7 +48,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, parent) super(PluginForm, self).__init__(parent)
self.activePlugin = None self.activePlugin = None
self.programaticChange = False self.programaticChange = False
self.setupUi(self) self.setupUi(self)

View File

@ -118,7 +118,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, self.main_window) super(PrintServiceForm, self).__init__(Registry().get('main_window'))
self.printer = QtGui.QPrinter() self.printer = QtGui.QPrinter()
self.print_dialog = QtGui.QPrintDialog(self.printer, self) self.print_dialog = QtGui.QPrintDialog(self.printer, self)
self.document = QtGui.QTextDocument() self.document = QtGui.QTextDocument()
@ -183,7 +183,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
self._add_element( self._add_element(
u'span', translate('OpenLP.ServiceManager', 'Custom Service Notes: '), div, classId=u'customNotesTitle') u'span', translate('OpenLP.ServiceManager', 'Custom Service Notes: '), div, classId=u'customNotesTitle')
self._add_element(u'span', cgi.escape(self.footer_text_edit.toPlainText()), div, classId=u'customNotesText') self._add_element(u'span', cgi.escape(self.footer_text_edit.toPlainText()), div, classId=u'customNotesText')
self.document.setHtml(html.tostring(html_data)) self.document.setHtml(html.tostring(html_data).decode())
self.preview_widget.updatePreview() self.preview_widget.updatePreview()
def _add_preview_item(self, body, item, index): def _add_preview_item(self, body, item, index):

View File

@ -43,7 +43,7 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, self.main_window) super(ServiceItemEditForm, self).__init__(Registry().get(u'main_window'))
self.setupUi(self) self.setupUi(self)
self.item_list = [] self.item_list = []
self.list_widget.currentRowChanged.connect(self.on_current_row_changed) self.list_widget.currentRowChanged.connect(self.on_current_row_changed)

View File

@ -60,7 +60,7 @@ class ServiceManagerList(QtGui.QTreeWidget):
""" """
Constructor Constructor
""" """
QtGui.QTreeWidget.__init__(self, parent) super(ServiceManagerList, self).__init__(parent)
self.serviceManager = serviceManager self.serviceManager = serviceManager
def keyPressEvent(self, event): def keyPressEvent(self, event):
@ -294,7 +294,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
""" """
Sets up the service manager, toolbars, list view, et al. Sets up the service manager, toolbars, list view, et al.
""" """
QtGui.QWidget.__init__(self, parent) super(ServiceManager, self).__init__(parent)
self.active = build_icon(u':/media/auto-start_active.png') self.active = build_icon(u':/media/auto-start_active.png')
self.inactive = build_icon(u':/media/auto-start_inactive.png') self.inactive = build_icon(u':/media/auto-start_inactive.png')
Registry().register(u'service_manager', self) Registry().register(u'service_manager', self)
@ -521,11 +521,11 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
self.main_window.increment_progress_bar() self.main_window.increment_progress_bar()
try: try:
zip_file = zipfile.ZipFile(temp_file_name, 'w', zipfile.ZIP_STORED, allow_zip_64) zip_file = zipfile.ZipFile(temp_file_name, 'w', zipfile.ZIP_STORED, allow_zip_64)
# First we add service contents. We save ALL file_names into ZIP using UTF-8. # First we add service contents..
zip_file.writestr(service_file_name.encode(u'utf-8'), service_content) zip_file.writestr(service_file_name, service_content)
# Finally add all the listed media files. # Finally add all the listed media files.
for write_from in write_list: for write_from in write_list:
zip_file.write(write_from, write_from.encode(u'utf-8')) zip_file.write(write_from, write_from)
for audio_from, audio_to in audio_files: for audio_from, audio_to in audio_files:
if audio_from.startswith(u'audio'): if audio_from.startswith(u'audio'):
# When items are saved, they get new unique_identifier. Let's copy the file to the new location. # When items are saved, they get new unique_identifier. Let's copy the file to the new location.
@ -536,7 +536,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
check_directory_exists(save_path) check_directory_exists(save_path)
if not os.path.exists(save_file): if not os.path.exists(save_file):
shutil.copy(audio_from, save_file) shutil.copy(audio_from, save_file)
zip_file.write(audio_from, audio_to.encode(u'utf-8')) zip_file.write(audio_from, audio_to)
except IOError: except IOError:
log.exception(u'Failed to save service to disk: %s', temp_file_name) log.exception(u'Failed to save service to disk: %s', temp_file_name)
self.main_window.error_message(translate(u'OpenLP.ServiceManager', u'Error Saving File'), self.main_window.error_message(translate(u'OpenLP.ServiceManager', u'Error Saving File'),
@ -593,7 +593,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
zip_file = zipfile.ZipFile(temp_file_name, 'w', zipfile.ZIP_STORED, zip_file = zipfile.ZipFile(temp_file_name, 'w', zipfile.ZIP_STORED,
True) True)
# First we add service contents. # First we add service contents.
zip_file.writestr(service_file_name.encode(u'utf-8'), service_content) zip_file.writestr(service_file_name, service_content)
except IOError: except IOError:
log.exception(u'Failed to save service to disk: %s', temp_file_name) log.exception(u'Failed to save service to disk: %s', temp_file_name)
self.main_window.error_message(translate(u'OpenLP.ServiceManager', u'Error Saving File'), self.main_window.error_message(translate(u'OpenLP.ServiceManager', u'Error Saving File'),
@ -685,14 +685,13 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
zip_file = zipfile.ZipFile(file_name) zip_file = zipfile.ZipFile(file_name)
for zip_info in zip_file.infolist(): for zip_info in zip_file.infolist():
try: try:
ucsfile = zip_info.filename.decode(u'utf-8') ucs_file = zip_info.filename
except UnicodeDecodeError: except UnicodeDecodeError:
log.exception(u'file_name "%s" is not valid UTF-8' % log.exception(u'file_name "%s" is not valid UTF-8' % zip_info.file_name)
zip_info.file_name.decode(u'utf-8', u'replace'))
critical_error_message_box(message=translate('OpenLP.ServiceManager', critical_error_message_box(message=translate('OpenLP.ServiceManager',
'File is not a valid service.\n The content encoding is not UTF-8.')) 'File is not a valid service.\n The content encoding is not UTF-8.'))
continue continue
osfile = ucsfile.replace(u'/', os.path.sep) osfile = ucs_file.replace(u'/', os.path.sep)
if not osfile.startswith(u'audio'): if not osfile.startswith(u'audio'):
osfile = os.path.split(osfile)[1] osfile = os.path.split(osfile)[1]
log.debug(u'Extract file: %s', osfile) log.debug(u'Extract file: %s', osfile)

View File

@ -43,7 +43,7 @@ class ServiceNoteForm(QtGui.QDialog):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, self.main_window) super(ServiceNoteForm, self).__init__(Registry().get(u'main_window'))
self.setupUi() self.setupUi()
self.retranslateUi() self.retranslateUi()

View File

@ -51,7 +51,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
""" """
Registry().register(u'settings_form', self) Registry().register(u'settings_form', self)
Registry().register_function(u'bootstrap_post_set_up', self.post_set_up) Registry().register_function(u'bootstrap_post_set_up', self.post_set_up)
QtGui.QDialog.__init__(self, parent) super(SettingsForm, self).__init__(parent)
self.processes = [] self.processes = []
self.setupUi(self) self.setupUi(self)

View File

@ -43,7 +43,7 @@ class CaptureShortcutButton(QtGui.QPushButton):
""" """
Constructor Constructor
""" """
QtGui.QPushButton.__init__(self, *args) super(CaptureShortcutButton, self).__init__(*args)
self.setCheckable(True) self.setCheckable(True)
def keyPressEvent(self, event): def keyPressEvent(self, event):

View File

@ -52,7 +52,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, parent) super(ShortcutListForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
self.changedActions = {} self.changedActions = {}
self.action_list = ActionList.get_instance() self.action_list = ActionList.get_instance()

View File

@ -65,7 +65,7 @@ class DisplayController(QtGui.QWidget):
""" """
Set up the general Controller. Set up the general Controller.
""" """
QtGui.QWidget.__init__(self, parent) super(DisplayController, self).__init__(parent)
self.is_live = is_live self.is_live = is_live
self.display = None self.display = None
self.controller_type = DisplayControllerType.Plugin self.controller_type = DisplayControllerType.Plugin
@ -90,7 +90,7 @@ class SlideController(DisplayController):
""" """
Set up the Slide Controller. Set up the Slide Controller.
""" """
DisplayController.__init__(self, parent, is_live) super(SlideController, self).__init__(parent, is_live)
Registry().register_function(u'bootstrap_post_set_up', self.screen_size_changed) Registry().register_function(u'bootstrap_post_set_up', self.screen_size_changed)
self.screens = ScreenList() self.screens = ScreenList()
try: try:

View File

@ -41,7 +41,7 @@ class SplashScreen(QtGui.QSplashScreen):
""" """
Constructor Constructor
""" """
QtGui.QSplashScreen.__init__(self) super(SplashScreen, self).__init__()
self.setupUi() self.setupUi()
def setupUi(self): def setupUi(self):

View File

@ -45,7 +45,7 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, self.main_window) super(StartTimeForm, self).__init__(Registry().get(u'main_window'))
self.setupUi(self) self.setupUi(self)
def exec_(self): def exec_(self):

View File

@ -58,7 +58,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
``parent`` ``parent``
The QWidget-derived parent of the wizard. The QWidget-derived parent of the wizard.
""" """
QtGui.QWizard.__init__(self, parent) super(ThemeForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
self.registerFields() self.registerFields()
self.updateThemeAllowed = True self.updateThemeAllowed = True

View File

@ -42,7 +42,7 @@ class ThemeLayoutForm(QtGui.QDialog, Ui_ThemeLayoutDialog):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, parent) super(ThemeLayoutForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
def exec_(self, image): def exec_(self, image):

View File

@ -57,7 +57,7 @@ class ThemeManager(QtGui.QWidget):
""" """
Constructor Constructor
""" """
QtGui.QWidget.__init__(self, parent) super(ThemeManager, self).__init__(parent)
Registry().register(u'theme_manager', self) Registry().register(u'theme_manager', self)
Registry().register_function(u'bootstrap_initialise', self.load_first_time_themes) Registry().register_function(u'bootstrap_initialise', self.load_first_time_themes)
Registry().register_function(u'bootstrap_post_set_up', self._push_themes) Registry().register_function(u'bootstrap_post_set_up', self._push_themes)
@ -514,23 +514,17 @@ class ThemeManager(QtGui.QWidget):
else: else:
abort_import = False abort_import = False
for name in theme_zip.namelist(): for name in theme_zip.namelist():
try: name = name.replace(u'/', os.path.sep)
uname = unicode(name, u'utf-8') split_name = name.split(os.path.sep)
except UnicodeDecodeError:
log.exception(u'Theme file contains non utf-8 filename "%s"' %
name.decode(u'utf-8', u'replace'))
raise Exception(u'validation')
uname = uname.replace(u'/', os.path.sep)
split_name = uname.split(os.path.sep)
if split_name[-1] == u'' or len(split_name) == 1: if split_name[-1] == u'' or len(split_name) == 1:
# is directory or preview file # is directory or preview file
continue continue
full_name = os.path.join(directory, uname) full_name = os.path.join(directory, name)
check_directory_exists(os.path.dirname(full_name)) check_directory_exists(os.path.dirname(full_name))
if os.path.splitext(uname)[1].lower() == u'.xml': if os.path.splitext(name)[1].lower() == u'.xml':
file_xml = unicode(theme_zip.read(name), u'utf-8') file_xml = unicode(theme_zip.read(name), u'utf-8')
out_file = open(full_name, u'w') out_file = open(full_name, u'w')
out_file.write(file_xml.encode(u'utf-8')) out_file.write(file_xml)
else: else:
out_file = open(full_name, u'wb') out_file = open(full_name, u'wb')
out_file.write(theme_zip.read(name)) out_file.write(theme_zip.read(name))
@ -637,7 +631,7 @@ class ThemeManager(QtGui.QWidget):
out_file = None out_file = None
try: try:
out_file = open(theme_file, u'w') out_file = open(theme_file, u'w')
out_file.write(theme_pretty_xml) out_file.write(theme_pretty_xml.decode('UTF-8'))
except IOError: except IOError:
log.exception(u'Saving theme to file failed') log.exception(u'Saving theme to file failed')
finally: finally:

View File

@ -48,14 +48,14 @@ class ThemesTab(SettingsTab):
""" """
self.icon_path = u':/themes/theme_new.png' self.icon_path = u':/themes/theme_new.png'
theme_translated = translate('OpenLP.ThemesTab', 'Themes') theme_translated = translate('OpenLP.ThemesTab', 'Themes')
SettingsTab.__init__(self, parent, u'Themes', theme_translated) super(ThemesTab, self).__init__(parent, u'Themes', theme_translated)
def setupUi(self): def setupUi(self):
""" """
Set up the UI Set up the UI
""" """
self.setObjectName(u'ThemesTab') self.setObjectName(u'ThemesTab')
SettingsTab.setupUi(self) super(ThemesTab, self).setupUi()
self.global_group_box = QtGui.QGroupBox(self.left_column) self.global_group_box = QtGui.QGroupBox(self.left_column)
self.global_group_box.setObjectName(u'global_group_box') self.global_group_box.setObjectName(u'global_group_box')
self.global_group_box_layout = QtGui.QVBoxLayout(self.global_group_box) self.global_group_box_layout = QtGui.QVBoxLayout(self.global_group_box)

View File

@ -96,7 +96,7 @@ class OpenLPWizard(QtGui.QWizard):
""" """
Constructor Constructor
""" """
QtGui.QWizard.__init__(self, parent) super(OpenLPWizard, self).__init__(parent)
self.plugin = plugin self.plugin = plugin
self.with_progress_page = add_progress_page self.with_progress_page = add_progress_page
self.setObjectName(name) self.setObjectName(name)

View File

@ -38,7 +38,6 @@ import re
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
import sys import sys
import urllib2 import urllib2
import icu
from PyQt4 import QtGui, QtCore from PyQt4 import QtGui, QtCore
@ -107,6 +106,7 @@ def get_application_version():
# Get the revision of this tree. # Get the revision of this tree.
bzr = Popen((u'bzr', u'revno'), stdout=PIPE) bzr = Popen((u'bzr', u'revno'), stdout=PIPE)
tree_revision, error = bzr.communicate() tree_revision, error = bzr.communicate()
tree_revision = tree_revision.decode()
code = bzr.wait() code = bzr.wait()
if code != 0: if code != 0:
raise Exception(u'Error running bzr log') raise Exception(u'Error running bzr log')
@ -117,7 +117,7 @@ def get_application_version():
code = bzr.wait() code = bzr.wait()
if code != 0: if code != 0:
raise Exception(u'Error running bzr tags') raise Exception(u'Error running bzr tags')
tags = output.splitlines() tags = map(bytes.decode, output.splitlines())
if not tags: if not tags:
tag_version = u'0.0.0' tag_version = u'0.0.0'
tag_revision = u'0' tag_revision = u'0'
@ -196,7 +196,7 @@ def check_latest_version(current_version):
req.add_header(u'User-Agent', u'OpenLP/%s' % current_version[u'full']) req.add_header(u'User-Agent', u'OpenLP/%s' % current_version[u'full'])
remote_version = None remote_version = None
try: try:
remote_version = unicode(urllib2.urlopen(req, None).read()).strip() remote_version = unicode(urllib2.urlopen(req, None).read().decode()).strip()
except IOError: except IOError:
log.exception(u'Failed to download the latest OpenLP version file') log.exception(u'Failed to download the latest OpenLP version file')
if remote_version: if remote_version:
@ -239,7 +239,7 @@ def get_images_filter():
global IMAGES_FILTER global IMAGES_FILTER
if not IMAGES_FILTER: if not IMAGES_FILTER:
log.debug(u'Generating images filter.') log.debug(u'Generating images filter.')
formats = map(unicode, QtGui.QImageReader.supportedImageFormats()) formats = list(map(bytes.decode, map(bytes, QtGui.QImageReader.supportedImageFormats())))
visible_formats = u'(*.%s)' % u'; *.'.join(formats) visible_formats = u'(*.%s)' % u'; *.'.join(formats)
actual_formats = u'(*.%s)' % u' *.'.join(formats) actual_formats = u'(*.%s)' % u' *.'.join(formats)
IMAGES_FILTER = u'%s %s %s' % (translate('OpenLP', 'Image Files'), visible_formats, actual_formats) IMAGES_FILTER = u'%s %s %s' % (translate('OpenLP', 'Image Files'), visible_formats, actual_formats)
@ -393,16 +393,22 @@ def format_time(text, local_time):
def get_locale_key(string): def get_locale_key(string):
""" """
Creates a key for case insensitive, locale aware string sorting. Creates a key for case insensitive, locale aware string sorting.
``string``
The corresponding string.
""" """
string = string.lower() string = string.lower()
# For Python 3 on platforms other than Windows ICU is not necessary. In those cases locale.strxfrm(str) can be used. # For Python 3 on platforms other than Windows ICU is not necessary. In those cases locale.strxfrm(str) can be used.
global ICU_COLLATOR if os.name == 'nt':
if ICU_COLLATOR is None: global ICU_COLLATOR
from languagemanager import LanguageManager if ICU_COLLATOR is None:
locale = LanguageManager.get_language() import icu
icu_locale = icu.Locale(locale) from languagemanager import LanguageManager
ICU_COLLATOR = icu.Collator.createInstance(icu_locale) language = LanguageManager.get_language()
return ICU_COLLATOR.getSortKey(string) icu_locale = icu.Locale(language)
ICU_COLLATOR = icu.Collator.createInstance(icu_locale)
return ICU_COLLATOR.getSortKey(string)
return locale.strxfrm(string).encode()
def get_natural_key(string): def get_natural_key(string):
@ -412,9 +418,10 @@ def get_natural_key(string):
""" """
key = DIGITS_OR_NONDIGITS.findall(string) key = DIGITS_OR_NONDIGITS.findall(string)
key = [int(part) if part.isdigit() else get_locale_key(part) for part in key] key = [int(part) if part.isdigit() else get_locale_key(part) for part in key]
# Python 3 does not support comparision of different types anymore. So make sure, that we do not compare str and int. # Python 3 does not support comparision of different types anymore. So make sure, that we do not compare str
#if string[0].isdigit(): # and int.
# return [''] + key if string[0].isdigit():
return [b''] + key
return key return key

View File

@ -103,12 +103,6 @@ class CategoryActionList(object):
self.index += 1 self.index += 1
return self.actions[self.index - 1][1] return self.actions[self.index - 1][1]
def next(self):
"""
Python 2 "next" method.
"""
return self.__next__()
def has_key(self, key): def has_key(self, key):
""" """
Implement the has_key() method to make this class a dictionary type Implement the has_key() method to make this class a dictionary type
@ -167,12 +161,6 @@ class CategoryList(object):
return category return category
raise KeyError(u'Category "%s" does not exist.' % key) raise KeyError(u'Category "%s" does not exist.' % key)
def __contains__(self, item):
"""
Implement the __contains__() method to make this class like a dictionary
"""
return self.has_key(item)
def __len__(self): def __len__(self):
""" """
Implement the __len__() method to make this class like a dictionary Implement the __len__() method to make this class like a dictionary
@ -196,12 +184,6 @@ class CategoryList(object):
self.index += 1 self.index += 1
return self.categories[self.index - 1] return self.categories[self.index - 1]
def next(self):
"""
Python 2 "next" method for iterator.
"""
return self.__next__()
def has_key(self, key): def has_key(self, key):
""" """
Implement the has_key() method to make this class like a dictionary Implement the has_key() method to make this class like a dictionary

View File

@ -143,20 +143,19 @@ def _get_os_dir_path(dir_type):
""" """
Return a path based on which OS and environment we are running in. Return a path based on which OS and environment we are running in.
""" """
encoding = sys.getfilesystemencoding()
if sys.platform == u'win32': if sys.platform == u'win32':
if dir_type == AppLocation.DataDir: if dir_type == AppLocation.DataDir:
return os.path.join(unicode(os.getenv(u'APPDATA'), encoding), u'openlp', u'data') return os.path.join(unicode(os.getenv(u'APPDATA')), u'openlp', u'data')
elif dir_type == AppLocation.LanguageDir: elif dir_type == AppLocation.LanguageDir:
return os.path.split(openlp.__file__)[0] return os.path.split(openlp.__file__)[0]
return os.path.join(unicode(os.getenv(u'APPDATA'), encoding), u'openlp') return os.path.join(unicode(os.getenv(u'APPDATA')), u'openlp')
elif sys.platform == u'darwin': elif sys.platform == u'darwin':
if dir_type == AppLocation.DataDir: if dir_type == AppLocation.DataDir:
return os.path.join(unicode(os.getenv(u'HOME'), encoding), return os.path.join(unicode(os.getenv(u'HOME')),
u'Library', u'Application Support', u'openlp', u'Data') u'Library', u'Application Support', u'openlp', u'Data')
elif dir_type == AppLocation.LanguageDir: elif dir_type == AppLocation.LanguageDir:
return os.path.split(openlp.__file__)[0] return os.path.split(openlp.__file__)[0]
return os.path.join(unicode(os.getenv(u'HOME'), encoding), u'Library', u'Application Support', u'openlp') return os.path.join(unicode(os.getenv(u'HOME')), u'Library', u'Application Support', u'openlp')
else: else:
if dir_type == AppLocation.LanguageDir: if dir_type == AppLocation.LanguageDir:
for prefix in [u'/usr/local', u'/usr']: for prefix in [u'/usr/local', u'/usr']:
@ -166,10 +165,10 @@ def _get_os_dir_path(dir_type):
return os.path.join(u'/usr', u'share', u'openlp') return os.path.join(u'/usr', u'share', u'openlp')
if XDG_BASE_AVAILABLE: if XDG_BASE_AVAILABLE:
if dir_type == AppLocation.DataDir: if dir_type == AppLocation.DataDir:
return os.path.join(unicode(BaseDirectory.xdg_data_home, encoding), u'openlp') return os.path.join(unicode(BaseDirectory.xdg_data_home), u'openlp')
elif dir_type == AppLocation.CacheDir: elif dir_type == AppLocation.CacheDir:
return os.path.join(unicode(BaseDirectory.xdg_cache_home, encoding), u'openlp') return os.path.join(unicode(BaseDirectory.xdg_cache_home), u'openlp')
if dir_type == AppLocation.DataDir: if dir_type == AppLocation.DataDir:
return os.path.join(unicode(os.getenv(u'HOME'), encoding), u'.openlp', u'data') return os.path.join(unicode(os.getenv(u'HOME')), u'.openlp', u'data')
return os.path.join(unicode(os.getenv(u'HOME'), encoding), u'.openlp') return os.path.join(unicode(os.getenv(u'HOME')), u'.openlp')

View File

@ -129,7 +129,7 @@ class AlertsPlugin(Plugin):
log.info(u'Alerts Plugin loaded') log.info(u'Alerts Plugin loaded')
def __init__(self): def __init__(self):
Plugin.__init__(self, u'alerts', __default_settings__, settings_tab_class=AlertsTab) super(AlertsPlugin, self).__init__(u'alerts', __default_settings__, settings_tab_class=AlertsTab)
self.weight = -3 self.weight = -3
self.icon_path = u':/plugins/plugin_alerts.png' self.icon_path = u':/plugins/plugin_alerts.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
@ -153,7 +153,7 @@ class AlertsPlugin(Plugin):
def initialise(self): def initialise(self):
log.info(u'Alerts Initialising') log.info(u'Alerts Initialising')
Plugin.initialise(self) super(AlertsPlugin, self).initialise()
self.tools_alert_item.setVisible(True) self.tools_alert_item.setVisible(True)
action_list = ActionList.get_instance() action_list = ActionList.get_instance()
action_list.add_action(self.tools_alert_item, UiStrings().Tools) action_list.add_action(self.tools_alert_item, UiStrings().Tools)
@ -164,7 +164,7 @@ class AlertsPlugin(Plugin):
""" """
log.info(u'Alerts Finalising') log.info(u'Alerts Finalising')
self.manager.finalise() self.manager.finalise()
Plugin.finalise(self) super(AlertsPlugin, self).finalise()
self.tools_alert_item.setVisible(False) self.tools_alert_item.setVisible(False)
action_list = ActionList.get_instance() action_list = ActionList.get_instance()
action_list.remove_action(self.tools_alert_item, u'Tools') action_list.remove_action(self.tools_alert_item, u'Tools')

View File

@ -41,7 +41,7 @@ above, like so::
class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
def __init__(self, parent=None): def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent) super(AuthorsForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality, This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality,

View File

@ -46,6 +46,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
self.manager = plugin.manager self.manager = plugin.manager
self.plugin = plugin self.plugin = plugin
self.item_id = None self.item_id = None
# TODO: Use Registry()
super(AlertForm, self).__init__(self.plugin.main_window) super(AlertForm, self).__init__(self.plugin.main_window)
self.setupUi(self) self.setupUi(self)
self.display_button.clicked.connect(self.on_display_clicked) self.display_button.clicked.connect(self.on_display_clicked)

View File

@ -48,7 +48,7 @@ class AlertsManager(QtCore.QObject):
log.info(u'Alert Manager loaded') log.info(u'Alert Manager loaded')
def __init__(self, parent): def __init__(self, parent):
QtCore.QObject.__init__(self, parent) super(AlertsManager, self).__init__(parent)
Registry().register(u'alerts_manager', self) Registry().register(u'alerts_manager', self)
self.timer_id = 0 self.timer_id = 0
self.alert_list = [] self.alert_list = []

View File

@ -38,11 +38,11 @@ class AlertsTab(SettingsTab):
AlertsTab is the alerts settings tab in the settings dialog. AlertsTab is the alerts settings tab in the settings dialog.
""" """
def __init__(self, parent, name, visible_title, icon_path): def __init__(self, parent, name, visible_title, icon_path):
SettingsTab.__init__(self, parent, name, visible_title, icon_path) super(AlertsTab, self).__init__(parent, name, visible_title, icon_path)
def setupUi(self): def setupUi(self):
self.setObjectName(u'AlertsTab') self.setObjectName(u'AlertsTab')
SettingsTab.setupUi(self) super(AlertsTab, self).setupUi()
self.font_group_box = QtGui.QGroupBox(self.left_column) self.font_group_box = QtGui.QGroupBox(self.left_column)
self.font_group_box.setObjectName(u'font_group_box') self.font_group_box.setObjectName(u'font_group_box')
self.font_layout = QtGui.QFormLayout(self.font_group_box) self.font_layout = QtGui.QFormLayout(self.font_group_box)

View File

@ -69,7 +69,7 @@ class BiblePlugin(Plugin):
log.info(u'Bible Plugin loaded') log.info(u'Bible Plugin loaded')
def __init__(self): def __init__(self):
Plugin.__init__(self, u'bibles', __default_settings__, BibleMediaItem, BiblesTab) super(BiblePlugin, self).__init__(u'bibles', __default_settings__, BibleMediaItem, BiblesTab)
self.weight = -9 self.weight = -9
self.icon_path = u':/plugins/plugin_bibles.png' self.icon_path = u':/plugins/plugin_bibles.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)

View File

@ -42,7 +42,7 @@ above, like so::
class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
def __init__(self, parent, manager, bible_plugin): def __init__(self, parent, manager, bible_plugin):
QtGui.QWizard.__init__(self, parent) super(BibleImportForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality, This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality,

View File

@ -78,13 +78,14 @@ class BibleImportForm(OpenLPWizard):
""" """
self.manager = manager self.manager = manager
self.web_bible_list = {} self.web_bible_list = {}
OpenLPWizard.__init__(self, parent, bible_plugin, u'bibleImportWizard', u':/wizards/wizard_importbible.bmp') super(BibleImportForm, self).__init__(
parent, bible_plugin, u'bibleImportWizard', u':/wizards/wizard_importbible.bmp')
def setupUi(self, image): def setupUi(self, image):
""" """
Set up the UI for the bible wizard. Set up the UI for the bible wizard.
""" """
OpenLPWizard.setupUi(self, image) super(BibleImportForm, self).setupUi(image)
self.formatComboBox.currentIndexChanged.connect(self.onCurrentIndexChanged) self.formatComboBox.currentIndexChanged.connect(self.onCurrentIndexChanged)
def onCurrentIndexChanged(self, index): def onCurrentIndexChanged(self, index):
@ -515,7 +516,7 @@ class BibleImportForm(OpenLPWizard):
""" """
Prepare the UI for the import. Prepare the UI for the import.
""" """
OpenLPWizard.pre_wizard(self) super(BibleImportForm, self).pre_wizard()
bible_type = self.field(u'source_format') bible_type = self.field(u'source_format')
if bible_type == BibleFormat.WebDownload: if bible_type == BibleFormat.WebDownload:
self.progress_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Registering Bible...')) self.progress_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Registering Bible...'))

View File

@ -39,7 +39,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Registry, Settings, UiStrings, translate, check_directory_exists from openlp.core.lib import Registry, Settings, UiStrings, translate, check_directory_exists
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
from openlp.core.utils import AppLocation, delete_file, get_filesystem_encoding from openlp.core.utils import AppLocation, delete_file
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, OldBibleDB, BiblesResourcesDB from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, OldBibleDB, BiblesResourcesDB
from openlp.plugins.bibles.lib.http import BSExtract, BGExtract, CWExtract from openlp.plugins.bibles.lib.http import BSExtract, BGExtract, CWExtract
@ -71,17 +71,18 @@ class BibleUpgradeForm(OpenLPWizard):
self.suffix = u'.sqlite' self.suffix = u'.sqlite'
self.settings_section = u'bibles' self.settings_section = u'bibles'
self.path = AppLocation.get_section_data_path(self.settings_section) self.path = AppLocation.get_section_data_path(self.settings_section)
self.temp_dir = os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp') self.temp_dir = os.path.join(gettempdir(), u'openlp')
self.files = self.manager.old_bible_databases self.files = self.manager.old_bible_databases
self.success = {} self.success = {}
self.new_bibles = {} self.new_bibles = {}
OpenLPWizard.__init__(self, parent, bible_plugin, u'bibleUpgradeWizard', u':/wizards/wizard_importbible.bmp') super(BibleUpgradeForm, self).__init__(
parent, bible_plugin, u'bibleUpgradeWizard', u':/wizards/wizard_importbible.bmp')
def setupUi(self, image): def setupUi(self, image):
""" """
Set up the UI for the bible wizard. Set up the UI for the bible wizard.
""" """
OpenLPWizard.setupUi(self, image) super(BibleUpgradeForm, self).setupUi(image)
Registry().execute(u'openlp_stop_wizard', self.stop_import) Registry().execute(u'openlp_stop_wizard', self.stop_import)
def stop_import(self): def stop_import(self):
@ -333,7 +334,7 @@ class BibleUpgradeForm(OpenLPWizard):
""" """
Prepare the UI for the upgrade. Prepare the UI for the upgrade.
""" """
OpenLPWizard.pre_wizard(self) super(BibleUpgradeForm, self).pre_wizard()
self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Starting upgrade...')) self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Starting upgrade...'))
self.application.process_events() self.application.process_events()
@ -559,4 +560,4 @@ class BibleUpgradeForm(OpenLPWizard):
self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade failed.')) self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade failed.'))
# Remove temp directory. # Remove temp directory.
shutil.rmtree(self.temp_dir, True) shutil.rmtree(self.temp_dir, True)
OpenLPWizard.post_wizard(self) super(BibleUpgradeForm, self).post_wizard()

View File

@ -56,7 +56,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog):
""" """
Constructor Constructor
""" """
QDialog.__init__(self, parent) super(BookNameForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
self.custom_signals() self.custom_signals()
self.book_names = BibleStrings().BookNames self.book_names = BibleStrings().BookNames

View File

@ -51,7 +51,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, parent) super(EditBibleForm, self).__init__(parent)
self.media_item = media_item self.media_item = media_item
self.book_names = BibleStrings().BookNames self.book_names = BibleStrings().BookNames
self.setupUi(self) self.setupUi(self)

View File

@ -54,7 +54,7 @@ class LanguageForm(QDialog, Ui_LanguageDialog):
""" """
Constructor Constructor
""" """
QDialog.__init__(self, parent) super(LanguageForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
def exec_(self, bible_name): def exec_(self, bible_name):

View File

@ -49,11 +49,11 @@ class BiblesTab(SettingsTab):
self.paragraph_style = True self.paragraph_style = True
self.show_new_chapters = False self.show_new_chapters = False
self.display_style = 0 self.display_style = 0
SettingsTab.__init__(self, parent, title, visible_title, icon_path) super(BiblesTab, self).__init__(parent, title, visible_title, icon_path)
def setupUi(self): def setupUi(self):
self.setObjectName(u'BiblesTab') self.setObjectName(u'BiblesTab')
SettingsTab.setupUi(self) super(BiblesTab, self).setupUi()
self.verse_display_group_box = QtGui.QGroupBox(self.left_column) self.verse_display_group_box = QtGui.QGroupBox(self.left_column)
self.verse_display_group_box.setObjectName(u'verse_display_group_box') self.verse_display_group_box.setObjectName(u'verse_display_group_box')
self.verse_display_layout = QtGui.QFormLayout(self.verse_display_group_box) self.verse_display_layout = QtGui.QFormLayout(self.verse_display_group_box)

View File

@ -61,7 +61,7 @@ class CustomPlugin(Plugin):
log.info(u'Custom Plugin loaded') log.info(u'Custom Plugin loaded')
def __init__(self): def __init__(self):
Plugin.__init__(self, u'custom', __default_settings__, CustomMediaItem, CustomTab) super(CustomPlugin, self).__init__(u'custom', __default_settings__, CustomMediaItem, CustomTab)
self.weight = -5 self.weight = -5
self.manager = Manager(u'custom', init_schema) self.manager = Manager(u'custom', init_schema)
self.icon_path = u':/plugins/plugin_custom.png' self.icon_path = u':/plugins/plugin_custom.png'

View File

@ -41,11 +41,11 @@ class CustomTab(SettingsTab):
CustomTab is the Custom settings tab in the settings dialog. CustomTab is the Custom settings tab in the settings dialog.
""" """
def __init__(self, parent, title, visible_title, icon_path): def __init__(self, parent, title, visible_title, icon_path):
SettingsTab.__init__(self, parent, title, visible_title, icon_path) super(CustomTab, self).__init__(parent, title, visible_title, icon_path)
def setupUi(self): def setupUi(self):
self.setObjectName(u'CustomTab') self.setObjectName(u'CustomTab')
SettingsTab.setupUi(self) super(CustomTab, self).setupUi()
self.custom_mode_group_box = QtGui.QGroupBox(self.left_column) self.custom_mode_group_box = QtGui.QGroupBox(self.left_column)
self.custom_mode_group_box.setObjectName(u'custom_mode_group_box') self.custom_mode_group_box.setObjectName(u'custom_mode_group_box')
self.custom_mode_layout = QtGui.QFormLayout(self.custom_mode_group_box) self.custom_mode_layout = QtGui.QFormLayout(self.custom_mode_group_box)
@ -97,4 +97,4 @@ class CustomTab(SettingsTab):
settings.endGroup() settings.endGroup()
if self.tab_visited: if self.tab_visited:
self.settings_form.register_post_process(u'custom_config_updated') self.settings_form.register_post_process(u'custom_config_updated')
self.tab_visited = False self.tab_visited = False

View File

@ -57,7 +57,7 @@ class CustomMediaItem(MediaManagerItem):
def __init__(self, parent, plugin): def __init__(self, parent, plugin):
self.icon_path = u'custom/custom' self.icon_path = u'custom/custom'
MediaManagerItem.__init__(self, parent, plugin) super(CustomMediaItem, self).__init__(parent, plugin)
self.edit_custom_form = EditCustomForm(self, self.main_window, self.plugin.manager) self.edit_custom_form = EditCustomForm(self, self.main_window, self.plugin.manager)
self.single_service_item = False self.single_service_item = False
self.quick_preview_allowed = True self.quick_preview_allowed = True

View File

@ -41,7 +41,7 @@ above, like so::
class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
def __init__(self, parent=None): def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent) super(AuthorsForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality, This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality,

View File

@ -42,7 +42,7 @@ class AddGroupForm(QtGui.QDialog, Ui_AddGroupDialog):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, parent) super(AddGroupForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
def exec_(self, clear=True, show_top_level_group=False, selected_group=None): def exec_(self, clear=True, show_top_level_group=False, selected_group=None):

View File

@ -40,7 +40,7 @@ class ChooseGroupForm(QtGui.QDialog, Ui_ChooseGroupDialog):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, parent) super(ChooseGroupForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
def exec_(self, selected_group=None): def exec_(self, selected_group=None):

View File

@ -48,7 +48,7 @@ class ImagePlugin(Plugin):
log.info(u'Image Plugin loaded') log.info(u'Image Plugin loaded')
def __init__(self): def __init__(self):
Plugin.__init__(self, u'images', __default_settings__, ImageMediaItem, ImageTab) super(ImagePlugin, self).__init__(u'images', __default_settings__, ImageMediaItem, ImageTab)
self.manager = Manager(u'images', init_schema) self.manager = Manager(u'images', init_schema)
self.weight = -7 self.weight = -7
self.icon_path = u':/plugins/plugin_images.png' self.icon_path = u':/plugins/plugin_images.png'

View File

@ -37,11 +37,11 @@ class ImageTab(SettingsTab):
ImageTab is the images settings tab in the settings dialog. ImageTab is the images settings tab in the settings dialog.
""" """
def __init__(self, parent, name, visible_title, icon_path): def __init__(self, parent, name, visible_title, icon_path):
SettingsTab.__init__(self, parent, name, visible_title, icon_path) super(ImageTab, self).__init__(parent, name, visible_title, icon_path)
def setupUi(self): def setupUi(self):
self.setObjectName(u'ImagesTab') self.setObjectName(u'ImagesTab')
SettingsTab.setupUi(self) super(ImageTab, self).setupUi()
self.background_color_group_box = QtGui.QGroupBox(self.left_column) self.background_color_group_box = QtGui.QGroupBox(self.left_column)
self.background_color_group_box.setObjectName(u'background_color_group_box') self.background_color_group_box.setObjectName(u'background_color_group_box')
self.form_layout = QtGui.QFormLayout(self.background_color_group_box) self.form_layout = QtGui.QFormLayout(self.background_color_group_box)

View File

@ -52,7 +52,7 @@ class ImageMediaItem(MediaManagerItem):
def __init__(self, parent, plugin): def __init__(self, parent, plugin):
self.icon_path = u'images/image' self.icon_path = u'images/image'
MediaManagerItem.__init__(self, parent, plugin) super(ImageMediaItem, self).__init__(parent, plugin)
self.quick_preview_allowed = True self.quick_preview_allowed = True
self.has_search = True self.has_search = True
self.manager = plugin.manager self.manager = plugin.manager

View File

@ -60,7 +60,7 @@ class MediaMediaItem(MediaManagerItem):
self.icon_path = u'images/image' self.icon_path = u'images/image'
self.background = False self.background = False
self.automatic = u'' self.automatic = u''
MediaManagerItem.__init__(self, parent, plugin) super(MediaMediaItem, self).__init__(parent, plugin)
self.single_service_item = False self.single_service_item = False
self.has_search = True self.has_search = True
self.media_object = None self.media_object = None

View File

@ -46,11 +46,11 @@ class MediaTab(SettingsTab):
""" """
def __init__(self, parent, title, visible_title, icon_path): def __init__(self, parent, title, visible_title, icon_path):
self.parent = parent self.parent = parent
SettingsTab.__init__(self, parent, title, visible_title, icon_path) super(MediaTab, self).__init__(parent, title, visible_title, icon_path)
def setupUi(self): def setupUi(self):
self.setObjectName(u'MediaTab') self.setObjectName(u'MediaTab')
SettingsTab.setupUi(self) super(MediaTab, self).setupUi()
self.advanced_group_box = QtGui.QGroupBox(self.left_column) self.advanced_group_box = QtGui.QGroupBox(self.left_column)
self.advanced_group_box.setObjectName(u'advanced_group_box') self.advanced_group_box.setObjectName(u'advanced_group_box')
self.advanced_layout = QtGui.QVBoxLayout(self.advanced_group_box) self.advanced_layout = QtGui.QVBoxLayout(self.advanced_group_box)

View File

@ -49,7 +49,7 @@ class MediaPlugin(Plugin):
log.info(u'%s MediaPlugin loaded', __name__) log.info(u'%s MediaPlugin loaded', __name__)
def __init__(self): def __init__(self):
Plugin.__init__(self, u'media', __default_settings__, MediaMediaItem) super(MediaPlugin, self).__init__(u'media', __default_settings__, MediaMediaItem)
self.weight = -6 self.weight = -6
self.icon_path = u':/plugins/plugin_media.png' self.icon_path = u':/plugins/plugin_media.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)

View File

@ -78,7 +78,7 @@ class ImpressController(PresentationController):
Initialise the class Initialise the class
""" """
log.debug(u'Initialising') log.debug(u'Initialising')
PresentationController.__init__(self, plugin, u'Impress', ImpressDocument) super(ImpressController, self).__init__(plugin, u'Impress', ImpressDocument)
self.supports = [u'odp'] self.supports = [u'odp']
self.also_supports = [u'ppt', u'pps', u'pptx', u'ppsx'] self.also_supports = [u'ppt', u'pps', u'pptx', u'ppsx']
self.process = None self.process = None
@ -208,7 +208,7 @@ class ImpressDocument(PresentationDocument):
Constructor, store information about the file and initialise. Constructor, store information about the file and initialise.
""" """
log.debug(u'Init Presentation OpenOffice') log.debug(u'Init Presentation OpenOffice')
PresentationDocument.__init__(self, controller, presentation) super(ImpressDocument, self).__init__(controller, presentation)
self.document = None self.document = None
self.presentation = None self.presentation = None
self.control = None self.control = None

View File

@ -58,7 +58,7 @@ class PowerpointController(PresentationController):
Initialise the class Initialise the class
""" """
log.debug(u'Initialising') log.debug(u'Initialising')
PresentationController.__init__(self, plugin, u'Powerpoint', PowerpointDocument) super(PowerpointController, self).__init__(plugin, u'Powerpoint', PowerpointDocument)
self.supports = [u'ppt', u'pps', u'pptx', u'ppsx'] self.supports = [u'ppt', u'pps', u'pptx', u'ppsx']
self.process = None self.process = None
@ -114,7 +114,7 @@ class PowerpointDocument(PresentationDocument):
Constructor, store information about the file and initialise. Constructor, store information about the file and initialise.
""" """
log.debug(u'Init Presentation Powerpoint') log.debug(u'Init Presentation Powerpoint')
PresentationDocument.__init__(self, controller, presentation) super(PowerpointDocument, self).__init__(controller, presentation)
self.presentation = None self.presentation = None
def load_presentation(self): def load_presentation(self):

View File

@ -54,7 +54,7 @@ class PptviewController(PresentationController):
""" """
log.debug(u'Initialising') log.debug(u'Initialising')
self.process = None self.process = None
PresentationController.__init__(self, plugin, u'Powerpoint Viewer', PptviewDocument) super(PptviewController, self).__init__(plugin, u'Powerpoint Viewer', PptviewDocument)
self.supports = [u'ppt', u'pps', u'pptx', u'ppsx'] self.supports = [u'ppt', u'pps', u'pptx', u'ppsx']
def check_available(self): def check_available(self):
@ -109,7 +109,7 @@ class PptviewDocument(PresentationDocument):
Constructor, store information about the file and initialise. Constructor, store information about the file and initialise.
""" """
log.debug(u'Init Presentation PowerPoint') log.debug(u'Init Presentation PowerPoint')
PresentationDocument.__init__(self, controller, presentation) super(PptviewDocument, self).__init__(controller, presentation)
self.presentation = None self.presentation = None
self.ppt_id = None self.ppt_id = None
self.blanked = False self.blanked = False

View File

@ -37,7 +37,7 @@ class PPTViewer(QtGui.QWidget):
Standalone Test Harness for the pptviewlib library Standalone Test Harness for the pptviewlib library
""" """
def __init__(self, parent=None): def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent) super(PPTViewer, self).__init__(parent)
self.pptid = -1 self.pptid = -1
self.setWindowTitle(u'PowerPoint Viewer Test') self.setWindowTitle(u'PowerPoint Viewer Test')

View File

@ -42,7 +42,7 @@ class PresentationTab(SettingsTab):
""" """
self.parent = parent self.parent = parent
self.controllers = controllers self.controllers = controllers
SettingsTab.__init__(self, parent, title, visible_title, icon_path) super(PresentationTab, self).__init__(parent, title, visible_title, icon_path)
self.activated = False self.activated = False
def setupUi(self): def setupUi(self):
@ -50,7 +50,7 @@ class PresentationTab(SettingsTab):
Create the controls for the settings tab Create the controls for the settings tab
""" """
self.setObjectName(u'PresentationTab') self.setObjectName(u'PresentationTab')
SettingsTab.setupUi(self) super(PresentationTab, self).setupUi()
self.controllers_group_box = QtGui.QGroupBox(self.left_column) self.controllers_group_box = QtGui.QGroupBox(self.left_column)
self.controllers_group_box.setObjectName(u'controllers_group_box') self.controllers_group_box.setObjectName(u'controllers_group_box')
self.controllers_layout = QtGui.QVBoxLayout(self.controllers_group_box) self.controllers_layout = QtGui.QVBoxLayout(self.controllers_group_box)

View File

@ -82,7 +82,7 @@ class PresentationPlugin(Plugin):
Initialise the plugin. Determine which controllers are enabled are start their processes. Initialise the plugin. Determine which controllers are enabled are start their processes.
""" """
log.info(u'Presentations Initialising') log.info(u'Presentations Initialising')
Plugin.initialise(self) super(PresentationPlugin, self).initialise()
for controller in self.controllers: for controller in self.controllers:
if self.controllers[controller].enabled(): if self.controllers[controller].enabled():
try: try:
@ -103,7 +103,7 @@ class PresentationPlugin(Plugin):
controller = self.controllers[key] controller = self.controllers[key]
if controller.enabled(): if controller.enabled():
controller.kill() controller.kill()
Plugin.finalise(self) super(PresentationPlugin, self).finalise()
def create_media_manager_item(self): def create_media_manager_item(self):
""" """

View File

@ -127,7 +127,7 @@ from PyQt4 import QtCore
from openlp.core.lib import Registry, Settings, PluginStatus, StringContent, image_to_byte from openlp.core.lib import Registry, Settings, PluginStatus, StringContent, image_to_byte
from openlp.core.utils import AppLocation, translate from openlp.core.utils import AppLocation, translate
from cherrypy._cpcompat import sha, ntob from hashlib import sha1
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -137,7 +137,7 @@ def make_sha_hash(password):
Create an encrypted password for the given password. Create an encrypted password for the given password.
""" """
log.debug("make_sha_hash") log.debug("make_sha_hash")
return sha(ntob(password)).hexdigest() return sha1(password.encode()).hexdigest()
def fetch_password(username): def fetch_password(username):
@ -445,7 +445,7 @@ class HttpRouter(object):
u'display': self.live_controller.desktop_screen.isChecked() u'display': self.live_controller.desktop_screen.isChecked()
} }
cherrypy.response.headers['Content-Type'] = u'application/json' cherrypy.response.headers['Content-Type'] = u'application/json'
return json.dumps({u'results': result}) return json.dumps({u'results': result}).encode()
def main_poll(self): def main_poll(self):
""" """
@ -455,7 +455,7 @@ class HttpRouter(object):
u'slide_count': self.live_controller.slide_count u'slide_count': self.live_controller.slide_count
} }
cherrypy.response.headers['Content-Type'] = u'application/json' cherrypy.response.headers['Content-Type'] = u'application/json'
return json.dumps({u'results': result}) return json.dumps({u'results': result}).encode()
def main_image(self): def main_image(self):
""" """
@ -465,7 +465,7 @@ class HttpRouter(object):
u'slide_image': u'data:image/png;base64,' + str(image_to_byte(self.live_controller.slide_image)) u'slide_image': u'data:image/png;base64,' + str(image_to_byte(self.live_controller.slide_image))
} }
cherrypy.response.headers['Content-Type'] = u'application/json' cherrypy.response.headers['Content-Type'] = u'application/json'
return json.dumps({u'results': result}) return json.dumps({u'results': result}).encode()
def display(self, action): def display(self, action):
""" """
@ -477,7 +477,7 @@ class HttpRouter(object):
""" """
self.live_controller.emit(QtCore.SIGNAL(u'slidecontroller_toggle_display'), action) self.live_controller.emit(QtCore.SIGNAL(u'slidecontroller_toggle_display'), action)
cherrypy.response.headers['Content-Type'] = u'application/json' cherrypy.response.headers['Content-Type'] = u'application/json'
return json.dumps({u'results': {u'success': True}}) return json.dumps({u'results': {u'success': True}}).encode()
def alert(self): def alert(self):
""" """
@ -495,7 +495,7 @@ class HttpRouter(object):
else: else:
success = False success = False
cherrypy.response.headers['Content-Type'] = u'application/json' cherrypy.response.headers['Content-Type'] = u'application/json'
return json.dumps({u'results': {u'success': success}}) return json.dumps({u'results': {u'success': success}}).encode()
def controller(self, display_type, action): def controller(self, display_type, action):
""" """
@ -543,7 +543,7 @@ class HttpRouter(object):
self.live_controller.emit(QtCore.SIGNAL(event)) self.live_controller.emit(QtCore.SIGNAL(event))
json_data = {u'results': {u'success': True}} json_data = {u'results': {u'success': True}}
cherrypy.response.headers['Content-Type'] = u'application/json' cherrypy.response.headers['Content-Type'] = u'application/json'
return json.dumps(json_data) return json.dumps(json_data).encode()
def service(self, action): def service(self, action):
""" """
@ -555,7 +555,7 @@ class HttpRouter(object):
event = u'servicemanager_%s' % action event = u'servicemanager_%s' % action
if action == u'list': if action == u'list':
cherrypy.response.headers['Content-Type'] = u'application/json' cherrypy.response.headers['Content-Type'] = u'application/json'
return json.dumps({u'results': {u'items': self._get_service_items()}}) return json.dumps({u'results': {u'items': self._get_service_items()}}).encode()
event += u'_item' event += u'_item'
if self.request_data: if self.request_data:
try: try:
@ -566,7 +566,7 @@ class HttpRouter(object):
else: else:
Registry().execute(event) Registry().execute(event)
cherrypy.response.headers['Content-Type'] = u'application/json' cherrypy.response.headers['Content-Type'] = u'application/json'
return json.dumps({u'results': {u'success': True}}) return json.dumps({u'results': {u'success': True}}).encode()
def plugin_info(self, action): def plugin_info(self, action):
""" """
@ -582,7 +582,7 @@ class HttpRouter(object):
if plugin.status == PluginStatus.Active and plugin.media_item and plugin.media_item.has_search: if plugin.status == PluginStatus.Active and plugin.media_item and plugin.media_item.has_search:
searches.append([plugin.name, unicode(plugin.text_strings[StringContent.Name][u'plural'])]) searches.append([plugin.name, unicode(plugin.text_strings[StringContent.Name][u'plural'])])
cherrypy.response.headers['Content-Type'] = u'application/json' cherrypy.response.headers['Content-Type'] = u'application/json'
return json.dumps({u'results': {u'items': searches}}) return json.dumps({u'results': {u'items': searches}}).encode()
def search(self, plugin_name): def search(self, plugin_name):
""" """
@ -602,7 +602,7 @@ class HttpRouter(object):
else: else:
results = [] results = []
cherrypy.response.headers['Content-Type'] = u'application/json' cherrypy.response.headers['Content-Type'] = u'application/json'
return json.dumps({u'results': {u'items': results}}) return json.dumps({u'results': {u'items': results}}).encode()
def go_live(self, plugin_name): def go_live(self, plugin_name):
""" """
@ -648,7 +648,7 @@ class HttpRouter(object):
Set the HTTP not found return code. Set the HTTP not found return code.
""" """
cherrypy.response.status = 404 cherrypy.response.status = 404
cherrypy.response.body = ["<html><body>Sorry, an error occurred </body></html>"] cherrypy.response.body = [b'<html><body>Sorry, an error occurred </body></html>']
def _get_service_manager(self): def _get_service_manager(self):
""" """

View File

@ -43,11 +43,11 @@ class RemoteTab(SettingsTab):
RemoteTab is the Remotes settings tab in the settings dialog. RemoteTab is the Remotes settings tab in the settings dialog.
""" """
def __init__(self, parent, title, visible_title, icon_path): def __init__(self, parent, title, visible_title, icon_path):
SettingsTab.__init__(self, parent, title, visible_title, icon_path) super(RemoteTab, self).__init__(parent, title, visible_title, icon_path)
def setupUi(self): def setupUi(self):
self.setObjectName(u'RemoteTab') self.setObjectName(u'RemoteTab')
SettingsTab.setupUi(self) super(RemoteTab, self).setupUi()
self.server_settings_group_box = QtGui.QGroupBox(self.left_column) self.server_settings_group_box = QtGui.QGroupBox(self.left_column)
self.server_settings_group_box.setObjectName(u'server_settings_group_box') self.server_settings_group_box.setObjectName(u'server_settings_group_box')
self.server_settings_layout = QtGui.QFormLayout(self.server_settings_group_box) self.server_settings_layout = QtGui.QFormLayout(self.server_settings_group_box)

View File

@ -55,7 +55,7 @@ class RemotesPlugin(Plugin):
""" """
remotes constructor remotes constructor
""" """
Plugin.__init__(self, u'remotes', __default_settings__, settings_tab_class=RemoteTab) super(RemotesPlugin, self).__init__(u'remotes', __default_settings__, settings_tab_class=RemoteTab)
self.icon_path = u':/plugins/plugin_remote.png' self.icon_path = u':/plugins/plugin_remote.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
self.weight = -1 self.weight = -1
@ -66,7 +66,7 @@ class RemotesPlugin(Plugin):
Initialise the remotes plugin, and start the http server Initialise the remotes plugin, and start the http server
""" """
log.debug(u'initialise') log.debug(u'initialise')
Plugin.initialise(self) super(RemotesPlugin, self).initialise()
self.server = HttpServer() self.server = HttpServer()
self.server.start_server() self.server.start_server()
@ -75,7 +75,7 @@ class RemotesPlugin(Plugin):
Tidy up and close down the http server Tidy up and close down the http server
""" """
log.debug(u'finalise') log.debug(u'finalise')
Plugin.finalise(self) super(RemotesPlugin, self).finalise()
if self.server: if self.server:
self.server.close() self.server.close()
self.server = None self.server = None

View File

@ -45,7 +45,7 @@ mentioned above, like so::
class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
def __init__(self, parent=None): def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent) super(AuthorsForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
This allows OpenLP to use ``self.object`` for all the GUI elements while keeping This allows OpenLP to use ``self.object`` for all the GUI elements while keeping

View File

@ -42,7 +42,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
""" """
Set up the screen and common data Set up the screen and common data
""" """
QtGui.QDialog.__init__(self, parent) super(AuthorsForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
self.auto_display_name = False self.auto_display_name = False
self.first_name_edit.textEdited.connect(self.on_first_name_edited) self.first_name_edit.textEdited.connect(self.on_first_name_edited)

View File

@ -67,8 +67,8 @@ class DuplicateSongRemovalForm(OpenLPWizard):
self.review_total_count = 0 self.review_total_count = 0
# Used to interrupt ongoing searches when cancel is clicked. # Used to interrupt ongoing searches when cancel is clicked.
self.break_search = False self.break_search = False
OpenLPWizard.__init__(self, self.main_window, plugin, u'duplicateSongRemovalWizard', super(DuplicateSongRemovalForm, self).__init__(Registry().get('main_window'),
u':/wizards/wizard_duplicateremoval.bmp', False) plugin, u'duplicateSongRemovalWizard', u':/wizards/wizard_duplicateremoval.bmp', False)
self.setMinimumWidth(730) self.setMinimumWidth(730)
def custom_signals(self): def custom_signals(self):
@ -269,7 +269,7 @@ class DuplicateSongRemovalForm(OpenLPWizard):
else: else:
self.proceed_to_next_review() self.proceed_to_next_review()
return False return False
return OpenLPWizard.validateCurrentPage(self) return super(DuplicateSongRemovalForm, self).validateCurrentPage()
def remove_button_clicked(self, song_review_widget): def remove_button_clicked(self, song_review_widget):
""" """
@ -312,7 +312,7 @@ class DuplicateSongRemovalForm(OpenLPWizard):
self.review_scroll_area_layout.removeItem(item) self.review_scroll_area_layout.removeItem(item)
# Process next set of duplicates. # Process next set of duplicates.
self.process_current_duplicate_entry() self.process_current_duplicate_entry()
def process_current_duplicate_entry(self): def process_current_duplicate_entry(self):
""" """
Update the review counter in the wizard header, add song widgets for Update the review counter in the wizard header, add song widgets for
@ -359,4 +359,5 @@ class DuplicateSongRemovalForm(OpenLPWizard):
self._application = Registry().get(u'application') self._application = Registry().get(u'application')
return self._application return self._application
application = property(_get_application) application = property(_get_application)

View File

@ -355,7 +355,7 @@ class SingleColumnTableWidget(QtGui.QTableWidget):
""" """
Constructor Constructor
""" """
QtGui.QTableWidget.__init__(self, parent) super(SingleColumnTableWidget, self).__init__(parent)
self.horizontalHeader().setVisible(False) self.horizontalHeader().setVisible(False)
self.setColumnCount(1) self.setColumnCount(1)

View File

@ -395,9 +395,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
# lazy xml migration for now # lazy xml migration for now
self.verse_list_widget.clear() self.verse_list_widget.clear()
self.verse_list_widget.setRowCount(0) self.verse_list_widget.setRowCount(0)
# This is just because occasionally the lyrics come back as a "buffer"
if isinstance(self.song.lyrics, buffer):
self.song.lyrics = unicode(self.song.lyrics)
verse_tags_translated = False verse_tags_translated = False
if self.song.lyrics.startswith(u'<?xml version='): if self.song.lyrics.startswith(u'<?xml version='):
songXML = SongXML() songXML = SongXML()

View File

@ -48,7 +48,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
""" """
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, parent) super(EditVerseForm, self).__init__(parent)
self.setupUi(self) self.setupUi(self)
self.verse_text_edit.customContextMenuRequested.connect(self.context_menu) self.verse_text_edit.customContextMenuRequested.connect(self.context_menu)
self.insert_button.clicked.connect(self.on_insert_button_clicked) self.insert_button.clicked.connect(self.on_insert_button_clicked)

View File

@ -44,7 +44,7 @@ class MediaFilesForm(QtGui.QDialog, Ui_MediaFilesDialog):
log.info(u'%s MediaFilesForm loaded', __name__) log.info(u'%s MediaFilesForm loaded', __name__)
def __init__(self, parent): def __init__(self, parent):
QtGui.QDialog.__init__(self) super(MediaFilesForm, self).__init__()
self.setupUi(self) self.setupUi(self)
def populateFiles(self, files): def populateFiles(self, files):

View File

@ -60,7 +60,7 @@ class SongExportForm(OpenLPWizard):
``plugin`` ``plugin``
The songs plugin. The songs plugin.
""" """
OpenLPWizard.__init__(self, parent, plugin, u'song_export_wizard', u':/wizards/wizard_exportsong.bmp') super(SongExportForm, self).__init__(parent, plugin, u'song_export_wizard', u':/wizards/wizard_exportsong.bmp')
self.stop_export_flag = False self.stop_export_flag = False
Registry().register_function(u'openlp_stop_wizard', self.stop_export) Registry().register_function(u'openlp_stop_wizard', self.stop_export)
@ -75,7 +75,7 @@ class SongExportForm(OpenLPWizard):
""" """
Set up the song wizard UI. Set up the song wizard UI.
""" """
OpenLPWizard.setupUi(self, image) super(SongExportForm, self).setupUi(image)
def custom_signals(self): def custom_signals(self):
""" """
@ -239,7 +239,7 @@ class SongExportForm(OpenLPWizard):
""" """
Perform pre export tasks. Perform pre export tasks.
""" """
OpenLPWizard.pre_wizard(self) super(SongExportForm, self).pre_wizard()
self.progress_label.setText(translate('SongsPlugin.ExportWizardForm', 'Starting export...')) self.progress_label.setText(translate('SongsPlugin.ExportWizardForm', 'Starting export...'))
self.application.process_events() self.application.process_events()

View File

@ -60,15 +60,15 @@ class SongImportForm(OpenLPWizard):
``plugin`` ``plugin``
The songs plugin. The songs plugin.
""" """
super(SongImportForm, self).__init__(parent, plugin, u'songImportWizard', u':/wizards/wizard_importsong.bmp')
self.clipboard = self.main_window.clipboard self.clipboard = self.main_window.clipboard
OpenLPWizard.__init__(self, parent, plugin, u'songImportWizard', u':/wizards/wizard_importsong.bmp')
def setupUi(self, image): def setupUi(self, image):
""" """
Set up the song wizard UI. Set up the song wizard UI.
""" """
self.format_widgets = dict([(song_format, {}) for song_format in SongFormat.get_format_list()]) self.format_widgets = dict([(song_format, {}) for song_format in SongFormat.get_format_list()])
OpenLPWizard.setupUi(self, image) super(SongImportForm, self).setupUi(image)
self.current_format = SongFormat.OpenLyrics self.current_format = SongFormat.OpenLyrics
self.format_stack.setCurrentIndex(self.current_format) self.format_stack.setCurrentIndex(self.current_format)
self.format_combo_box.currentIndexChanged.connect(self.onCurrentIndexChanged) self.format_combo_box.currentIndexChanged.connect(self.onCurrentIndexChanged)
@ -329,7 +329,7 @@ class SongImportForm(OpenLPWizard):
""" """
Perform pre import tasks Perform pre import tasks
""" """
OpenLPWizard.pre_wizard(self) super(SongImportForm, self).pre_wizard()
self.progress_label.setText(WizardStrings.StartingImport) self.progress_label.setText(WizardStrings.StartingImport)
self.application.process_events() self.application.process_events()

View File

@ -64,7 +64,7 @@ class SongReviewWidget(QtGui.QWidget):
``song`` ``song``
The Song which this SongReviewWidget should represent. The Song which this SongReviewWidget should represent.
""" """
QtGui.QWidget.__init__(self, parent) super(SongReviewWidget, self).__init__(parent)
self.song = song self.song = song
self.setupUi() self.setupUi()
self.retranslateUi() self.retranslateUi()

View File

@ -395,12 +395,6 @@ def clean_song(manager, song):
""" """
from xml import SongXML from xml import SongXML
if isinstance(song.title, buffer):
song.title = unicode(song.title)
if isinstance(song.alternate_title, buffer):
song.alternate_title = unicode(song.alternate_title)
if isinstance(song.lyrics, buffer):
song.lyrics = unicode(song.lyrics)
if song.title: if song.title:
song.title = clean_title(song.title) song.title = clean_title(song.title)
else: else:

View File

@ -68,7 +68,7 @@ class Song(BaseModel):
Song model Song model
""" """
def __init__(self): def __init__(self):
self.sort_key = () self.sort_key = []
@reconstructor @reconstructor
def init_on_load(self): def init_on_load(self):

View File

@ -100,12 +100,11 @@ class DreamBeamImport(SongImport):
log.exception(u'XML syntax error in file %s' % file) log.exception(u'XML syntax error in file %s' % file)
self.logError(file, SongStrings.XMLSyntaxError) self.logError(file, SongStrings.XMLSyntaxError)
continue continue
xml = unicode(etree.tostring(parsed_file)) xml = etree.tostring(parsed_file).decode()
song_xml = objectify.fromstring(xml) song_xml = objectify.fromstring(xml)
if song_xml.tag != u'DreamSong': if song_xml.tag != u'DreamSong':
self.logError(file, unicode( self.logError(file,
translate('SongsPlugin.DreamBeamImport', translate('SongsPlugin.DreamBeamImport', 'Invalid DreamBeam song file. Missing DreamSong tag.'))
('Invalid DreamBeam song file. Missing DreamSong tag.'))))
continue continue
if hasattr(song_xml, u'Version'): if hasattr(song_xml, u'Version'):
self.version = float(song_xml.Version.text) self.version = float(song_xml.Version.text)

View File

@ -54,7 +54,7 @@ class EasySlidesImport(SongImport):
log.info(u'Importing EasySlides XML file %s', self.import_source) log.info(u'Importing EasySlides XML file %s', self.import_source)
parser = etree.XMLParser(remove_blank_text=True) parser = etree.XMLParser(remove_blank_text=True)
parsed_file = etree.parse(self.import_source, parser) parsed_file = etree.parse(self.import_source, parser)
xml = unicode(etree.tostring(parsed_file)) xml = etree.tostring(parsed_file).decode()
song_xml = objectify.fromstring(xml) song_xml = objectify.fromstring(xml)
self.import_wizard.progress_bar.setMaximum(len(song_xml.Item)) self.import_wizard.progress_bar.setMaximum(len(song_xml.Item))
for song in song_xml.Item: for song in song_xml.Item:

View File

@ -274,7 +274,7 @@ class EasyWorshipSongImport(SongImport):
return None return None
# Format the field depending on the field type # Format the field depending on the field type
if field_desc.field_type == FieldType.String: if field_desc.field_type == FieldType.String:
return field.rstrip('\0').decode(self.encoding) return field.rstrip('\0')
elif field_desc.field_type == FieldType.Int16: elif field_desc.field_type == FieldType.Int16:
return field ^ 0x8000 return field ^ 0x8000
elif field_desc.field_type == FieldType.Int32: elif field_desc.field_type == FieldType.Int32:

View File

@ -127,11 +127,10 @@ class FoilPresenterImport(SongImport):
for file_path in self.import_source: for file_path in self.import_source:
if self.stop_import_flag: if self.stop_import_flag:
return return
self.import_wizard.increment_progress_bar( self.import_wizard.increment_progress_bar(WizardStrings.ImportingType % os.path.basename(file_path))
WizardStrings.ImportingType % os.path.basename(file_path))
try: try:
parsed_file = etree.parse(file_path, parser) parsed_file = etree.parse(file_path, parser)
xml = unicode(etree.tostring(parsed_file)) xml = etree.tostring(parsed_file).decode()
self.FoilPresenter.xml_to_song(xml) self.FoilPresenter.xml_to_song(xml)
except etree.XMLSyntaxError: except etree.XMLSyntaxError:
self.logError(file_path, SongStrings.XMLSyntaxError) self.logError(file_path, SongStrings.XMLSyntaxError)

View File

@ -71,7 +71,7 @@ class SongMediaItem(MediaManagerItem):
def __init__(self, parent, plugin): def __init__(self, parent, plugin):
self.icon_path = u'songs/song' self.icon_path = u'songs/song'
MediaManagerItem.__init__(self, parent, plugin) super(SongMediaItem, self).__init__(parent, plugin)
self.single_service_item = False self.single_service_item = False
# Holds information about whether the edit is remotely triggered and which Song is required. # Holds information about whether the edit is remotely triggered and which Song is required.
self.remote_song = -1 self.remote_song = -1

Some files were not shown because too many files have changed in this diff Show More