From 201dc353ff2a9a35869c56ff0309ab59f9c4effa Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Tue, 23 Jul 2013 20:30:47 +0100 Subject: [PATCH 01/36] Fixed bug 1174039 --- .../plugins/songs/lib/foilpresenterimport.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index fc9afd602..bb22bb52e 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -96,6 +96,7 @@ import os from lxml import etree, objectify +from openlp.core.lib import translate from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import clean_song, VerseType from openlp.plugins.songs.lib.songimport import SongImport @@ -115,7 +116,7 @@ class FoilPresenterImport(SongImport): """ log.debug(u'initialise FoilPresenterImport') SongImport.__init__(self, manager, **kwargs) - self.FoilPresenter = FoilPresenter(self.manager) + self.FoilPresenter = FoilPresenter(self.manager, self) def doImport(self): """ @@ -202,8 +203,9 @@ class FoilPresenter(object): tag. """ - def __init__(self, manager): + def __init__(self, manager, importer): self.manager = manager + self.importer = importer def xml_to_song(self, xml): """ @@ -222,6 +224,7 @@ class FoilPresenter(object): song.search_lyrics = u'' song.verse_order = u'' song.search_title = u'' + self.skip_song = False # Because "text" seems to be an reserverd word, we have to recompile it. xml = re.compile(u'').sub(u'', xml) xml = re.compile(u'').sub(u'', xml) @@ -236,8 +239,9 @@ class FoilPresenter(object): self._process_authors(foilpresenterfolie, song) self._process_songbooks(foilpresenterfolie, song) self._process_topics(foilpresenterfolie, song) - clean_song(self.manager, song) - self.manager.save_object(song) + if not self.skip_song: + clean_song(self.manager, song) + self.manager.save_object(song) def _child(self, element): """ @@ -424,6 +428,12 @@ class FoilPresenter(object): VerseType.Tags[VerseType.Intro]: 1, VerseType.Tags[VerseType.PreChorus]: 1 } + if not hasattr(foilpresenterfolie.strophen, u'strophe'): + self.importer.logError(self._child(foilpresenterfolie.titel), + unicode(translate('SongsPlugin.FoilPresenterSongImport', + 'Invalid Foilpresenter song file. No verses found.'))) + self.skip_song = True + return for strophe in foilpresenterfolie.strophen.strophe: text = self._child(strophe.text_) if hasattr(strophe, u'text_') \ else u'' From 4e3b92516da9274068c9b2210dd670b14d40ceaa Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Wed, 24 Jul 2013 19:41:38 +0100 Subject: [PATCH 02/36] changed skip_song to save_song --- openlp/plugins/songs/lib/foilpresenterimport.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index bb22bb52e..ffc306ac8 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -224,7 +224,7 @@ class FoilPresenter(object): song.search_lyrics = u'' song.verse_order = u'' song.search_title = u'' - self.skip_song = False + self.save_song = False # Because "text" seems to be an reserverd word, we have to recompile it. xml = re.compile(u'').sub(u'', xml) xml = re.compile(u'').sub(u'', xml) @@ -239,7 +239,7 @@ class FoilPresenter(object): self._process_authors(foilpresenterfolie, song) self._process_songbooks(foilpresenterfolie, song) self._process_topics(foilpresenterfolie, song) - if not self.skip_song: + if not self.save_song: clean_song(self.manager, song) self.manager.save_object(song) @@ -432,7 +432,7 @@ class FoilPresenter(object): self.importer.logError(self._child(foilpresenterfolie.titel), unicode(translate('SongsPlugin.FoilPresenterSongImport', 'Invalid Foilpresenter song file. No verses found.'))) - self.skip_song = True + self.save_song = True return for strophe in foilpresenterfolie.strophen.strophe: text = self._child(strophe.text_) if hasattr(strophe, u'text_') \ From 257fa70ab45393367a7e92d30f2075edc5b8e69e Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Wed, 24 Jul 2013 21:05:36 +0100 Subject: [PATCH 03/36] fixed logic --- openlp/plugins/songs/lib/foilpresenterimport.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index ffc306ac8..1ac37e29d 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -224,7 +224,7 @@ class FoilPresenter(object): song.search_lyrics = u'' song.verse_order = u'' song.search_title = u'' - self.save_song = False + self.save_song = True # Because "text" seems to be an reserverd word, we have to recompile it. xml = re.compile(u'').sub(u'', xml) xml = re.compile(u'').sub(u'', xml) @@ -239,7 +239,7 @@ class FoilPresenter(object): self._process_authors(foilpresenterfolie, song) self._process_songbooks(foilpresenterfolie, song) self._process_topics(foilpresenterfolie, song) - if not self.save_song: + if self.save_song: clean_song(self.manager, song) self.manager.save_object(song) @@ -432,7 +432,7 @@ class FoilPresenter(object): self.importer.logError(self._child(foilpresenterfolie.titel), unicode(translate('SongsPlugin.FoilPresenterSongImport', 'Invalid Foilpresenter song file. No verses found.'))) - self.save_song = True + self.save_song = False return for strophe in foilpresenterfolie.strophen.strophe: text = self._child(strophe.text_) if hasattr(strophe, u'text_') \ From a7130ce666e82c2df9bbf036c9750cfc4faad08d Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Thu, 25 Jul 2013 19:58:09 +0100 Subject: [PATCH 04/36] fixed 1204629 in 2.0 also made it more robust by checking that the user selected a valid image file using the open dialog --- openlp/core/ui/themeform.py | 12 +++++++++++- openlp/core/utils/__init__.py | 15 +++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index b4440e038..3533a9aac 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -78,6 +78,10 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): QtCore.SIGNAL(u'clicked()'), self.onGradientEndButtonClicked) QtCore.QObject.connect(self.imageBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onImageBrowseButtonClicked) + + QtCore.QObject.connect(self.imageFileEdit, + QtCore.SIGNAL(u'editingFinished()'), self.onImageFileEditEditingFinished) + QtCore.QObject.connect(self.mainColorButton, QtCore.SIGNAL(u'clicked()'), self.onMainColorButtonClicked) QtCore.QObject.connect(self.outlineColorButton, @@ -233,7 +237,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): background_image = BackgroundType.to_string(BackgroundType.Image) if self.page(self.currentId()) == self.backgroundPage and \ self.theme.background_type == background_image and \ - is_not_image_file(self.imageFileEdit.text()): + is_not_image_file(self.theme.background_filename): QtGui.QMessageBox.critical(self, translate('OpenLP.ThemeWizard', 'Background Image Empty'), translate('OpenLP.ThemeWizard', 'You have not selected a ' @@ -545,6 +549,12 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.theme.background_filename = unicode(filename) self.setBackgroundPageValues() + def onImageFileEditEditingFinished(self): + """ + Background image path edited + """ + self.theme.background_filename = unicode(self.imageFileEdit.text()) + def onMainColorButtonClicked(self): self.theme.font_main_color = \ self._colorButton(self.theme.font_main_color) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index faef00a82..a33cd2604 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -371,15 +371,14 @@ def is_not_image_file(file_name): ``file_name`` File name to be checked. """ - if file_name.isEmpty(): - return True - else: - formats = [unicode(fmt).lower() - for fmt in QtGui.QImageReader.supportedImageFormats()] - file_part, file_extension = os.path.splitext(unicode(file_name)) - if file_extension[1:].lower() in formats and os.path.exists(file_name): - return False + if not file_name: return True + formats = [unicode(fmt).lower() + for fmt in QtGui.QImageReader.supportedImageFormats()] + file_part, file_extension = os.path.splitext(unicode(file_name)) + if file_extension[1:].lower() in formats and os.path.exists(file_name): + return False + return True def join_url(base, *args): """ From 06b5e7c55f6dcb1baf46cb000b25c5b193602664 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Thu, 25 Jul 2013 20:27:43 +0100 Subject: [PATCH 05/36] removed extra spaces --- openlp/core/ui/themeform.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 3533a9aac..7381e32e7 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -78,10 +78,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): QtCore.SIGNAL(u'clicked()'), self.onGradientEndButtonClicked) QtCore.QObject.connect(self.imageBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onImageBrowseButtonClicked) - QtCore.QObject.connect(self.imageFileEdit, QtCore.SIGNAL(u'editingFinished()'), self.onImageFileEditEditingFinished) - QtCore.QObject.connect(self.mainColorButton, QtCore.SIGNAL(u'clicked()'), self.onMainColorButtonClicked) QtCore.QObject.connect(self.outlineColorButton, From c3b703ec8a7d04cf7601fa120a1c9e0c67c3ed9c Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Fri, 2 Aug 2013 20:44:54 +0100 Subject: [PATCH 06/36] Fixes # 1194610 by detecting the encoding rather than assuming that its cp1252 --- .../plugins/songs/lib/songshowplusimport.py | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index 04fe10370..6edf089ff 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -30,6 +30,7 @@ The :mod:`songshowplusimport` module provides the functionality for importing SongShow Plus songs into the OpenLP database. """ +import chardet import os import logging import re @@ -142,44 +143,44 @@ class SongShowPlusImport(SongImport): log.debug(length_descriptor_size) data = song_data.read(length_descriptor) if block_key == TITLE: - self.title = unicode(data, u'cp1252') + self.title = unicode(data, chardet.detect(data)['encoding']) elif block_key == AUTHOR: authors = data.split(" / ") for author in authors: if author.find(",") !=-1: authorParts = author.split(", ") author = authorParts[1] + " " + authorParts[0] - self.parseAuthor(unicode(author, u'cp1252')) + self.parseAuthor(unicode(author, chardet.detect(data)['encoding'])) elif block_key == COPYRIGHT: - self.addCopyright(unicode(data, u'cp1252')) + self.addCopyright(unicode(data, chardet.detect(data)['encoding'])) elif block_key == CCLI_NO: self.ccliNumber = int(data) elif block_key == VERSE: - self.addVerse(unicode(data, u'cp1252'), + self.addVerse(unicode(data, chardet.detect(data)['encoding']), "%s%s" % (VerseType.Tags[VerseType.Verse], verse_no)) elif block_key == CHORUS: - self.addVerse(unicode(data, u'cp1252'), + self.addVerse(unicode(data, chardet.detect(data)['encoding']), "%s%s" % (VerseType.Tags[VerseType.Chorus], verse_no)) elif block_key == BRIDGE: - self.addVerse(unicode(data, u'cp1252'), + self.addVerse(unicode(data, chardet.detect(data)['encoding']), "%s%s" % (VerseType.Tags[VerseType.Bridge], verse_no)) elif block_key == TOPIC: - self.topics.append(unicode(data, u'cp1252')) + self.topics.append(unicode(data, chardet.detect(data)['encoding'])) elif block_key == COMMENTS: - self.comments = unicode(data, u'cp1252') + self.comments = unicode(data, chardet.detect(data)['encoding']) elif block_key == VERSE_ORDER: verse_tag = self.toOpenLPVerseTag(data, True) if verse_tag: if not isinstance(verse_tag, unicode): - verse_tag = unicode(verse_tag, u'cp1252') + verse_tag = unicode(verse_tag, chardet.detect(data)['encoding']) self.sspVerseOrderList.append(verse_tag) elif block_key == SONG_BOOK: - self.songBookName = unicode(data, u'cp1252') + self.songBookName = unicode(data, chardet.detect(data)['encoding']) elif block_key == SONG_NUMBER: self.songNumber = ord(data) elif block_key == CUSTOM_VERSE: verse_tag = self.toOpenLPVerseTag(verse_name) - self.addVerse(unicode(data, u'cp1252'), verse_tag) + self.addVerse(unicode(data, chardet.detect(data)['encoding']), verse_tag) else: log.debug("Unrecognised blockKey: %s, data: %s" % (block_key, data)) From a37ae5880f9c388f40da9e7381c0f5358e37eba0 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Fri, 2 Aug 2013 22:15:52 +0100 Subject: [PATCH 07/36] Fixes #1184869 Ensures that there is text in the anchor tag --- openlp/plugins/bibles/lib/http.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 214c427af..008857802 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -375,6 +375,7 @@ class BSExtract(object): content = content.findAll(u'li') return [ book.contents[0].contents[0] for book in content + if len(book.contents[0].contents) ] From 2c9910d6ad86f65af1cd7ec436cd738a9edd9969 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 3 Aug 2013 21:26:46 +0100 Subject: [PATCH 08/36] fixes 1194730 by returning None if the verse does not exist --- openlp/plugins/bibles/lib/http.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 214c427af..9f1a501e0 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -245,6 +245,8 @@ class BGExtract(object): return None Receiver.send_message(u'openlp_process_events') div = soup.find('div', 'result-text-style-normal') + if not div: + return None self._clean_soup(div) span_list = div.findAll('span', 'text') log.debug('Span list: %s', span_list) From fd64e241707596c23815c24326f02025f1d72564 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sun, 4 Aug 2013 13:11:30 +0100 Subject: [PATCH 09/36] Fixes #1096450 Stripping the leading and trailing spaces at the end rather than begginning (the space means something, see added comments) Semi-colons (;) denotes comments ONLY when it is the first char of the line ie the whole line is a comment Finally fixed an issue when a verse was being added to the verse order multiple times, thus repeating it over and over and .... --- openlp/plugins/songs/lib/opensongimport.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/songs/lib/opensongimport.py b/openlp/plugins/songs/lib/opensongimport.py index f39ad0495..00d6c89b0 100644 --- a/openlp/plugins/songs/lib/opensongimport.py +++ b/openlp/plugins/songs/lib/opensongimport.py @@ -49,6 +49,9 @@ class OpenSongImport(SongImport): the OpenSong web site. However, it doesn't describe the section, so here's an attempt: + If the first charachter of a line is a space, then the rest of that line + is lyrics. If it is not a space the following applies. + Verses can be expressed in one of 2 ways, either in complete verses, or by line grouping, i.e. grouping all line 1's of a verse together, all line 2's of a verse together, and so on. @@ -171,13 +174,11 @@ class OpenSongImport(SongImport): else: lyrics = u'' for this_line in lyrics.split(u'\n'): - # remove comments - semicolon = this_line.find(u';') - if semicolon >= 0: - this_line = this_line[:semicolon] - this_line = this_line.strip() if not this_line: continue + # skip this line if it is a comment + if this_line.startswith(u';'): + continue # skip guitar chords and page and column breaks if this_line.startswith(u'.') or this_line.startswith(u'---') \ or this_line.startswith(u'-!!'): @@ -212,7 +213,6 @@ class OpenSongImport(SongImport): if this_line[0].isdigit(): verse_num = this_line[0] this_line = this_line[1:].strip() - our_verse_order.append([verse_tag, verse_num, inst]) verses.setdefault(verse_tag, {}) verses[verse_tag].setdefault(verse_num, {}) if inst not in verses[verse_tag][verse_num]: @@ -222,6 +222,7 @@ class OpenSongImport(SongImport): this_line = self.tidyText(this_line) this_line = this_line.replace(u'_', u'') this_line = this_line.replace(u'|', u'\n') + this_line = this_line.strip() verses[verse_tag][verse_num][inst].append(this_line) # done parsing # add verses in original order From 03638ddea608878c9a78126ee2c031572b513287 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 10 Aug 2013 11:16:15 +0100 Subject: [PATCH 10/36] Fixes #1209515 by subclassing QFileDialog and attempting to urldecode any files not found --- openlp/core/lib/__init__.py | 1 + openlp/core/lib/filedialog.py | 59 ++++++++++++++++++++ openlp/core/lib/mediamanageritem.py | 4 +- openlp/core/lib/ui.py | 6 +- openlp/core/ui/thememanager.py | 4 +- openlp/core/utils/__init__.py | 1 - openlp/plugins/songs/forms/editsongform.py | 4 +- openlp/plugins/songs/forms/songimportform.py | 4 +- 8 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 openlp/core/lib/filedialog.py diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 4f0f78cd9..93d2dd953 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -384,6 +384,7 @@ def create_separated_list(stringlist): from eventreceiver import Receiver +from filedialog import FileDialog from listwidgetwithdnd import ListWidgetWithDnD from formattingtags import FormattingTags from spelltextedit import SpellTextEdit diff --git a/openlp/core/lib/filedialog.py b/openlp/core/lib/filedialog.py new file mode 100644 index 000000000..ffc8ec96d --- /dev/null +++ b/openlp/core/lib/filedialog.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2013 Raoul Snyman # +# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +""" +Provide a work around for a bug in QFileDialog (#1209515) +""" +import logging +import os +import urllib + +from PyQt4 import QtCore, QtGui + +from openlp.core.lib.ui import UiStrings + +log = logging.getLogger(__name__) + +class FileDialog(QtGui.QFileDialog): + def __init__(self): + QtGui.QFileDialog.__init__(self) + + def getOpenFileNames(self, parent, title, path, filters): + files = QtGui.QFileDialog.getOpenFileNames(parent, title, path, filters) + file_list = QtCore.QStringList() + for file in files: + if not os.path.exists(file): + file = urllib.unquote(unicode(file)) + if not os.path.exists(file): + QtGui.QMessageBox.information(self, + UiStrings().FNFT, + UiStrings().FNF % file) + continue + file_list.append(QtCore.QString(file)) + return file_list \ No newline at end of file diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 541206828..e31c3692c 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -35,7 +35,7 @@ import re from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \ +from openlp.core.lib import FileDialog, SettingsManager, OpenLPToolbar, ServiceItem, \ StringContent, build_icon, translate, Receiver, ListWidgetWithDnD from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings, create_widget_action, \ @@ -337,7 +337,7 @@ class MediaManagerItem(QtGui.QWidget): """ Add a file to the list widget to make it available for showing """ - files = QtGui.QFileDialog.getOpenFileNames( + files = FileDialog().getOpenFileNames( self, self.onNewPrompt, SettingsManager.get_last_dir(self.settingsSection), self.onNewFileMasks) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 5353d12f6..7d835998f 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -77,8 +77,12 @@ class UiStrings(object): self.Error = translate('OpenLP.Ui', 'Error') self.Export = translate('OpenLP.Ui', 'Export') self.File = translate('OpenLP.Ui', 'File') + self.FNFT = unicode(translate('OpenLP.Ui', + 'File Not Found')) + self.FNF = unicode(translate('OpenLP.Ui', + 'File %s not found.\nPlease try selecting it individually.')) self.FontSizePtUnit = translate('OpenLP.Ui', 'pt', - 'Abbreviated font pointsize unit') + 'Abbreviated font pointsize unit')ad self.Help = translate('OpenLP.Ui', 'Help') self.Hours = translate('OpenLP.Ui', 'h', 'The abbreviated unit for hours') diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 9804b3eca..84e7cb518 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -36,7 +36,7 @@ import re from xml.etree.ElementTree import ElementTree, XML from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, get_text_file_string, build_icon, \ +from openlp.core.lib import FileDialog, OpenLPToolbar, get_text_file_string, build_icon, \ Receiver, SettingsManager, translate, check_item_selected, \ check_directory_exists, create_thumb, validate_thumb, ImageSource from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, \ @@ -420,7 +420,7 @@ class ThemeManager(QtGui.QWidget): attempting to extract OpenLP themes from those files. This process will load both OpenLP version 1 and version 2 themes. """ - files = QtGui.QFileDialog.getOpenFileNames(self, + files = FileDialog().getOpenFileNames(self, translate('OpenLP.ThemeManager', 'Select Theme Import File'), SettingsManager.get_last_dir(self.settingsSection), unicode(translate('OpenLP.ThemeManager', diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index a33cd2604..031a0f1b3 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -150,7 +150,6 @@ class AppLocation(object): check_directory_exists(path) return path - def _get_os_dir_path(dir_type): """ Return a path based on which OS and environment we are running in. diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 7593e4a95..0803ee4e9 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -34,7 +34,7 @@ import shutil from PyQt4 import QtCore, QtGui -from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, \ +from openlp.core.lib import FileDialog, PluginStatus, Receiver, MediaType, translate, \ create_separated_list, check_directory_exists from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, \ critical_error_message_box, find_and_set_in_combo_box @@ -757,7 +757,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): Loads file(s) from the filesystem. """ filters = u'%s (*)' % UiStrings().AllFiles - filenames = QtGui.QFileDialog.getOpenFileNames(self, + filenames = FileDialog().getOpenFileNames(self, translate('SongsPlugin.EditSongForm', 'Open File(s)'), QtCore.QString(), filters) for filename in filenames: diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index e58137903..21e0b43fd 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -35,7 +35,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, SettingsManager, translate +from openlp.core.lib import FileDialog, Receiver, SettingsManager, translate from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.lib.settings import Settings from openlp.core.ui.wizard import OpenLPWizard, WizardStrings @@ -281,7 +281,7 @@ class SongImportForm(OpenLPWizard): if filters: filters += u';;' filters += u'%s (*)' % UiStrings().AllFiles - filenames = QtGui.QFileDialog.getOpenFileNames(self, title, + filenames = FileDialog().getOpenFileNames(self, title, SettingsManager.get_last_dir(self.plugin.settingsSection, 1), filters) if filenames: From 0e155daaf644463bc987225e689a6ab1f4b443c0 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 10 Aug 2013 21:40:12 +0100 Subject: [PATCH 11/36] removed __init__ as its not needed --- openlp/core/lib/filedialog.py | 3 --- openlp/core/lib/ui.py | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/openlp/core/lib/filedialog.py b/openlp/core/lib/filedialog.py index ffc8ec96d..36efb841b 100644 --- a/openlp/core/lib/filedialog.py +++ b/openlp/core/lib/filedialog.py @@ -41,9 +41,6 @@ from openlp.core.lib.ui import UiStrings log = logging.getLogger(__name__) class FileDialog(QtGui.QFileDialog): - def __init__(self): - QtGui.QFileDialog.__init__(self) - def getOpenFileNames(self, parent, title, path, filters): files = QtGui.QFileDialog.getOpenFileNames(parent, title, path, filters) file_list = QtCore.QStringList() diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 7d835998f..65b720787 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -82,7 +82,7 @@ class UiStrings(object): self.FNF = unicode(translate('OpenLP.Ui', 'File %s not found.\nPlease try selecting it individually.')) self.FontSizePtUnit = translate('OpenLP.Ui', 'pt', - 'Abbreviated font pointsize unit')ad + 'Abbreviated font pointsize unit') self.Help = translate('OpenLP.Ui', 'Help') self.Hours = translate('OpenLP.Ui', 'h', 'The abbreviated unit for hours') From d42364671eb576b2a4ad80b84525867b5209bda7 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sun, 11 Aug 2013 21:16:27 +0100 Subject: [PATCH 12/36] Changed to static metod --- openlp/core/lib/filedialog.py | 3 ++- openlp/core/lib/mediamanageritem.py | 2 +- openlp/core/ui/thememanager.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 2 +- openlp/plugins/songs/forms/songimportform.py | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/openlp/core/lib/filedialog.py b/openlp/core/lib/filedialog.py index 36efb841b..ba9f6661e 100644 --- a/openlp/core/lib/filedialog.py +++ b/openlp/core/lib/filedialog.py @@ -41,7 +41,8 @@ from openlp.core.lib.ui import UiStrings log = logging.getLogger(__name__) class FileDialog(QtGui.QFileDialog): - def getOpenFileNames(self, parent, title, path, filters): + @staticmethod + def getOpenFileNames(parent, title, path, filters): files = QtGui.QFileDialog.getOpenFileNames(parent, title, path, filters) file_list = QtCore.QStringList() for file in files: diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index e31c3692c..9fd589a12 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -337,7 +337,7 @@ class MediaManagerItem(QtGui.QWidget): """ Add a file to the list widget to make it available for showing """ - files = FileDialog().getOpenFileNames( + files = FileDialog.getOpenFileNames( self, self.onNewPrompt, SettingsManager.get_last_dir(self.settingsSection), self.onNewFileMasks) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 84e7cb518..9d53230a1 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -420,7 +420,7 @@ class ThemeManager(QtGui.QWidget): attempting to extract OpenLP themes from those files. This process will load both OpenLP version 1 and version 2 themes. """ - files = FileDialog().getOpenFileNames(self, + files = FileDialog.getOpenFileNames(self, translate('OpenLP.ThemeManager', 'Select Theme Import File'), SettingsManager.get_last_dir(self.settingsSection), unicode(translate('OpenLP.ThemeManager', diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 0803ee4e9..4774dab6b 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -757,7 +757,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): Loads file(s) from the filesystem. """ filters = u'%s (*)' % UiStrings().AllFiles - filenames = FileDialog().getOpenFileNames(self, + filenames = FileDialog.getOpenFileNames(self, translate('SongsPlugin.EditSongForm', 'Open File(s)'), QtCore.QString(), filters) for filename in filenames: diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 21e0b43fd..2db16abc5 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -281,7 +281,7 @@ class SongImportForm(OpenLPWizard): if filters: filters += u';;' filters += u'%s (*)' % UiStrings().AllFiles - filenames = FileDialog().getOpenFileNames(self, title, + filenames = FileDialog.getOpenFileNames(self, title, SettingsManager.get_last_dir(self.plugin.settingsSection, 1), filters) if filenames: From bc214ac9906f9bfdfc715589d93b7a8afbf4ae26 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Mon, 12 Aug 2013 19:19:57 +0100 Subject: [PATCH 13/36] Indented line to show continuation --- openlp/plugins/bibles/lib/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 008857802..99b85406f 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -375,7 +375,7 @@ class BSExtract(object): content = content.findAll(u'li') return [ book.contents[0].contents[0] for book in content - if len(book.contents[0].contents) + if len(book.contents[0].contents) ] From 12fb5ebd463456b6a9c1e40c9bea911c44a43bd9 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Tue, 13 Aug 2013 18:57:18 +0100 Subject: [PATCH 14/36] Need to encode filename to unicode --- openlp/core/lib/filedialog.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/filedialog.py b/openlp/core/lib/filedialog.py index ba9f6661e..0c2bd1005 100644 --- a/openlp/core/lib/filedialog.py +++ b/openlp/core/lib/filedialog.py @@ -46,8 +46,9 @@ class FileDialog(QtGui.QFileDialog): files = QtGui.QFileDialog.getOpenFileNames(parent, title, path, filters) file_list = QtCore.QStringList() for file in files: + file = unicode(file) if not os.path.exists(file): - file = urllib.unquote(unicode(file)) + file = urllib.unquote(file) if not os.path.exists(file): QtGui.QMessageBox.information(self, UiStrings().FNFT, From 711fa05dc157e229b39c34ad9d2c60ede31435df Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Tue, 13 Aug 2013 21:33:26 +0100 Subject: [PATCH 15/36] added option to select windows encoding --- .../plugins/songs/lib/songshowplusimport.py | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index 6edf089ff..abfa0a84e 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -37,7 +37,7 @@ import re import struct from openlp.core.ui.wizard import WizardStrings -from openlp.plugins.songs.lib import VerseType +from openlp.plugins.songs.lib import VerseType, retrieve_windows_encoding from openlp.plugins.songs.lib.songimport import SongImport TITLE = 1 @@ -143,44 +143,44 @@ class SongShowPlusImport(SongImport): log.debug(length_descriptor_size) data = song_data.read(length_descriptor) if block_key == TITLE: - self.title = unicode(data, chardet.detect(data)['encoding']) + self.title = self.decode(data) elif block_key == AUTHOR: authors = data.split(" / ") for author in authors: if author.find(",") !=-1: authorParts = author.split(", ") author = authorParts[1] + " " + authorParts[0] - self.parseAuthor(unicode(author, chardet.detect(data)['encoding'])) + self.parseAuthor(self.decode(author)) elif block_key == COPYRIGHT: - self.addCopyright(unicode(data, chardet.detect(data)['encoding'])) + self.addCopyright(self.decode(data)) elif block_key == CCLI_NO: self.ccliNumber = int(data) elif block_key == VERSE: - self.addVerse(unicode(data, chardet.detect(data)['encoding']), + self.addVerse(self.decode(data), "%s%s" % (VerseType.Tags[VerseType.Verse], verse_no)) elif block_key == CHORUS: - self.addVerse(unicode(data, chardet.detect(data)['encoding']), + self.addVerse(self.decode(data), "%s%s" % (VerseType.Tags[VerseType.Chorus], verse_no)) elif block_key == BRIDGE: - self.addVerse(unicode(data, chardet.detect(data)['encoding']), + self.addVerse(self.decode(data), "%s%s" % (VerseType.Tags[VerseType.Bridge], verse_no)) elif block_key == TOPIC: - self.topics.append(unicode(data, chardet.detect(data)['encoding'])) + self.topics.append(self.decode(data)) elif block_key == COMMENTS: - self.comments = unicode(data, chardet.detect(data)['encoding']) + self.comments = self.decode(data) elif block_key == VERSE_ORDER: verse_tag = self.toOpenLPVerseTag(data, True) if verse_tag: if not isinstance(verse_tag, unicode): - verse_tag = unicode(verse_tag, chardet.detect(data)['encoding']) + verse_tag = self.decode(verse_tag) self.sspVerseOrderList.append(verse_tag) elif block_key == SONG_BOOK: - self.songBookName = unicode(data, chardet.detect(data)['encoding']) + self.songBookName = self.decode(data) elif block_key == SONG_NUMBER: self.songNumber = ord(data) elif block_key == CUSTOM_VERSE: verse_tag = self.toOpenLPVerseTag(verse_name) - self.addVerse(unicode(data, chardet.detect(data)['encoding']), verse_tag) + self.addVerse(self.decode(data), verse_tag) else: log.debug("Unrecognised blockKey: %s, data: %s" % (block_key, data)) @@ -222,3 +222,13 @@ class SongShowPlusImport(SongImport): verse_tag = VerseType.Tags[VerseType.Other] verse_number = self.otherList[verse_name] return verse_tag + verse_number + + def decode(self, data): + try: + return unicode(data, chardet.detect(data)['encoding']) + except: + while True: + try: + return unicode(data, self.encoding) + except: + self.encoding = retrieve_windows_encoding() \ No newline at end of file From d724a6c87293ad54c586e7263b18dc48e58bef7f Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Wed, 14 Aug 2013 06:07:23 +0100 Subject: [PATCH 16/36] changed fallback to cp1252 --- openlp/plugins/songs/lib/songshowplusimport.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index abfa0a84e..aaa3b7ad9 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -227,8 +227,4 @@ class SongShowPlusImport(SongImport): try: return unicode(data, chardet.detect(data)['encoding']) except: - while True: - try: - return unicode(data, self.encoding) - except: - self.encoding = retrieve_windows_encoding() \ No newline at end of file + return unicode(data, u'cp1252') \ No newline at end of file From 1478636c97700ab8183247207537c827de59a0e9 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Wed, 14 Aug 2013 21:22:17 +0100 Subject: [PATCH 17/36] Fixes #1211913. The case can change of field names, so have taken that in to account by converting them to upper case --- openlp/plugins/songs/lib/sundayplusimport.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/songs/lib/sundayplusimport.py b/openlp/plugins/songs/lib/sundayplusimport.py index 9af6099e0..cd72cc564 100644 --- a/openlp/plugins/songs/lib/sundayplusimport.py +++ b/openlp/plugins/songs/lib/sundayplusimport.py @@ -96,7 +96,7 @@ class SundayPlusImport(SongImport): # Now we are looking for the name. if data[i:i + 1] == '#': name_end = data.find(':', i + 1) - name = data[i + 1:name_end] + name = data[i + 1:name_end].upper() i = name_end + 1 while data[i:i + 1] == ' ': i += 1 @@ -122,13 +122,13 @@ class SundayPlusImport(SongImport): value = data[i:end] # If we are in the main group. if cell == False: - if name == 'title': + if name == 'TITLE': self.title = self.decode(self.unescape(value)) - elif name == 'Author': + elif name == 'AUTHOR': author = self.decode(self.unescape(value)) if len(author): self.addAuthor(author) - elif name == 'Copyright': + elif name == 'COPYRIGHT': self.copyright = self.decode(self.unescape(value)) elif name[0:4] == 'CELL': self.parse(value, cell = name[4:]) @@ -142,13 +142,13 @@ class SundayPlusImport(SongImport): if len(value) >= 2 and value[-1] in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']: verse_type = "%s%s" % (verse_type, value[-1]) - elif name == 'Hotkey': + elif name == 'HOTKEY': # Hotkey always appears after MARKER_NAME, so it # effectively overrides MARKER_NAME, if present. if len(value) and \ value in HOTKEY_TO_VERSE_TYPE.keys(): verse_type = HOTKEY_TO_VERSE_TYPE[value] - if name == 'rtf': + if name == 'RTF': value = self.unescape(value) result = strip_rtf(value, self.encoding) if result is None: From 047a0b3085c3a991e6c22ccfeff2d51733042842 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 15 Aug 2013 21:57:23 +0200 Subject: [PATCH 18/36] Fix bug #1212801 where the song edit form did not clear a previously set theme. Fixes: https://launchpad.net/bugs/1212801 --- openlp/plugins/songs/forms/editsongform.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 7593e4a95..3209f994b 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -47,6 +47,7 @@ from editsongdialog import Ui_EditSongDialog log = logging.getLogger(__name__) + class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): """ Class to manage the editing of a song @@ -229,6 +230,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.loadTopics() self.loadBooks() self.loadMediaFiles() + self.themeComboBox.setEditText(u'') self.themeComboBox.setCurrentIndex(0) # it's a new song to preview is not possible self.previewButton.setVisible(False) @@ -261,6 +263,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if self.song.theme_name: find_and_set_in_combo_box( self.themeComboBox, unicode(self.song.theme_name)) + else: + self.themeComboBox.setEditText(u'') + self.themeComboBox.setCurrentIndex(0) self.copyrightEdit.setText( self.song.copyright if self.song.copyright else u'') self.commentsEdit.setPlainText( From 6a0771392d0efcfcca13d2e9da9baf29a93a4452 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Fri, 16 Aug 2013 06:20:21 +0100 Subject: [PATCH 19/36] renamed strings, remove unused logger import --- openlp/core/lib/filedialog.py | 11 ++++------- openlp/core/lib/ui.py | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/openlp/core/lib/filedialog.py b/openlp/core/lib/filedialog.py index 0c2bd1005..5e0c7539b 100644 --- a/openlp/core/lib/filedialog.py +++ b/openlp/core/lib/filedialog.py @@ -28,9 +28,8 @@ ############################################################################### """ -Provide a work around for a bug in QFileDialog (#1209515) +Provide a work around for a bug in QFileDialog """ -import logging import os import urllib @@ -38,8 +37,6 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib.ui import UiStrings -log = logging.getLogger(__name__) - class FileDialog(QtGui.QFileDialog): @staticmethod def getOpenFileNames(parent, title, path, filters): @@ -50,9 +47,9 @@ class FileDialog(QtGui.QFileDialog): if not os.path.exists(file): file = urllib.unquote(file) if not os.path.exists(file): - QtGui.QMessageBox.information(self, - UiStrings().FNFT, - UiStrings().FNF % file) + QtGui.QMessageBox.information(parent, + UiStrings().FileNotFound, + UiStrings().FileNotFoundMessage % file) continue file_list.append(QtCore.QString(file)) return file_list \ No newline at end of file diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 65b720787..03403816a 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -77,9 +77,9 @@ class UiStrings(object): self.Error = translate('OpenLP.Ui', 'Error') self.Export = translate('OpenLP.Ui', 'Export') self.File = translate('OpenLP.Ui', 'File') - self.FNFT = unicode(translate('OpenLP.Ui', + self.FileNotFound = unicode(translate('OpenLP.Ui', 'File Not Found')) - self.FNF = unicode(translate('OpenLP.Ui', + self.FileNotFoundMessage = unicode(translate('OpenLP.Ui', 'File %s not found.\nPlease try selecting it individually.')) self.FontSizePtUnit = translate('OpenLP.Ui', 'pt', 'Abbreviated font pointsize unit') From d492c2fecd9736efa4ff93123fb78218ed54446a Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 17 Aug 2013 08:37:36 +0100 Subject: [PATCH 20/36] fixes #1213254 by filtering out invalid xml chars --- openlp/plugins/songs/lib/xml.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 1cd349f13..22539b495 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -92,6 +92,27 @@ class SongXML(object): self.song_xml = objectify.fromstring(u'') self.lyrics = etree.SubElement(self.song_xml, u'lyrics') + @staticmethod + def valid_xml_char_ordinal(char): + """ + Control Characters we need to filter from the xml. + Source + """ + return ( + 0x20 <= char <= 0xD7FF + or char in (0x9, 0xA, 0xD) + or 0xE000 <= char <= 0xFFFD + or 0x10000 <= char <= 0x10FFFF + ) + + @staticmethod + def clean_xml_string(xml): + """ + Filter out invalid characters in xml + Source + """ + return ''.join(char for char in xml if SongXML.valid_xml_char_ordinal(ord(char))) + def add_verse_to_lyrics(self, type, number, content, lang=None): """ Add a verse to the ```` tag. From 9f7e32cd31d68485db021f711005245c43f0dd8c Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 17 Aug 2013 09:10:25 +0100 Subject: [PATCH 21/36] fixes #1213254 by filtering out invalid xml chars --- openlp/plugins/songs/lib/xml.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 22539b495..f4702f207 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -133,6 +133,7 @@ class SongXML(object): The verse's language code (ISO-639). This is not required, but should be added if available. """ + content = self.clean_xml_string(content) verse = etree.Element(u'verse', type=unicode(type), label=unicode(number)) if lang: From 3a551d08c05c20fa3d5d89dde795b26326c5dcdf Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 17 Aug 2013 08:51:08 +0000 Subject: [PATCH 22/36] Space reinstated as per PEP8 --- openlp/core/utils/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 031a0f1b3..a33cd2604 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -150,6 +150,7 @@ class AppLocation(object): check_directory_exists(path) return path + def _get_os_dir_path(dir_type): """ Return a path based on which OS and environment we are running in. From aee52232d38710c312b301dcc64feef586ba003c Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sun, 18 Aug 2013 06:48:55 +0000 Subject: [PATCH 23/36] Fixes #1197659 by seting the default attribut on the save button when the tag is edited --- openlp/core/ui/formattingtagform.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index 6b10b4d00..f2a529527 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -109,6 +109,7 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog): has been changed. """ self.savePushButton.setEnabled(True) + self.savePushButton.setDefault(True) def onNewClicked(self): """ From 0c3985f88ef788cb56952d0ab368c36340ac1ab3 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sun, 18 Aug 2013 20:44:48 +0000 Subject: [PATCH 24/36] added file open mode --- openlp/plugins/songs/lib/sundayplusimport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/sundayplusimport.py b/openlp/plugins/songs/lib/sundayplusimport.py index cd72cc564..410c35e88 100644 --- a/openlp/plugins/songs/lib/sundayplusimport.py +++ b/openlp/plugins/songs/lib/sundayplusimport.py @@ -68,7 +68,7 @@ class SundayPlusImport(SongImport): for filename in self.importSource: if self.stopImportFlag: return - song_file = open(filename) + song_file = open(filename, 'rb') self.doImportFile(song_file) song_file.close() From 5e6d30f7504d0beab7c0c73c81e412eb73dcc893 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Mon, 19 Aug 2013 20:17:09 +0000 Subject: [PATCH 25/36] merged two methods in to one and made them module level --- openlp/plugins/songs/lib/xml.py | 34 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index f4702f207..fc92a9cd9 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -78,6 +78,17 @@ log = logging.getLogger(__name__) NAMESPACE = u'http://openlyrics.info/namespace/2009/song' NSMAP = '{' + NAMESPACE + '}' + '%s' +def clean_xml_string(xml): + """ + Filter out invalid characters in xml + Source + """ + return ''.join(char for char in xml if + 0x20 <= char <= 0xD7FF + or char in (0x9, 0xA, 0xD) + or 0xE000 <= char <= 0xFFFD + or 0x10000 <= char <= 0x10FFFF) + class SongXML(object): """ @@ -92,27 +103,6 @@ class SongXML(object): self.song_xml = objectify.fromstring(u'') self.lyrics = etree.SubElement(self.song_xml, u'lyrics') - @staticmethod - def valid_xml_char_ordinal(char): - """ - Control Characters we need to filter from the xml. - Source - """ - return ( - 0x20 <= char <= 0xD7FF - or char in (0x9, 0xA, 0xD) - or 0xE000 <= char <= 0xFFFD - or 0x10000 <= char <= 0x10FFFF - ) - - @staticmethod - def clean_xml_string(xml): - """ - Filter out invalid characters in xml - Source - """ - return ''.join(char for char in xml if SongXML.valid_xml_char_ordinal(ord(char))) - def add_verse_to_lyrics(self, type, number, content, lang=None): """ Add a verse to the ```` tag. @@ -133,7 +123,7 @@ class SongXML(object): The verse's language code (ISO-639). This is not required, but should be added if available. """ - content = self.clean_xml_string(content) + content = clean_xml_string(content) verse = etree.Element(u'verse', type=unicode(type), label=unicode(number)) if lang: From c620a303e29dc838fc287feb3624e62b42e965bf Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 19 Aug 2013 23:09:52 +0200 Subject: [PATCH 26/36] Fix bug #1194622: skip the Bibles page if the Bibles plugin is not enabled. Fixes: https://launchpad.net/bugs/1194622 --- openlp/core/ui/firsttimeform.py | 15 +++++++++++++-- openlp/core/ui/firsttimewizard.py | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 0742a92b6..761ec0ceb 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The First Time Wizard +""" import io import logging import os @@ -48,6 +50,7 @@ from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage log = logging.getLogger(__name__) + class ThemeScreenshotThread(QtCore.QThread): """ This thread downloads the theme screenshots. @@ -56,6 +59,9 @@ class ThemeScreenshotThread(QtCore.QThread): QtCore.QThread.__init__(self, parent) def run(self): + """ + Run the thread. + """ themes = self.parent().config.get(u'themes', u'files') themes = themes.split(u',') themes_dir = self.parent().config.get(u'themes', u'directory') @@ -189,6 +195,11 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): return -1 elif self.currentId() == FirstTimePage.NoInternet: return FirstTimePage.Progress + elif self.currentId() == FirstTimePage.Songs: + if self.bibleCheckBox.isChecked(): + return FirstTimePage.Bibles + else: + return FirstTimePage.Themes elif self.currentId() == FirstTimePage.Themes: Receiver.send_message(u'cursor_busy') Receiver.send_message(u'openlp_process_events') @@ -395,7 +406,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.max_progress += size if self.max_progress: # Add on 2 for plugins status setting plus a "finished" point. - self.max_progress = self.max_progress + 2 + self.max_progress += 2 self.progressBar.setValue(0) self.progressBar.setMinimum(0) self.progressBar.setMaximum(self.max_progress) diff --git a/openlp/core/ui/firsttimewizard.py b/openlp/core/ui/firsttimewizard.py index 2ba0bda3c..d792c4f99 100644 --- a/openlp/core/ui/firsttimewizard.py +++ b/openlp/core/ui/firsttimewizard.py @@ -34,7 +34,11 @@ import sys from openlp.core.lib import translate from openlp.core.lib.ui import add_welcome_page + class FirstTimePage(object): + """ + An enumeration object to make it easy for a developer to determine which page is which by index + """ Welcome = 0 Plugins = 1 NoInternet = 2 From d7fcf9e4f67f8b8f4973d4beca08443f2c57f468 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 20 Aug 2013 20:30:15 +0200 Subject: [PATCH 27/36] Fix bug #1088800 by adding ".pptm" to the list of acceptable file extensions. Fixes: https://launchpad.net/bugs/1088800 --- openlp/plugins/presentations/lib/impresscontroller.py | 4 +++- openlp/plugins/presentations/lib/mediaitem.py | 9 +++++---- openlp/plugins/presentations/lib/powerpointcontroller.py | 3 ++- openlp/plugins/presentations/lib/pptviewcontroller.py | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index aef32dabc..37890eb37 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -44,6 +44,7 @@ import time if os.name == u'nt': from win32com.client import Dispatch import pywintypes + # Declare an empty exception to match the exception imported from UNO class ErrorCodeIOException(Exception): pass @@ -63,6 +64,7 @@ from presentationcontroller import PresentationController, PresentationDocument log = logging.getLogger(__name__) + class ImpressController(PresentationController): """ Class to control interactions with Impress presentations. @@ -79,7 +81,7 @@ class ImpressController(PresentationController): PresentationController.__init__(self, plugin, u'Impress', ImpressDocument) self.supports = [u'odp'] - self.alsosupports = [u'ppt', u'pps', u'pptx', u'ppsx'] + self.alsosupports = [u'ppt', u'pps', u'pptx', u'ppsx', u'pptm'] self.process = None self.desktop = None self.manager = None diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index b307eebb3..2f944810f 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -45,6 +45,7 @@ log = logging.getLogger(__name__) ERROR = QtGui.QImage(u':/general/general_delete.png') + class PresentationMediaItem(MediaManagerItem): """ This is the Presentation media manager item for Presentation Items. @@ -88,10 +89,10 @@ class PresentationMediaItem(MediaManagerItem): if self.controllers[controller].enabled(): types = self.controllers[controller].supports + \ self.controllers[controller].alsosupports - for type in types: - if fileType.find(type) == -1: - fileType += u'*.%s ' % type - self.plugin.serviceManager.supportedSuffixes(type) + for type_ in types: + if fileType.find(type_) == -1: + fileType += u'*.%s ' % type_ + self.plugin.serviceManager.supportedSuffixes(type_) self.onNewFileMasks = unicode(translate('PresentationPlugin.MediaItem', 'Presentations (%s)')) % fileType diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index fac11a2b6..4f078f928 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -43,6 +43,7 @@ log = logging.getLogger(__name__) # PPT API documentation: # http://msdn.microsoft.com/en-us/library/aa269321(office.10).aspx + class PowerpointController(PresentationController): """ Class to control interactions with PowerPoint Presentations @@ -58,7 +59,7 @@ class PowerpointController(PresentationController): log.debug(u'Initialising') PresentationController.__init__(self, plugin, u'Powerpoint', PowerpointDocument) - self.supports = [u'ppt', u'pps', u'pptx', u'ppsx'] + self.supports = [u'ppt', u'pps', u'pptx', u'ppsx', u'pptm'] self.process = None def check_available(self): diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index a568985de..0242f0597 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -38,6 +38,7 @@ from presentationcontroller import PresentationController, PresentationDocument log = logging.getLogger(__name__) + class PptviewController(PresentationController): """ Class to control interactions with PowerPOint Viewer Presentations @@ -54,7 +55,7 @@ class PptviewController(PresentationController): self.process = None PresentationController.__init__(self, 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', u'pptm'] def check_available(self): """ From a869c2401ba68dce129dfb5d662d58a1ae8ff601 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 20 Aug 2013 21:05:26 +0200 Subject: [PATCH 28/36] Added a fix for songs as well. Fixes: https://launchpad.net/bugs/1194622 --- openlp/core/ui/firsttimeform.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 761ec0ceb..a24876e88 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -186,11 +186,19 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): Determine the next page in the Wizard to go to. """ Receiver.send_message(u'openlp_process_events') + # If we are currently on the plugins page if self.currentId() == FirstTimePage.Plugins: + # But we don't have Internet access if not self.webAccess: return FirstTimePage.NoInternet - else: + # The songs plugin is enabled + elif self.songsCheckBox.isChecked(): return FirstTimePage.Songs + # The Bibles plugin is enabled + elif self.bibleCheckBox.isChecked(): + return FirstTimePage.Bibles + else: + return FirstTimePage.Themes elif self.currentId() == FirstTimePage.Progress: return -1 elif self.currentId() == FirstTimePage.NoInternet: From 647331c00cf9175ef721843d61ab6715a85f94f2 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Tue, 20 Aug 2013 19:38:50 +0000 Subject: [PATCH 29/36] added doc strings --- openlp/core/lib/filedialog.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/filedialog.py b/openlp/core/lib/filedialog.py index 5e0c7539b..d1a5bd69a 100644 --- a/openlp/core/lib/filedialog.py +++ b/openlp/core/lib/filedialog.py @@ -28,7 +28,8 @@ ############################################################################### """ -Provide a work around for a bug in QFileDialog +Provide a work around for a bug in QFileDialog + """ import os import urllib @@ -38,8 +39,15 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib.ui import UiStrings class FileDialog(QtGui.QFileDialog): + """ + Subclass QFileDialog to work round a bug + """ @staticmethod def getOpenFileNames(parent, title, path, filters): + """ + Reimplement getOpenFileNames to fix the way it returns some file + names that url encoded when selecting multiple files/ + """ files = QtGui.QFileDialog.getOpenFileNames(parent, title, path, filters) file_list = QtCore.QStringList() for file in files: From 7cc9f9ae7b89185fccee19bfc02591a5a6eee17a Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Tue, 20 Aug 2013 21:19:11 +0000 Subject: [PATCH 30/36] reinstate retrieve_windows_encoding dialog --- openlp/plugins/songs/lib/songshowplusimport.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index aaa3b7ad9..8d3dcba25 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -227,4 +227,9 @@ class SongShowPlusImport(SongImport): try: return unicode(data, chardet.detect(data)['encoding']) except: - return unicode(data, u'cp1252') \ No newline at end of file + self.encoding = u'cp1252' + while self.encoding: + try: + return unicode(data, self.encoding) + except: + self.encoding = retrieve_windows_encoding() From e802d577fd07620fc9ea22bb4ba8ef7d06824b4d Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Wed, 21 Aug 2013 05:30:11 +0000 Subject: [PATCH 31/36] Removed loop --- openlp/plugins/songs/lib/songshowplusimport.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index 8d3dcba25..45746bdd1 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -227,9 +227,4 @@ class SongShowPlusImport(SongImport): try: return unicode(data, chardet.detect(data)['encoding']) except: - self.encoding = u'cp1252' - while self.encoding: - try: - return unicode(data, self.encoding) - except: - self.encoding = retrieve_windows_encoding() + return unicode(data, retrieve_windows_encoding()) From 621ef0b6e6ce701989d7290012c1f95eea8a7e10 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Wed, 21 Aug 2013 14:39:22 +0200 Subject: [PATCH 32/36] fixed bug #1214875 'Importing an OSIS bible always results in English book names' Fixes: https://launchpad.net/bugs/1214875 --- openlp/plugins/bibles/lib/db.py | 20 ++++++++++++++++++++ openlp/plugins/bibles/lib/osis.py | 9 +++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 0cc3a1c7a..ead7afabb 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -862,6 +862,26 @@ class BiblesResourcesDB(QtCore.QObject, Manager): return book[0] return None + @staticmethod + def get_language_by_id(language_id): + """ + Return a dict containing the language id, name and code by id. + + ``id`` + The id of the language in the database. + """ + log.debug(u'BiblesResourcesDB.get_language_by_id(%d)', language_id) + language = BiblesResourcesDB.run_sql(u'SELECT id, name, code FROM ' + u'language WHERE id = ?', (unicode(language_id),)) + if language: + return { + u'id': language[0][0], + u'name': unicode(language[0][1]), + u'code': unicode(language[0][2]) + } + else: + return None + @staticmethod def get_language(name): """ diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 1a0028f37..373d17593 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -34,7 +34,7 @@ import codecs import re from openlp.core.lib import Receiver, translate -from openlp.core.utils import AppLocation +from openlp.core.utils import AppLocation, LanguageManager from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB log = logging.getLogger(__name__) @@ -157,12 +157,17 @@ class OSISBible(BibleDB): if last_chapter == 0: self.wizard.progressBar.setMaximum(chapter_count) if last_chapter != chapter: + custom_translator = LanguageManager.get_translator( + BiblesResourcesDB.get_language_by_id( + language_id)['code'])[0] + book_name_localized = custom_translator.translate( + 'BiblesPlugin', book_details[u'name']) if last_chapter != 0: self.session.commit() self.wizard.incrementProgressBar(unicode(translate( 'BiblesPlugin.OsisImport', 'Importing %s %s...', 'Importing ...')) % - (book_details[u'name'], chapter)) + (book_name_localized, chapter)) last_chapter = chapter # All of this rigmarol below is because the mod2osis # tool from the Sword library embeds XML in the OSIS From fe5c144dce0a3e89eeb70d5e39de5201555b3208 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Wed, 21 Aug 2013 14:47:32 +0200 Subject: [PATCH 33/36] Removed needless unicode() call --- openlp/plugins/bibles/lib/db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index ead7afabb..3def6bc3e 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -872,7 +872,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): """ log.debug(u'BiblesResourcesDB.get_language_by_id(%d)', language_id) language = BiblesResourcesDB.run_sql(u'SELECT id, name, code FROM ' - u'language WHERE id = ?', (unicode(language_id),)) + u'language WHERE id = ?', (language_id,)) if language: return { u'id': language[0][0], From 7ba834689dcc80b1a97766daf6a0d37af9541fe3 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Wed, 21 Aug 2013 14:58:23 +0200 Subject: [PATCH 34/36] Save the translated name in the bible database file --- openlp/plugins/bibles/lib/osis.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 373d17593..4bbad60dc 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -148,20 +148,20 @@ class OSISBible(BibleDB): self.filename) return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) - if not db_book or db_book.name != book_details[u'name']: - log.debug(u'New book: "%s"' % book_details[u'name']) + custom_translator = LanguageManager.get_translator( + BiblesResourcesDB.get_language_by_id( + language_id)['code'])[0] + book_name_localized = unicode(custom_translator.translate( + 'BiblesPlugin', book_details[u'name'])) + if not db_book or db_book.name != book_name_localized: + log.debug(u'New book: "%s"' % book_name_localized) db_book = self.create_book( - book_details[u'name'], + book_name_localized, book_ref_id, book_details[u'testament_id']) if last_chapter == 0: self.wizard.progressBar.setMaximum(chapter_count) if last_chapter != chapter: - custom_translator = LanguageManager.get_translator( - BiblesResourcesDB.get_language_by_id( - language_id)['code'])[0] - book_name_localized = custom_translator.translate( - 'BiblesPlugin', book_details[u'name']) if last_chapter != 0: self.session.commit() self.wizard.incrementProgressBar(unicode(translate( From d6746bb76b4633bc755156dc601803b7161f8830 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Wed, 21 Aug 2013 22:14:11 +0200 Subject: [PATCH 35/36] Handle an unknown bible language nicely --- openlp/plugins/bibles/lib/osis.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 4bbad60dc..3c23e1c4a 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -148,11 +148,18 @@ class OSISBible(BibleDB): self.filename) return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) - custom_translator = LanguageManager.get_translator( - BiblesResourcesDB.get_language_by_id( - language_id)['code'])[0] - book_name_localized = unicode(custom_translator.translate( - 'BiblesPlugin', book_details[u'name'])) + bible_language = BiblesResourcesDB.get_language_by_id(language_id) + if bible_language is not None: + # The language of this bible was found, so we can + # translate the name of this book + custom_translator = LanguageManager.get_translator( + bible_language['code'])[0] + book_name_localized = unicode(custom_translator.translate( + 'BiblesPlugin', book_details[u'name'])) + else: + # The language of this bible was not found, so we just + # use the English name for this book + book_name_localized = book_details[u'name'] if not db_book or db_book.name != book_name_localized: log.debug(u'New book: "%s"' % book_name_localized) db_book = self.create_book( From 4fe68f43c6609ba2ab55269915de406b5cf3f351 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 22 Aug 2013 11:02:18 +0200 Subject: [PATCH 36/36] Fix bug #1215302 by adding the .divx extension to the list in vlcplayer Fixes: https://launchpad.net/bugs/1215302 --- openlp/core/ui/media/vlcplayer.py | 3 +- openlp/core/ui/media/webkitplayer.py | 46 ++++++++++++++-------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 11f451b4a..845382a28 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -89,7 +89,8 @@ VIDEO_EXT = [ u'*.xa', u'*.iso', u'*.vob', - u'*.webm' + u'*.webm', + u'*.divx' ] diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 71a19b768..666e6abd8 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -229,32 +229,32 @@ FLASH_HTML = u""" """ VIDEO_EXT = [ - u'*.3gp' - , u'*.3gpp' - , u'*.3g2' - , u'*.3gpp2' - , u'*.aac' - , u'*.flv' - , u'*.f4a' - , u'*.f4b' - , u'*.f4p' - , u'*.f4v' - , u'*.mov' - , u'*.m4a' - , u'*.m4b' - , u'*.m4p' - , u'*.m4v' - , u'*.mkv' - , u'*.mp4' - , u'*.ogv' - , u'*.webm' - , u'*.mpg', u'*.wmv', u'*.mpeg', u'*.avi' - , u'*.swf' + u'*.3gp', + u'*.3gpp', + u'*.3g2', + u'*.3gpp2', + u'*.aac', + u'*.flv', + u'*.f4a', + u'*.f4b', + u'*.f4p', + u'*.f4v', + u'*.mov', + u'*.m4a', + u'*.m4b', + u'*.m4p', + u'*.m4v', + u'*.mkv', + u'*.mp4', + u'*.ogv', + u'*.webm', + u'*.mpg', u'*.wmv', u'*.mpeg', u'*.avi', + u'*.swf' ] AUDIO_EXT = [ - u'*.mp3' - , u'*.ogg' + u'*.mp3', + u'*.ogg' ]