From 68d6bc46d682d3f87bf9b27461f01f7a8b797eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 14 Feb 2011 13:20:30 +0100 Subject: [PATCH 01/11] Comment 14.02.2011 --- openlp/plugins/songs/forms/songimportform.py | 46 ++++++++++++++++++++ openlp/plugins/songs/lib/importer.py | 7 ++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 433c9abfc..e07b8c019 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -140,6 +140,12 @@ class SongImportForm(OpenLPWizard): QtCore.QObject.connect(self.songBeamerRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onSongBeamerRemoveButtonClicked) + QtCore.QObject.connect(self.foilPresenterAddButton, + QtCore.SIGNAL(u'clicked()'), + self.onFoilPresenterAddButtonClicked), + QtCore.QObject.connect(self.foilPresenterRemoveButton, + QtCore.SIGNAL(u'clicked()'), + self.onFoilPresenterRemoveButtonClicked) def addCustomPages(self): """ @@ -186,6 +192,8 @@ class SongImportForm(OpenLPWizard): self.addSingleFileSelectItem(u'ew') # Words of Worship self.addMultiFileSelectItem(u'songBeamer') + # Foilpresenter + self.addMultiFileSelectItem(u'foilPresenter') # Commented out for future use. # self.addSingleFileSelectItem(u'csv', u'CSV') self.sourceLayout.addLayout(self.formatStack) @@ -236,6 +244,8 @@ class SongImportForm(OpenLPWizard): translate('SongsPlugin.ImportWizardForm', 'EasyWorship')) self.formatComboBox.setItemText(10, translate('SongsPlugin.ImportWizardForm', 'SongBeamer')) + self.formatComboBox.setItemText(11, + translate('SongsPlugin.ImportWizardForm', 'FoilPresenter')) # self.formatComboBox.setItemText(11, # translate('SongsPlugin.ImportWizardForm', 'CSV')) self.openLP2FilenameLabel.setText( @@ -300,6 +310,10 @@ class SongImportForm(OpenLPWizard): translate('SongsPlugin.ImportWizardForm', 'Add Files...')) self.songBeamerRemoveButton.setText( translate('SongsPlugin.ImportWizardForm', 'Remove File(s)')) + self.foilPresenterAddButton.setText( + translate('SongsPlugin.ImportWizardForm', 'Add Files...')) + self.foilPresenterRemoveButton.setText( + translate('SongsPlugin.ImportWizardForm', 'Remove File(s)')) # self.csvFilenameLabel.setText( # translate('SongsPlugin.ImportWizardForm', 'Filename:')) # self.csvBrowseButton.setText( @@ -447,6 +461,16 @@ class SongImportForm(OpenLPWizard): 'file to import from.')) self.songBeamerAddButton.setFocus() return False + elif source_format == SongFormat.FoilPresenter: + if self.foilPresenterFileListWidget.count() == 0: + criticalErrorMessageBox( + translate('SongsPlugin.ImportWizardForm', + 'No Foilpresenter Files Selected'), + translate('SongsPlugin.ImportWizardForm', + 'You need to add at least one Foilpresenter ' + 'song file to import from.')) + self.foilPresenterAddButton.setFocus() + return False return True elif self.currentPage() == self.progressPage: return True @@ -682,6 +706,22 @@ class SongImportForm(OpenLPWizard): """ self.removeSelectedItems(self.songBeamerFileListWidget) + def onFoilPresenterAddButtonClicked(self): + """ + Get FoilPresenter song database files + """ + self.getFiles( + translate('SongsPlugin.ImportWizardForm', + 'Select FoilPresenter Files'), + self.foilPresenterFileListWidget + ) + + def onFoilPresenterRemoveButtonClicked(self): + """ + Remove selected FoilPresenter files from the import list + """ + self.removeSelectedItems(self.foilPresenterFileListWidget) + def registerFields(self): """ Register song import wizard fields. @@ -707,6 +747,7 @@ class SongImportForm(OpenLPWizard): self.easiSlidesFilenameEdit.setText(u'') self.ewFilenameEdit.setText(u'') self.songBeamerFileListWidget.clear() + self.foilPresenterFileListWidget.clear() #self.csvFilenameEdit.setText(u'') def preWizard(self): @@ -783,6 +824,11 @@ class SongImportForm(OpenLPWizard): importer = self.plugin.importSongs(SongFormat.SongBeamer, filenames=self.getListOfFiles(self.songBeamerFileListWidget) ) + elif source_format == SongFormat.FoilPresenter: + # Import Foilpresenter songs + importer = self.plugin.importSongs(SongFormat.FoilPresenter, + filenames=self.getListOfFiles(self.foilPresenterFileListWidget) + ) if importer.do_import(): # reload songs self.progressLabel.setText( diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 91d3d7e6f..e914cc6ac 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -34,6 +34,7 @@ from wowimport import WowImport from cclifileimport import CCLIFileImport from ewimport import EasyWorshipSongImport from songbeamerimport import SongBeamerImport +from foilpresenterimport import FoilPresenterImport # Imports that might fail try: from olp1import import OpenLP1SongImport @@ -71,6 +72,7 @@ class SongFormat(object): EasiSlides = 8 EasyWorship = 9 SongBeamer = 10 + FoilPresenter = 11 @staticmethod def get_class(format): @@ -102,6 +104,8 @@ class SongFormat(object): return EasyWorshipSongImport elif format == SongFormat.SongBeamer: return SongBeamerImport + elif format == SongFormat.FoilPresenter: + return FoilPresenterImport return None @staticmethod @@ -120,7 +124,8 @@ class SongFormat(object): SongFormat.Generic, SongFormat.EasiSlides, SongFormat.EasyWorship, - SongFormat.SongBeamer + SongFormat.SongBeamer, + SongFormat.FoilPresenter ] @staticmethod From cafd7b397d3301431d05ef6a6c01aafaa3798fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 14 Feb 2011 14:01:52 +0100 Subject: [PATCH 02/11] 14.02.2011 --- openlp/plugins/songs/forms/songimportform.py | 17 +++++++++-------- openlp/plugins/songs/lib/importer.py | 5 +---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 6c5c90838..b6c7286bc 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -140,18 +140,18 @@ class SongImportForm(OpenLPWizard): QtCore.QObject.connect(self.songBeamerRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onSongBeamerRemoveButtonClicked) - QtCore.QObject.connect(self.foilPresenterAddButton, - QtCore.SIGNAL(u'clicked()'), - self.onFoilPresenterAddButtonClicked), - QtCore.QObject.connect(self.foilPresenterRemoveButton, - QtCore.SIGNAL(u'clicked()'), - self.onFoilPresenterRemoveButtonClicked) QtCore.QObject.connect(self.songShowPlusAddButton, QtCore.SIGNAL(u'clicked()'), self.onSongShowPlusAddButtonClicked) QtCore.QObject.connect(self.songShowPlusRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onSongShowPlusRemoveButtonClicked) + QtCore.QObject.connect(self.foilPresenterAddButton, + QtCore.SIGNAL(u'clicked()'), + self.onFoilPresenterAddButtonClicked) + QtCore.QObject.connect(self.foilPresenterRemoveButton, + QtCore.SIGNAL(u'clicked()'), + self.onFoilPresenterRemoveButtonClicked) def addCustomPages(self): """ @@ -200,10 +200,10 @@ class SongImportForm(OpenLPWizard): self.addFileSelectItem(u'ew', single_select=True) # Words of Worship self.addFileSelectItem(u'songBeamer') - # Foilpresenter - self.addFileSelectItem(u'foilPresenter') # Song Show Plus self.addFileSelectItem(u'songShowPlus') + # Foilpresenter + self.addFileSelectItem(u'foilPresenter') # Commented out for future use. # self.addFileSelectItem(u'csv', u'CSV', single_select=True) self.sourceLayout.addLayout(self.formatStack) @@ -475,6 +475,7 @@ class SongImportForm(OpenLPWizard): 'You need to add at least one SongShow Plus ' 'file to import from.')) self.wordsOfWorshipAddButton.setFocus() + return False elif source_format == SongFormat.FoilPresenter: if self.foilPresenterFileListWidget.count() == 0: criticalErrorMessageBox( diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index dbbcad596..53ba17de9 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -34,11 +34,8 @@ from wowimport import WowImport from cclifileimport import CCLIFileImport from ewimport import EasyWorshipSongImport from songbeamerimport import SongBeamerImport -<<<<<<< TREE -from foilpresenterimport import FoilPresenterImport -======= from songshowplusimport import SongShowPlusImport ->>>>>>> MERGE-SOURCE +from foilpresenterimport import FoilPresenterImport # Imports that might fail try: from olp1import import OpenLP1SongImport From e75c24bdd785d060e35a6e9ddd3121ab239b70ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Fri, 18 Feb 2011 21:40:07 +0100 Subject: [PATCH 03/11] Changed 18.02.2011 --- openlp/plugins/songs/forms/songimportform.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index b6c7286bc..361a076da 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -256,7 +256,7 @@ class SongImportForm(OpenLPWizard): self.formatComboBox.setItemText(11, translate('SongsPlugin.ImportWizardForm', 'SongShow Plus')) self.formatComboBox.setItemText(12, - translate('SongsPlugin.ImportWizardForm', 'FoilPresenter')) + translate('SongsPlugin.ImportWizardForm', 'Foilpresenter')) # self.formatComboBox.setItemText(11, # translate('SongsPlugin.ImportWizardForm', 'CSV')) self.openLP2FilenameLabel.setText( @@ -711,7 +711,9 @@ class SongImportForm(OpenLPWizard): self.getFiles( translate('SongsPlugin.ImportWizardForm', 'Select FoilPresenter Files'), - self.foilPresenterFileListWidget + self.foilPresenterFileListWidget, u'%s (*.foil)' + % translate('SongsPlugin.ImportWizardForm', + 'Foilpresenter Song Files') ) def onFoilPresenterRemoveButtonClicked(self): From ab917254d0b72d04b4afc697fb7f12db159f91cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 19 Feb 2011 14:03:43 +0100 Subject: [PATCH 04/11] 19.02.2011 From 6208587b939333766412500d6552f2394598ed99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 19 Feb 2011 22:34:51 +0100 Subject: [PATCH 05/11] foilpresenterimport - some changes --- openlp/core/ui/wizard.py | 1 + openlp/plugins/songs/forms/songimportform.py | 12 ++----- .../plugins/songs/lib/foilpresenterimport.py | 36 +++++++++---------- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 2960607e4..fc1edeecb 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -54,6 +54,7 @@ class WizardStrings(object): SoF = u'Songs of Fellowship' SSP = u'SongShow Plus' WoW = u'Words of Worship' + FP = u'Foilpresenter' # These strings should need a good reason to be retranslated elsewhere. FinishedImport = translate('OpenLP.Ui', 'Finished import.') FormatLabel = translate('OpenLP.Ui', 'Format:') diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index bc3e28a33..06de08a93 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -410,12 +410,8 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.FoilPresenter: if self.foilPresenterFileListWidget.count() == 0: - criticalErrorMessageBox( - translate('SongsPlugin.ImportWizardForm', - 'No Foilpresenter Files Selected'), - translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one Foilpresenter ' - 'song file to import from.')) + critical_error_message_box(UiStrings.NFSp, + WizardStrings.YouSpecifyFile % WizardStrings.FP) self.foilPresenterAddButton.setFocus() return False return True @@ -613,9 +609,7 @@ class SongImportForm(OpenLPWizard): """ Get FoilPresenter song database files """ - self.getFiles( - translate('SongsPlugin.ImportWizardForm', - 'Select FoilPresenter Files'), + self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.FP, self.foilPresenterFileListWidget, u'%s (*.foil)' % translate('SongsPlugin.ImportWizardForm', 'Foilpresenter Song Files') diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index 919901694..635137b00 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -94,6 +94,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 VerseType from openlp.plugins.songs.lib.songimport import SongImport from openlp.plugins.songs.lib.db import Author, Book, Song, Topic @@ -110,32 +111,27 @@ class FoilPresenterImport(SongImport): Initialise the import. """ log.debug(u'initialise FoilPresenterImport') - SongImport.__init__(self, master_manager) - self.master_manager = master_manager - self.FoilPresenter = FoilPresenter(master_manager) - if kwargs.has_key(u'filename'): - self.import_source = kwargs[u'filename'] - if kwargs.has_key(u'filenames'): - self.import_source = kwargs[u'filenames'] + SongImport.__init__(self, master_manager, **kwargs) + self.FoilPresenter = FoilPresenter(self.manager) def do_import(self): """ Imports the songs. """ self.import_wizard.progressBar.setMaximum(len(self.import_source)) + parser = etree.XMLParser(remove_blank_text=True) for file_path in self.import_source: if self.stop_import_flag: return False - self.import_wizard.incrementProgressBar(unicode(translate( - 'SongsPlugin.FoilPresenterImport', 'Importing %s...')) % - os.path.basename(file_path)) - parser = etree.XMLParser(remove_blank_text=True) - parsed_file = etree.parse(file_path, parser) - xml = unicode(etree.tostring(parsed_file)) - if self.FoilPresenter.xml_to_song(xml) is None: - log.debug(u'File could not be imported: %s' % file_path) - # Importing this song failed! For now we stop import. - return False + self.import_wizard.incrementProgressBar( + WizardStrings.ImportingType % os.path.basename(file_path)) + try: + parsed_file = etree.parse(file_path, parser) + xml = unicode(etree.tostring(parsed_file)) + if self.FoilPresenter.xml_to_song(xml) is None: + log.debug(u'File could not be imported: %s' % file_path) + except etree.XMLSyntaxError: + log.exception(u'XML syntax error in file %s' % file_path) return True class FoilPresenter(object): @@ -325,9 +321,9 @@ class FoilPresenter(object): for test_temp in test: author_temp.append(test_temp) for author in author_temp: - author = re.compile( - u'^[\/,;\-\s]+|[\/,;\-\s]+$|\s*[0-9]{4}\s*[\-\/]?\s*([0-9]{4})?[\/,;\-\s]*$' - ).sub(u'', author) + regex = u'^[\/,;\-\s]+|[\/,;\-\s]+$|'\ + '\s*[0-9]{4}\s*[\-\/]?\s*([0-9]{4})?[\/,;\-\s]*$' + author = re.compile(regex).sub(u'', author) author = re.compile( u'[0-9]{1,2}\.\s?J(ahr)?h\.|um\s*$|vor\s*$').sub(u'', author) From 265aeebf4bbca34afe5c157ba689d710a4acdb17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 21 Feb 2011 14:45:14 +0100 Subject: [PATCH 06/11] sort WizardStrings in alphapetical order --- openlp/core/ui/wizard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index fc1edeecb..209f3f212 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -47,6 +47,7 @@ class WizardStrings(object): CSV = u'CSV' EW = u'EasyWorship' ES = u'EasiSlides' + FP = u'Foilpresenter' OL = u'OpenLyrics' OS = u'OpenSong' OSIS = u'OSIS' @@ -54,7 +55,6 @@ class WizardStrings(object): SoF = u'Songs of Fellowship' SSP = u'SongShow Plus' WoW = u'Words of Worship' - FP = u'Foilpresenter' # These strings should need a good reason to be retranslated elsewhere. FinishedImport = translate('OpenLP.Ui', 'Finished import.') FormatLabel = translate('OpenLP.Ui', 'Format:') From 4aa69e53bbf0c70615bafa929a987273322799b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 21 Feb 2011 15:59:01 +0100 Subject: [PATCH 07/11] removed duplicate method registerFields() and sort some lines --- openlp/plugins/songs/forms/songimportform.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 06de08a93..3eecac4ba 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -604,6 +604,12 @@ class SongImportForm(OpenLPWizard): % translate('SongsPlugin.ImportWizardForm', 'SongShow Plus Song Files') ) + + def onSongShowPlusRemoveButtonClicked(self): + """ + Remove selected SongShow Plus files from the import list + """ + self.removeSelectedItems(self.songShowPlusFileListWidget) def onFoilPresenterAddButtonClicked(self): """ @@ -621,18 +627,6 @@ class SongImportForm(OpenLPWizard): """ self.removeSelectedItems(self.foilPresenterFileListWidget) - def registerFields(self): - """ - Register song import wizard fields. - """ - pass - - def onSongShowPlusRemoveButtonClicked(self): - """ - Remove selected SongShow Plus files from the import list - """ - self.removeSelectedItems(self.songShowPlusFileListWidget) - def setDefaults(self): """ Set default form values for the song import wizard. From 1e041d9158d72aa1f7ad177f38c756f55da07c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 21 Feb 2011 17:02:28 +0100 Subject: [PATCH 08/11] remove some whitespaces --- openlp/plugins/songs/forms/songimportform.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 3eecac4ba..16c0f9edb 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -594,7 +594,7 @@ class SongImportForm(OpenLPWizard): Remove selected SongBeamer files from the import list """ self.removeSelectedItems(self.songBeamerFileListWidget) - + def onSongShowPlusAddButtonClicked(self): """ Get SongShow Plus song database files @@ -604,7 +604,7 @@ class SongImportForm(OpenLPWizard): % translate('SongsPlugin.ImportWizardForm', 'SongShow Plus Song Files') ) - + def onSongShowPlusRemoveButtonClicked(self): """ Remove selected SongShow Plus files from the import list From 0ecc3c2dc9e5924559ed9222f0229526163c5bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 21 Feb 2011 23:03:09 +0100 Subject: [PATCH 09/11] adapt "Author unknown" similar to xml.py correct some whitespaces and quotation marks --- .../plugins/songs/lib/foilpresenterimport.py | 85 +++++++++---------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index 635137b00..963561cb5 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -99,6 +99,7 @@ from openlp.plugins.songs.lib import VerseType from openlp.plugins.songs.lib.songimport import SongImport from openlp.plugins.songs.lib.db import Author, Book, Song, Topic from openlp.plugins.songs.lib.xml import SongXML +from openlp.plugins.songs.lib.ui import SongStrings log = logging.getLogger(__name__) @@ -261,40 +262,40 @@ class FoilPresenter(object): if copyright: strings = [] author_temp = [] - if copyright.find(u"Copyright") != -1: - test = copyright.partition(u"Copyright") + if copyright.find(u'Copyright') != -1: + test = copyright.partition(u'Copyright') copyright = test[0] - elif copyright.find(u"copyright") != -1: - test = copyright.partition(u"copyright") + elif copyright.find(u'copyright') != -1: + test = copyright.partition(u'copyright') copyright = test[0] - elif copyright.find(u"©") != -1: - test = copyright.partition(u"©") + elif copyright.find(u'©') != -1: + test = copyright.partition(u'©') copyright = test[0] - elif copyright.find(u"(c)") != -1: - test = copyright.partition(u"(c)") + elif copyright.find(u'(c)') != -1: + test = copyright.partition(u'(c)') copyright = test[0] - elif copyright.find(u"(C)") != -1: - test = copyright.partition(u"(C)") + elif copyright.find(u'(C)') != -1: + test = copyright.partition(u'(C)') copyright = test[0] - elif copyright.find(u"c)") != -1: - test = copyright.partition(u"c)") + elif copyright.find(u'c)') != -1: + test = copyright.partition(u'c)') copyright = test[0] - elif copyright.find(u"C)") != -1: - test = copyright.partition(u"C)") + elif copyright.find(u'C)') != -1: + test = copyright.partition(u'C)') copyright = test[0] - elif copyright.find(u"C:") != -1: - test = copyright.partition(u"C:") + elif copyright.find(u'C:') != -1: + test = copyright.partition(u'C:') copyright = test[0] - elif copyright.find(u"C,)") != -1: - test = copyright.partition(u"C,)") + elif copyright.find(u'C,)') != -1: + test = copyright.partition(u'C,)') copyright = test[0] copyright = re.compile(u'\\n').sub(u' ', copyright) copyright = re.compile(u'\(.*\)').sub(u'', copyright) - if copyright.find(u"Rechte") != -1: - test = copyright.partition(u"Rechte") + if copyright.find(u'Rechte') != -1: + test = copyright.partition(u'Rechte') copyright = test[0] markers = [u'Text +u\.?n?d? +Melodie[a-zA-Z0-9\,\. ]*:', - u'Text +u\.?n?d? +Musik', u"T & M", u'Melodie und Satz', + u'Text +u\.?n?d? +Musik', u'T & M', u'Melodie und Satz', u'Text[a-zA-Z0-9\,\. ]*:', u'Melodie', u'Musik', u'Satz', u'Weise', u'[dD]eutsch', u'[dD]t[\.\:]', u'Englisch', u'[oO]riginal', u'Bearbeitung', u'[R|r]efrain'] @@ -304,9 +305,9 @@ class FoilPresenter(object): i = 0 x = 0 while i != 1: - if copyright.find(u"") != -1: - test = copyright.partition(u"") - if (test[0].strip() != u"") & (x > 0): + if copyright.find(u'') != -1: + test = copyright.partition(u'') + if (test[0].strip() != u'') & (x > 0): strings.append(test[0]) copyright = test[2] x += 1 @@ -316,7 +317,7 @@ class FoilPresenter(object): else: i = 1 for author in strings: - test = re.split(u",(?=\D{2})|(?<=\D),|\/(?=\D{3,})|(?<=\D);", + test = re.split(u',(?=\D{2})|(?<=\D),|\/(?=\D{3,})|(?<=\D);', author) for test_temp in test: author_temp.append(test_temp) @@ -332,16 +333,14 @@ class FoilPresenter(object): if re.search( u'\w+\.?\s+\w{3,}\s+[a|u]nd\s|\w+\.?\s+\w{3,}\s+&\s', author, re.U) != None: - temp = re.split(u'\s[a|u]nd\s|\s&\s',author) + temp = re.split(u'\s[a|u]nd\s|\s&\s', author) for temp_temp in temp: temp_temp = temp_temp.strip() authors.append(temp_temp) elif (len(author) > 2): authors.append(author) if not authors: - # Add "Author unknown" (can be translated). - authors.append((unicode(translate('SongsPlugin.XML', - 'Author unknown')))) + authors.append(SongStrings.AuthorUnknownUnT) for display_name in authors: author = self.manager.get_object_filtered(Author, Author.display_name == display_name) @@ -415,18 +414,18 @@ class FoilPresenter(object): search_text = u'' temp_verse_order = {} temp_verse_order_backup = [] - temp_verse_sort= [] + temp_verse_sort = [] temp_sortnr_backup = 1 temp_sortnr_liste = [] - versenumber = {u"V":1, u"C": 1, u"B": 1, u"E": 1, u"O": 1, u"I": 1, - u"P": 1 } + versenumber = {u'V': 1, u'C': 1, u'B': 1, u'E': 1, u'O': 1, u'I': 1, + u'P': 1 } for strophe in foilpresenterfolie.strophen.strophe: text = self._child(strophe.text_) verse_name = self._child(strophe.key) children = strophe.getchildren() sortnr = 0 for child in children: - if child.tag == "sortnr": + if child.tag == 'sortnr': verse_sortnr = self._child(strophe.sortnr) sortnr = 1 # In older Version there is no sortnr, but we need one @@ -437,26 +436,26 @@ class FoilPresenter(object): temp_sortnr_liste.append(verse_sortnr) temp_verse_name = re.compile(u'[0-9].*').sub(u'', verse_name) temp_verse_name = temp_verse_name[:3].lower() - if temp_verse_name == u"ref": + if temp_verse_name == u'ref': verse_type = u'C' - elif temp_verse_name == u"r": + elif temp_verse_name == u'r': verse_type = u'C' - elif temp_verse_name == u"": + elif temp_verse_name == u'': verse_type = u'V' - elif temp_verse_name == u"v": + elif temp_verse_name == u'v': verse_type = u'V' - elif temp_verse_name == u"bri": + elif temp_verse_name == u'bri': verse_type = u'B' - elif temp_verse_name == u"cod": + elif temp_verse_name == u'cod': verse_type = u'E' - elif temp_verse_name == u"sch": + elif temp_verse_name == u'sch': verse_type = u'E' - elif temp_verse_name == u"pre": + elif temp_verse_name == u'pre': verse_type = u'P' - elif temp_verse_name == u"int": + elif temp_verse_name == u'int': verse_type = u'I' else: - verse_type = u"O" + verse_type = u'O' verse_number = re.compile(u'[a-zA-Z.+-_ ]*').sub(u'', verse_name) verse_part = re.compile(u'[0-9]*').sub(u'', verse_name[1:]) # Foilpresenter allows e. g. "C", but we need "C1". From 71068d4eb65eb8d214d0e0f8df7ec6c711fa1fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Tue, 22 Feb 2011 21:35:18 +0100 Subject: [PATCH 10/11] fix inconsistant field names, refer now to the xml file --- .../plugins/songs/lib/foilpresenterimport.py | 91 +++++++++---------- 1 file changed, 44 insertions(+), 47 deletions(-) diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index 963561cb5..30c94303b 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -105,7 +105,7 @@ log = logging.getLogger(__name__) class FoilPresenterImport(SongImport): """ - This provides the Openlyrics import. + This provides the Foilpresenter import. """ def __init__(self, master_manager, **kwargs): """ @@ -263,37 +263,37 @@ class FoilPresenter(object): strings = [] author_temp = [] if copyright.find(u'Copyright') != -1: - test = copyright.partition(u'Copyright') - copyright = test[0] + temp = copyright.partition(u'Copyright') + copyright = temp[0] elif copyright.find(u'copyright') != -1: - test = copyright.partition(u'copyright') - copyright = test[0] + temp = copyright.partition(u'copyright') + copyright = temp[0] elif copyright.find(u'©') != -1: - test = copyright.partition(u'©') - copyright = test[0] + temp = copyright.partition(u'©') + copyright = temp[0] elif copyright.find(u'(c)') != -1: - test = copyright.partition(u'(c)') - copyright = test[0] + temp = copyright.partition(u'(c)') + copyright = temp[0] elif copyright.find(u'(C)') != -1: - test = copyright.partition(u'(C)') - copyright = test[0] + temp = copyright.partition(u'(C)') + copyright = temp[0] elif copyright.find(u'c)') != -1: - test = copyright.partition(u'c)') - copyright = test[0] + temp = copyright.partition(u'c)') + copyright = temp[0] elif copyright.find(u'C)') != -1: - test = copyright.partition(u'C)') - copyright = test[0] + temp = copyright.partition(u'C)') + copyright = temp[0] elif copyright.find(u'C:') != -1: - test = copyright.partition(u'C:') - copyright = test[0] + temp = copyright.partition(u'C:') + copyright = temp[0] elif copyright.find(u'C,)') != -1: - test = copyright.partition(u'C,)') - copyright = test[0] + temp = copyright.partition(u'C,)') + copyright = temp[0] copyright = re.compile(u'\\n').sub(u' ', copyright) copyright = re.compile(u'\(.*\)').sub(u'', copyright) if copyright.find(u'Rechte') != -1: - test = copyright.partition(u'Rechte') - copyright = test[0] + temp = copyright.partition(u'Rechte') + copyright = temp[0] markers = [u'Text +u\.?n?d? +Melodie[a-zA-Z0-9\,\. ]*:', u'Text +u\.?n?d? +Musik', u'T & M', u'Melodie und Satz', u'Text[a-zA-Z0-9\,\. ]*:', u'Melodie', u'Musik', u'Satz', @@ -306,10 +306,10 @@ class FoilPresenter(object): x = 0 while i != 1: if copyright.find(u'') != -1: - test = copyright.partition(u'') - if (test[0].strip() != u'') & (x > 0): - strings.append(test[0]) - copyright = test[2] + temp = copyright.partition(u'') + if (temp[0].strip() != u'') & (x > 0): + strings.append(temp[0]) + copyright = temp[2] x += 1 elif x > 0: strings.append(copyright) @@ -317,10 +317,10 @@ class FoilPresenter(object): else: i = 1 for author in strings: - test = re.split(u',(?=\D{2})|(?<=\D),|\/(?=\D{3,})|(?<=\D);', + temp = re.split(u',(?=\D{2})|(?<=\D),|\/(?=\D{3,})|(?<=\D);', author) - for test_temp in test: - author_temp.append(test_temp) + for tempx in temp: + author_temp.append(tempx) for author in author_temp: regex = u'^[\/,;\-\s]+|[\/,;\-\s]+$|'\ '\s*[0-9]{4}\s*[\-\/]?\s*([0-9]{4})?[\/,;\-\s]*$' @@ -334,9 +334,9 @@ class FoilPresenter(object): u'\w+\.?\s+\w{3,}\s+[a|u]nd\s|\w+\.?\s+\w{3,}\s+&\s', author, re.U) != None: temp = re.split(u'\s[a|u]nd\s|\s&\s', author) - for temp_temp in temp: - temp_temp = temp_temp.strip() - authors.append(temp_temp) + for tempx in temp: + tempx = tempx.strip() + authors.append(tempx) elif (len(author) > 2): authors.append(author) if not authors: @@ -347,8 +347,8 @@ class FoilPresenter(object): if author is None: # We need to create a new author, as the author does not exist. author = Author.populate(display_name=display_name, - last_name=display_name.split(u' ')[-1], - first_name=u' '.join(display_name.split(u' ')[:-1])) + last_name = display_name.split(u' ')[-1], + first_name = u' '.join(display_name.split(u' ')[:-1])) self.manager.save_object(author) song.authors.append(author) @@ -404,9 +404,6 @@ class FoilPresenter(object): ``foilpresenterfolie`` The foilpresenterfolie object (lxml.objectify.ObjectifiedElement). - ``lyrics`` - The lyrics object (lxml.objectify.ObjectifiedElement). - ``song`` The song object. """ @@ -418,14 +415,14 @@ class FoilPresenter(object): temp_sortnr_backup = 1 temp_sortnr_liste = [] versenumber = {u'V': 1, u'C': 1, u'B': 1, u'E': 1, u'O': 1, u'I': 1, - u'P': 1 } + u'P': 1} for strophe in foilpresenterfolie.strophen.strophe: text = self._child(strophe.text_) verse_name = self._child(strophe.key) children = strophe.getchildren() sortnr = 0 for child in children: - if child.tag == 'sortnr': + if child.tag == u'sortnr': verse_sortnr = self._child(strophe.sortnr) sortnr = 1 # In older Version there is no sortnr, but we need one @@ -506,8 +503,8 @@ class FoilPresenter(object): song.song_book_id = 0 song.song_number = u'' try: - for songbook in foilpresenterfolie.buch.bucheintrag: - bookname = self._child(songbook.name) + for bucheintrag in foilpresenterfolie.buch.bucheintrag: + bookname = self._child(bucheintrag.name) if bookname: book = self.manager.get_object_filtered(Book, Book.name == bookname) @@ -517,8 +514,8 @@ class FoilPresenter(object): self.manager.save_object(book) song.song_book_id = book.id try: - if self._child(songbook.nummer): - song.song_number = self._child(songbook.nummer) + if self._child(bucheintrag.nummer): + song.song_number = self._child(bucheintrag.nummer) except AttributeError: pass # We only support one song book, so take the first one. @@ -536,13 +533,13 @@ class FoilPresenter(object): ``song`` The song object. """ - for title in foilpresenterfolie.titel.titelstring: + for titelstring in foilpresenterfolie.titel.titelstring: if not song.title: - song.title = self._child(title) + song.title = self._child(titelstring) song.search_title = unicode(song.title) song.alternate_title = u'' else: - song.alternate_title = self._child(title) + song.alternate_title = self._child(titelstring) song.search_title += u'@' + song.alternate_title song.search_title = re.sub(r'[\'"`,;:(){}?]+', u'', unicode(song.search_title)).lower() @@ -558,8 +555,8 @@ class FoilPresenter(object): The song object. """ try: - for topictext in foilpresenterfolie.kategorien.name: - topictext = self._child(topictext) + for name in foilpresenterfolie.kategorien.name: + topictext = self._child(name) if topictext: topic = self.manager.get_object_filtered(Topic, Topic.name == topictext) From b4b6fef70a2e107c024f360f736f429412409a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 23 Feb 2011 20:48:37 +0100 Subject: [PATCH 11/11] change value to True/False --- 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 30c94303b..2eded332f 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -420,13 +420,13 @@ class FoilPresenter(object): text = self._child(strophe.text_) verse_name = self._child(strophe.key) children = strophe.getchildren() - sortnr = 0 + sortnr = False for child in children: if child.tag == u'sortnr': verse_sortnr = self._child(strophe.sortnr) - sortnr = 1 + sortnr = True # In older Version there is no sortnr, but we need one - if sortnr == 0: + if sortnr == False: verse_sortnr = unicode(temp_sortnr_backup) temp_sortnr_backup += 1 # Foilpresenter allows e. g. "Ref" or "1", but we need "C1" or "V1".