From bbe4169c24b2e518c23a2c4c3ad342e39d138b58 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 21 Mar 2014 21:38:08 +0000 Subject: [PATCH] Fix all formatting errors --- .../custom/forms/editcustomslidedialog.py | 3 +- openlp/plugins/custom/lib/mediaitem.py | 22 +++--- .../presentations/lib/impresscontroller.py | 8 +- .../presentations/lib/pdfcontroller.py | 6 +- .../presentations/lib/pptviewlib/ppttest.py | 10 +-- openlp/plugins/remotes/lib/httpserver.py | 3 - openlp/plugins/remotes/lib/remotetab.py | 7 +- openlp/plugins/remotes/remoteplugin.py | 16 ++-- .../songs/forms/duplicatesongremovalform.py | 6 +- openlp/plugins/songs/forms/editsongform.py | 8 +- .../plugins/songs/forms/mediafilesdialog.py | 1 - openlp/plugins/songs/forms/mediafilesform.py | 1 - openlp/plugins/songs/forms/songimportform.py | 8 +- .../songs/forms/songmaintenancedialog.py | 4 +- .../songs/forms/songmaintenanceform.py | 2 +- .../plugins/songs/forms/songreviewwidget.py | 2 +- openlp/plugins/songs/lib/__init__.py | 1 - openlp/plugins/songs/lib/cclifileimport.py | 4 +- openlp/plugins/songs/lib/db.py | 34 +++++---- openlp/plugins/songs/lib/dreambeamimport.py | 5 +- .../plugins/songs/lib/foilpresenterimport.py | 15 ++-- openlp/plugins/songs/lib/mediaitem.py | 6 +- openlp/plugins/songs/lib/olpimport.py | 6 +- openlp/plugins/songs/lib/openlyricsexport.py | 5 +- openlp/plugins/songs/lib/powersongimport.py | 4 +- openlp/plugins/songs/lib/sofimport.py | 11 ++- openlp/plugins/songs/lib/songcompare.py | 2 +- openlp/plugins/songs/lib/songimport.py | 2 +- .../plugins/songs/lib/songshowplusimport.py | 4 +- openlp/plugins/songs/lib/sundayplusimport.py | 3 +- openlp/plugins/songs/lib/test/test.opensong | 72 ------------------ .../plugins/songs/lib/test/test.opensong.zip | Bin 855 -> 0 bytes openlp/plugins/songs/lib/test/test2.opensong | 45 ----------- openlp/plugins/songs/lib/test/test3.opensong | 10 --- .../songs/lib/test/test_import_file.py | 50 ------------ .../songs/lib/test/test_importing_lots.py | 61 --------------- openlp/plugins/songs/lib/ui.py | 4 +- openlp/plugins/songs/lib/upgrade.py | 1 - .../songs/lib/worshipcenterproimport.py | 6 +- openlp/plugins/songs/lib/xml.py | 3 +- openlp/plugins/songs/lib/zionworximport.py | 2 +- openlp/plugins/songs/songsplugin.py | 2 +- 42 files changed, 111 insertions(+), 354 deletions(-) delete mode 100644 openlp/plugins/songs/lib/test/test.opensong delete mode 100644 openlp/plugins/songs/lib/test/test.opensong.zip delete mode 100644 openlp/plugins/songs/lib/test/test2.opensong delete mode 100644 openlp/plugins/songs/lib/test/test3.opensong delete mode 100644 openlp/plugins/songs/lib/test/test_import_file.py delete mode 100644 openlp/plugins/songs/lib/test/test_importing_lots.py diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index a94bdd109..3b74566fc 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -33,6 +33,7 @@ from openlp.core.common import UiStrings, translate from openlp.core.lib import SpellTextEdit from openlp.core.lib.ui import create_button, create_button_box + class Ui_CustomSlideEditDialog(object): def setupUi(self, custom_slide_edit_dialog): custom_slide_edit_dialog.setObjectName('custom_slide_edit_dialog') @@ -45,7 +46,7 @@ class Ui_CustomSlideEditDialog(object): self.insert_button = create_button(custom_slide_edit_dialog, 'insertButton', icon=':/general/general_add.png') self.button_box = create_button_box(custom_slide_edit_dialog, 'button_box', ['cancel', 'save'], - [self.split_button, self.insert_button]) + [self.split_button, self.insert_button]) self.dialog_layout.addWidget(self.button_box) self.retranslateUi(custom_slide_edit_dialog) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index cfea319e6..9ecfac779 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -33,8 +33,8 @@ from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_, func, and_ from openlp.core.common import Registry, Settings, UiStrings, translate -from openlp.core.lib import MediaManagerItem, ItemCapabilities, ServiceItemContext, PluginStatus,\ - check_item_selected +from openlp.core.lib import MediaManagerItem, ItemCapabilities, ServiceItemContext, PluginStatus, \ + check_item_selected from openlp.plugins.custom.forms.editcustomform import EditCustomForm from openlp.plugins.custom.lib import CustomXMLParser, CustomXMLBuilder from openlp.plugins.custom.lib.db import CustomSlide @@ -105,12 +105,10 @@ class CustomMediaItem(MediaManagerItem): """ Initialise the UI so it can provide Searches """ - self.search_text_edit.set_search_types([(CustomSearch.Titles, ':/songs/song_search_title.png', - translate('SongsPlugin.MediaItem', 'Titles'), - translate('SongsPlugin.MediaItem', 'Search Titles...')), - (CustomSearch.Themes, ':/slides/slide_theme.png', UiStrings().Themes, - UiStrings().SearchThemes) - ]) + self.search_text_edit.set_search_types( + [(CustomSearch.Titles, ':/songs/song_search_title.png', translate('SongsPlugin.MediaItem', 'Titles'), + translate('SongsPlugin.MediaItem', 'Search Titles...')), + (CustomSearch.Themes, ':/slides/slide_theme.png', UiStrings().Themes, UiStrings().SearchThemes)]) self.search_text_edit.set_current_search_type(Settings().value('%s/last search type' % self.settings_section)) self.load_list(self.plugin.db_manager.get_all_objects(CustomSlide, order_by_ref=CustomSlide.title)) self.config_update() @@ -191,10 +189,9 @@ class CustomMediaItem(MediaManagerItem): if QtGui.QMessageBox.question(self, UiStrings().ConfirmDelete, translate('CustomPlugin.MediaItem', 'Are you sure you want to delete the %n selected custom slide(s)?', - '', - QtCore.QCoreApplication.CodecForTr, len(items)), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes - | QtGui.QMessageBox.No), + '', QtCore.QCoreApplication.CodecForTr, len(items)), + QtGui.QMessageBox.StandardButtons( + QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: return row_list = [item.row() for item in self.list_view.selectedIndexes()] @@ -348,4 +345,3 @@ class CustomMediaItem(MediaManagerItem): func.lower(CustomSlide.text).like(search)), order_by_ref=CustomSlide.title) return [[custom.id, custom.title] for custom in search_results] - diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 356a6cceb..c55873c5f 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -29,7 +29,8 @@ # OOo API documentation: # http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/XSlideShowController.html -# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Basic/Getting_Information_about_UNO_Objects#Inspecting_interfaces_during_debugging +# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Basic +# /Getting_Information_about_UNO_Objects#Inspecting_interfaces_during_debugging # http://docs.go-oo.org/sd/html/classsd_1_1SlideShow.html # http://www.oooforum.org/forum/viewtopic.phtml?t=5252 # http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations @@ -45,6 +46,7 @@ if os.name == 'nt': from win32com.client import Dispatch import pywintypes # Declare an empty exception to match the exception imported from UNO + class ErrorCodeIOException(Exception): pass else: @@ -204,7 +206,7 @@ class ImpressDocument(PresentationDocument): Class which holds information and controls a single presentation. """ - def __init__ (self, controller, presentation): + def __init__(self, controller, presentation): """ Constructor, store information about the file and initialise. """ @@ -353,7 +355,7 @@ class ImpressDocument(PresentationDocument): log.debug('unblank screen OpenOffice') return self.control.resume() - def blank_screen (self): + def blank_screen(self): """ Blanks the screen. """ diff --git a/openlp/plugins/presentations/lib/pdfcontroller.py b/openlp/plugins/presentations/lib/pdfcontroller.py index 2dade90a1..597b7d78b 100644 --- a/openlp/plugins/presentations/lib/pdfcontroller.py +++ b/openlp/plugins/presentations/lib/pdfcontroller.py @@ -132,7 +132,8 @@ class PdfController(PresentationController): DEVNULL = open(os.devnull, 'wb') # First try to find mupdf try: - self.mudrawbin = check_output(['which', 'mudraw'], stderr=DEVNULL).decode(encoding='UTF-8').rstrip('\n') + self.mudrawbin = check_output(['which', 'mudraw'], + stderr=DEVNULL).decode(encoding='UTF-8').rstrip('\n') except CalledProcessError: self.mudrawbin = '' # if mupdf isn't installed, fallback to ghostscript @@ -192,7 +193,8 @@ class PdfDocument(PresentationDocument): :return: The resolution dpi to be used. """ # Use a postscript script to get size of the pdf. It is assumed that all pages have same size - gs_resolution_script = AppLocation.get_directory(AppLocation.PluginsDir) + '/presentations/lib/ghostscript_get_resolution.ps' + gs_resolution_script = AppLocation.get_directory( + AppLocation.PluginsDir) + '/presentations/lib/ghostscript_get_resolution.ps' # Run the script on the pdf to get the size runlog = [] try: diff --git a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py index 6c48f9ee0..49a820670 100644 --- a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py +++ b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py @@ -32,6 +32,7 @@ from PyQt4 import QtGui, QtCore from ctypes import * from ctypes.wintypes import RECT + class PPTViewer(QtGui.QWidget): """ Standalone Test Harness for the pptviewlib library @@ -169,16 +170,16 @@ class PPTViewer(QtGui.QWidget): app.processEvents() def openClick(self): - oldid = self.pptid; + oldid = self.pptid rect = RECT(int(self.xEdit.text()), int(self.yEdit.text()), - int(self.widthEdit.text()), int(self.heightEdit.text())) + int(self.widthEdit.text()), int(self.heightEdit.text())) filename = str(self.pptEdit.text().replace('/', '\\')) folder = str(self.folderEdit.text().replace('/', '\\')) print(filename, folder) self.pptid = self.pptdll.OpenPPT(filename, None, rect, folder) print('id: ' + str(self.pptid)) if oldid >= 0: - self.pptdll.ClosePPT(oldid); + self.pptdll.ClosePPT(oldid) slides = self.pptdll.GetSlideCount(self.pptid) print('slidecount: ' + str(slides)) self.total.setNum(self.pptdll.GetSlideCount(self.pptid)) @@ -201,8 +202,7 @@ class PPTViewer(QtGui.QWidget): app.processEvents() def openDialog(self): - self.pptEdit.setText(QtGui.QFileDialog.getOpenFileName(self, - 'Open file')) + self.pptEdit.setText(QtGui.QFileDialog.getOpenFileName(self, 'Open file')) if __name__ == '__main__': pptdll = cdll.LoadLibrary(r'pptviewlib.dll') diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index b57bd29d3..fa578184b 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -144,6 +144,3 @@ class HTTPSServer(HTTPServer): server_side=True) self.server_bind() self.server_activate() - - - diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 540b8d212..d6b96cc1c 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -225,7 +225,8 @@ class RemoteTab(SettingsTab): continue for address in interface.addressEntries(): ip = address.ip() - if ip.protocol() == QtNetwork.QAbstractSocket.IPv4Protocol and ip != QtNetwork.QHostAddress.LocalHost: + if ip.protocol() == QtNetwork.QAbstractSocket.IPv4Protocol and \ + ip != QtNetwork.QHostAddress.LocalHost: return ip.toString() return ip_address @@ -262,9 +263,9 @@ class RemoteTab(SettingsTab): Settings().value(self.settings_section + '/port') != self.port_spin_box.value() or \ Settings().value(self.settings_section + '/https port') != self.https_port_spin_box.value() or \ Settings().value(self.settings_section + '/https enabled') != \ - self.https_settings_group_box.isChecked() or \ + self.https_settings_group_box.isChecked() or \ Settings().value(self.settings_section + '/authentication enabled') != \ - self.user_login_group_box.isChecked(): + self.user_login_group_box.isChecked(): self.settings_form.register_post_process('remotes_config_updated') Settings().setValue(self.settings_section + '/port', self.port_spin_box.value()) Settings().setValue(self.settings_section + '/https port', self.https_port_spin_box.value()) diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 3517c4f9c..393f08dd9 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -36,14 +36,14 @@ from openlp.plugins.remotes.lib import RemoteTab, OpenLPServer log = logging.getLogger(__name__) __default_settings__ = { - 'remotes/twelve hour': True, - 'remotes/port': 4316, - 'remotes/https port': 4317, - 'remotes/https enabled': False, - 'remotes/user id': 'openlp', - 'remotes/password': 'password', - 'remotes/authentication enabled': False, - 'remotes/ip address': '0.0.0.0' + 'remotes/twelve hour': True, + 'remotes/port': 4316, + 'remotes/https port': 4317, + 'remotes/https enabled': False, + 'remotes/user id': 'openlp', + 'remotes/password': 'password', + 'remotes/authentication enabled': False, + 'remotes/ip address': '0.0.0.0' } diff --git a/openlp/plugins/songs/forms/duplicatesongremovalform.py b/openlp/plugins/songs/forms/duplicatesongremovalform.py index fc5e9a809..22299cde5 100644 --- a/openlp/plugins/songs/forms/duplicatesongremovalform.py +++ b/openlp/plugins/songs/forms/duplicatesongremovalform.py @@ -64,8 +64,8 @@ class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): # Used to interrupt ongoing searches when cancel is clicked. self.break_search = False super(DuplicateSongRemovalForm, self).__init__( - Registry().get('main_window'), plugin, 'duplicateSongRemovalWizard', ':/wizards/wizard_duplicateremoval.bmp' - , False) + Registry().get('main_window'), plugin, 'duplicateSongRemovalWizard', + ':/wizards/wizard_duplicateremoval.bmp', False) self.setMinimumWidth(730) def custom_signals(self): @@ -327,4 +327,4 @@ class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): self.button(QtGui.QWizard.FinishButton).show() self.button(QtGui.QWizard.FinishButton).setEnabled(True) self.button(QtGui.QWizard.NextButton).hide() - self.button(QtGui.QWizard.CancelButton).hide() \ No newline at end of file + self.button(QtGui.QWizard.CancelButton).hide() diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 06639fe18..8b1e3a897 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -185,11 +185,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): if len(invalid_verses) > 1: msg = translate('SongsPlugin.EditSongForm', 'There are no verses corresponding to "%(invalid)s".' 'Valid entries are %(valid)s.\nPlease enter the verses separated by spaces.') % \ - {'invalid': ', '.join(invalid_verses), 'valid' : valid} + {'invalid': ', '.join(invalid_verses), 'valid': valid} else: msg = translate('SongsPlugin.EditSongForm', 'There is no verse corresponding to "%(invalid)s".' 'Valid entries are %(valid)s.\nPlease enter the verses separated by spaces.') % \ - {'invalid': invalid_verses[0], 'valid' : valid} + {'invalid': invalid_verses[0], 'valid': valid} critical_error_message_box(title=translate('SongsPlugin.EditSongForm', 'Invalid Verse Order'), message=msg) return len(invalid_verses) == 0 @@ -257,7 +257,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): self.song.lyrics = str(sxml.extract_xml(), 'utf-8') for verse in multiple: self.song.verse_order = re.sub('([' + verse.upper() + verse.lower() + '])(\W|$)', - r'\g<1>1\2', self.song.verse_order) + r'\g<1>1\2', self.song.verse_order) except: log.exception('Problem processing song Lyrics \n%s', sxml.dump_xml()) raise @@ -955,4 +955,4 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): log.exception('Could not remove directory: %s', save_path) clean_song(self.manager, self.song) self.manager.save_object(self.song) - self.media_item.auto_select_id = self.song.id \ No newline at end of file + self.media_item.auto_select_id = self.song.id diff --git a/openlp/plugins/songs/forms/mediafilesdialog.py b/openlp/plugins/songs/forms/mediafilesdialog.py index 09fbd96f5..a0392e3db 100644 --- a/openlp/plugins/songs/forms/mediafilesdialog.py +++ b/openlp/plugins/songs/forms/mediafilesdialog.py @@ -71,4 +71,3 @@ class Ui_MediaFilesDialog(object): self.select_label.setText(translate('SongsPlugin.MediaFilesForm', 'Select one or more audio files from the list below, and click OK to import them ' 'into this song.')) - diff --git a/openlp/plugins/songs/forms/mediafilesform.py b/openlp/plugins/songs/forms/mediafilesform.py index 660a9f72d..ec689ddb6 100644 --- a/openlp/plugins/songs/forms/mediafilesform.py +++ b/openlp/plugins/songs/forms/mediafilesform.py @@ -56,4 +56,3 @@ class MediaFilesForm(QtGui.QDialog, Ui_MediaFilesDialog): def get_selected_files(self): return [item.data(QtCore.Qt.UserRole) for item in self.file_list_widget.selectedItems()] - diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index e87c9f645..27f0d9343 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -99,7 +99,8 @@ class SongImportForm(OpenLPWizard, RegistryProperties): self.format_widgets[song_format]['removeButton'].clicked.connect(self.on_remove_button_clicked) else: self.format_widgets[song_format]['browseButton'].clicked.connect(self.on_browse_button_clicked) - self.format_widgets[song_format]['file_path_edit'].textChanged.connect(self.on_filepath_edit_text_changed) + self.format_widgets[song_format]['file_path_edit'].textChanged.\ + connect(self.on_filepath_edit_text_changed) def add_custom_pages(self): """ @@ -163,7 +164,8 @@ class SongImportForm(OpenLPWizard, RegistryProperties): f_label = 'Filename:' if select_mode == SongFormatSelect.SingleFolder: f_label = 'Folder:' - self.format_widgets[format_list]['filepathLabel'].setText(translate('SongsPlugin.ImportWizardForm', f_label)) + self.format_widgets[format_list]['filepathLabel'].setText( + translate('SongsPlugin.ImportWizardForm', f_label)) for format_list in self.disablable_formats: self.format_widgets[format_list]['disabled_label'].setText(SongFormat.get(format_list, 'disabledLabelText')) self.progress_page.setTitle(WizardStrings.Importing) @@ -244,7 +246,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties): if file_names: listbox.addItems(file_names) Settings().setValue(self.plugin.settings_section + '/last directory import', - os.path.split(str(file_names[0]))[0]) + os.path.split(str(file_names[0]))[0]) def get_list_of_files(self, list_box): """ diff --git a/openlp/plugins/songs/forms/songmaintenancedialog.py b/openlp/plugins/songs/forms/songmaintenancedialog.py index 200b4b1ff..84e3535d3 100644 --- a/openlp/plugins/songs/forms/songmaintenancedialog.py +++ b/openlp/plugins/songs/forms/songmaintenancedialog.py @@ -162,6 +162,6 @@ class Ui_SongMaintenanceDialog(object): self.edit_book_button.setText(UiStrings().Edit) self.delete_book_button.setText(UiStrings().Delete) type_list_width = max(self.fontMetrics().width(SongStrings.Authors), - self.fontMetrics().width(SongStrings.Topics), - self.fontMetrics().width(SongStrings.SongBooks)) + self.fontMetrics().width(SongStrings.Topics), + self.fontMetrics().width(SongStrings.SongBooks)) self.type_list_widget.setFixedWidth(type_list_width + self.type_list_widget.iconSize().width() + 32) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 8f92e9cae..4e9bdad93 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -531,4 +531,4 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope edit_button.setEnabled(False) else: delete_button.setEnabled(True) - edit_button.setEnabled(True) \ No newline at end of file + edit_button.setEnabled(True) diff --git a/openlp/plugins/songs/forms/songreviewwidget.py b/openlp/plugins/songs/forms/songreviewwidget.py index 839174009..02d7b8774 100644 --- a/openlp/plugins/songs/forms/songreviewwidget.py +++ b/openlp/plugins/songs/forms/songreviewwidget.py @@ -191,7 +191,7 @@ class SongReviewWidget(QtGui.QWidget): self.song_remove_button.setObjectName('song_remove_button') self.song_remove_button.setIcon(build_icon(':/songs/song_delete.png')) self.song_remove_button.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.song_vertical_layout.addWidget(self.song_remove_button, alignment = QtCore.Qt.AlignHCenter) + self.song_vertical_layout.addWidget(self.song_remove_button, alignment=QtCore.Qt.AlignHCenter) def retranslateUi(self): self.song_remove_button.setText('Remove') diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 1c9141b16..dc198d4b7 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -549,4 +549,3 @@ def delete_song(song_id, song_plugin): except OSError: log.exception('Could not remove directory: %s', save_path) song_plugin.manager.delete_object(Song, song_id) - diff --git a/openlp/plugins/songs/lib/cclifileimport.py b/openlp/plugins/songs/lib/cclifileimport.py index 54779a194..0866a1cc7 100644 --- a/openlp/plugins/songs/lib/cclifileimport.py +++ b/openlp/plugins/songs/lib/cclifileimport.py @@ -89,8 +89,8 @@ class CCLIFileImport(SongImport): if not self.do_import_txt_file(lines): self.log_error(filename) else: - self.log_error(filename, - translate('SongsPlugin.CCLIFileImport', 'The file does not have a valid extension.')) + self.log_error(filename, translate('SongsPlugin.CCLIFileImport', 'The file does not have a valid ' + 'extension.')) log.info('Extension %s is not valid', filename) if self.stop_import_flag: return diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index ad5bee1a1..c3965e2ed 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -172,7 +172,8 @@ def init_schema(url): session, metadata = init_db(url) # Definition of the "authors" table - authors_table = Table('authors', metadata, + authors_table = Table( + 'authors', metadata, Column('id', types.Integer(), primary_key=True), Column('first_name', types.Unicode(128)), Column('last_name', types.Unicode(128)), @@ -180,7 +181,8 @@ def init_schema(url): ) # Definition of the "media_files" table - media_files_table = Table('media_files', metadata, + media_files_table = Table( + 'media_files', metadata, Column('id', types.Integer(), primary_key=True), Column('song_id', types.Integer(), ForeignKey('songs.id'), default=None), Column('file_name', types.Unicode(255), nullable=False), @@ -189,14 +191,16 @@ def init_schema(url): ) # Definition of the "song_books" table - song_books_table = Table('song_books', metadata, + song_books_table = Table( + 'song_books', metadata, Column('id', types.Integer(), primary_key=True), Column('name', types.Unicode(128), nullable=False), Column('publisher', types.Unicode(128)) ) # Definition of the "songs" table - songs_table = Table('songs', metadata, + songs_table = Table( + 'songs', metadata, Column('id', types.Integer(), primary_key=True), Column('song_book_id', types.Integer(), ForeignKey('song_books.id'), default=None), Column('title', types.Unicode(255), nullable=False), @@ -216,19 +220,22 @@ def init_schema(url): ) # Definition of the "topics" table - topics_table = Table('topics', metadata, + topics_table = Table( + 'topics', metadata, Column('id', types.Integer(), primary_key=True), Column('name', types.Unicode(128), index=True, nullable=False) ) # Definition of the "authors_songs" table - authors_songs_table = Table('authors_songs', metadata, + authors_songs_table = Table( + 'authors_songs', metadata, Column('author_id', types.Integer(), ForeignKey('authors.id'), primary_key=True), Column('song_id', types.Integer(), ForeignKey('songs.id'), primary_key=True) ) # Definition of the "songs_topics" table - songs_topics_table = Table('songs_topics', metadata, + songs_topics_table = Table( + 'songs_topics', metadata, Column('song_id', types.Integer(), ForeignKey('songs.id'), primary_key=True), Column('topic_id', types.Integer(), ForeignKey('topics.id'), primary_key=True) ) @@ -236,13 +243,12 @@ def init_schema(url): mapper(Author, authors_table) mapper(Book, song_books_table) mapper(MediaFile, media_files_table) - mapper(Song, songs_table, - properties={ - 'authors': relation(Author, backref='songs', secondary=authors_songs_table, lazy=False), - 'book': relation(Book, backref='songs'), - 'media_files': relation(MediaFile, backref='songs', order_by=media_files_table.c.weight), - 'topics': relation(Topic, backref='songs', secondary=songs_topics_table) - }) + mapper(Song, songs_table, properties={ + 'authors': relation(Author, backref='songs', secondary=authors_songs_table, lazy=False), + 'book': relation(Book, backref='songs'), + 'media_files': relation(MediaFile, backref='songs', order_by=media_files_table.c.weight), + 'topics': relation(Topic, backref='songs', secondary=songs_topics_table) + }) mapper(Topic, topics_table) metadata.create_all(checkfirst=True) diff --git a/openlp/plugins/songs/lib/dreambeamimport.py b/openlp/plugins/songs/lib/dreambeamimport.py index 18da6d8e3..375867aac 100644 --- a/openlp/plugins/songs/lib/dreambeamimport.py +++ b/openlp/plugins/songs/lib/dreambeamimport.py @@ -120,7 +120,7 @@ class DreamBeamImport(SongImport): author_copyright = song_xml.Author.text if hasattr(song_xml, 'SongLyrics'): for lyrics_item in song_xml.SongLyrics.iterchildren(): - verse_type = lyrics_item.get('Type') + verse_type = lyrics_item.get('Type') verse_number = lyrics_item.get('Number') verse_text = str(lyrics_item.text) self.add_verse(verse_text, ('%s%s' % (verse_type[:1], verse_number))) @@ -145,8 +145,7 @@ class DreamBeamImport(SongImport): author_copyright = song_xml.Text2.Text.text if author_copyright: author_copyright = str(author_copyright) - if author_copyright.find( - str(SongStrings.CopyrightSymbol)) >= 0: + if author_copyright.find(str(SongStrings.CopyrightSymbol)) >= 0: self.add_copyright(author_copyright) else: self.parse_author(author_copyright) diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index 3b6d4e9a8..6f8bd6978 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -298,10 +298,10 @@ class FoilPresenter(object): temp = copyright.partition('Rechte') copyright = temp[0] markers = ['Text +u\.?n?d? +Melodie[\w\,\. ]*:', - 'Text +u\.?n?d? +Musik', 'T & M', 'Melodie und Satz', - 'Text[\w\,\. ]*:', 'Melodie', 'Musik', 'Satz', - 'Weise', '[dD]eutsch', '[dD]t[\.\:]', 'Englisch', - '[oO]riginal', 'Bearbeitung', '[R|r]efrain'] + 'Text +u\.?n?d? +Musik', 'T & M', 'Melodie und Satz', + 'Text[\w\,\. ]*:', 'Melodie', 'Musik', 'Satz', + 'Weise', '[dD]eutsch', '[dD]t[\.\:]', 'Englisch', + '[oO]riginal', 'Bearbeitung', '[R|r]efrain'] for marker in markers: copyright = re.compile(marker).sub('', copyright, re.U) copyright = re.compile('(?<=) *:').sub('', copyright) @@ -324,12 +324,9 @@ class FoilPresenter(object): for tempx in temp: author_temp.append(tempx) for author in author_temp: - regex = '^[\/,;\-\s\.]+|[\/,;\-\s\.]+$|'\ - '\s*[0-9]{4}\s*[\-\/]?\s*([0-9]{4})?[\/,;\-\s\.]*$' + regex = '^[\/,;\-\s\.]+|[\/,;\-\s\.]+$|\s*[0-9]{4}\s*[\-\/]?\s*([0-9]{4})?[\/,;\-\s\.]*$' author = re.compile(regex).sub('', author) - author = re.compile( - '[0-9]{1,2}\.\s?J(ahr)?h\.|um\s*$|vor\s*$').sub('', - author) + author = re.compile('[0-9]{1,2}\.\s?J(ahr)?h\.|um\s*$|vor\s*$').sub('', author) author = re.compile('[N|n]ach.*$').sub('', author) author = author.strip() if re.search('\w+\.?\s+\w{3,}\s+[a|u]nd\s|\w+\.?\s+\w{3,}\s+&\s', author, re.U): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 27571c0ca..ad981135f 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -493,9 +493,9 @@ class SongMediaItem(MediaManagerItem): # FIXME: This file seems to be an old one (prior to 1.9.5), which means, that the search title # (data_string[u'title']) is probably wrong. We add "@" to search title and hope that we do not add any # duplicate. This should work for songs without alternate title. - search_results = self.plugin.manager.get_all_objects(Song, - Song.search_title == (re.compile(r'\W+', re.UNICODE).sub(' ', - item.data_string['title'].strip()) + '@').strip().lower(), Song.search_title.asc()) + temp = (re.compile(r'\W+', re.UNICODE).sub(' ', item.data_string['title'].strip()) + '@').strip().lower() + search_results = \ + self.plugin.manager.get_all_objects(Song, Song.search_title == temp, Song.search_title.asc()) else: search_results = self.plugin.manager.get_all_objects( Song, Song.search_title == item.data_string['title'], Song.search_title.asc()) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index 171859432..335ba606a 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -128,11 +128,9 @@ class OpenLPSongImport(SongImport): except UnmappedClassError: mapper(OldMediaFile, source_media_files_table) song_props = { - 'authors': relation(OldAuthor, backref='songs', - secondary=source_authors_songs_table), + 'authors': relation(OldAuthor, backref='songs', secondary=source_authors_songs_table), 'book': relation(OldBook, backref='songs'), - 'topics': relation(OldTopic, backref='songs', - secondary=source_songs_topics_table) + 'topics': relation(OldTopic, backref='songs', secondary=source_songs_topics_table) } if has_media_files: if isinstance(source_media_files_songs_table, Table): diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index 735ef3afe..72210e89f 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -68,8 +68,8 @@ class OpenLyricsExport(RegistryProperties): self.application.process_events() if self.parent.stop_export_flag: return False - self.parent.increment_progress_bar(translate('SongsPlugin.OpenLyricsExport', 'Exporting "%s"...') % - song.title) + self.parent.increment_progress_bar( + translate('SongsPlugin.OpenLyricsExport', 'Exporting "%s"...') % song.title) xml = open_lyrics.song_to_xml(song) tree = etree.ElementTree(etree.fromstring(xml.encode())) filename = '%s (%s)' % (song.title, ', '.join([author.display_name for author in song.authors])) @@ -81,4 +81,3 @@ class OpenLyricsExport(RegistryProperties): tree.write(open(os.path.join(self.save_path, filename), 'wb'), encoding='utf-8', xml_declaration=True, pretty_print=True) return True - diff --git a/openlp/plugins/songs/lib/powersongimport.py b/openlp/plugins/songs/lib/powersongimport.py index 7c5b9e02e..cd568bc2c 100644 --- a/openlp/plugins/songs/lib/powersongimport.py +++ b/openlp/plugins/songs/lib/powersongimport.py @@ -122,7 +122,7 @@ class PowerSongImport(SongImport): parse_error = True self.log_error(os.path.basename(file), str( translate('SongsPlugin.PowerSongImport', 'Invalid %s file. Unexpected byte value.')) % - ps_string) + ps_string) break else: if label == 'TITLE': @@ -145,7 +145,7 @@ class PowerSongImport(SongImport): if not found_copyright: self.log_error(self.title, str( translate('SongsPlugin.PowerSongImport', 'Invalid %s file. Missing "COPYRIGHTLINE" header.')) % - ps_string) + ps_string) continue # Check that file had at least one verse if not self.verses: diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index a41472201..e44034648 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -287,8 +287,7 @@ class SofImport(OooImport): :param text: The verse text """ - if self.italics != self.is_chorus and ((len(self.verses) > 0) or - (self.current__verse.count('\n') > 1)): + if self.italics != self.is_chorus and ((len(self.verses) > 0) or (self.current__verse.count('\n') > 1)): self.finish_verse() if self.italics: self.is_chorus = True @@ -348,10 +347,10 @@ class SofImport(OooImport): for i in range(1, len(text_arr)): # Do not translate these. Fixed strings in SOF song file if text_arr[i] in ('JESUS', 'CHRIST', 'KING', 'ALMIGHTY', 'REDEEMER', 'SHEPHERD', 'SON', 'GOD', 'LORD', - 'FATHER', 'HOLY', 'SPIRIT', 'LAMB', 'YOU', 'YOUR', 'I', 'I\'VE', 'I\'M', 'I\'LL', - 'SAVIOUR', 'O', 'YOU\'RE', 'HE', 'HIS', 'HIM', 'ZION', 'EMMANUEL', 'MAJESTY', 'JESUS\'', - 'JIREH', 'JUDAH', 'LION', 'LORD\'S', 'ABRAHAM', 'GOD\'S', 'FATHER\'S', 'ELIJAH' 'MARTHA', - 'CHRISTMAS', 'ALPHA', 'OMEGA'): + 'FATHER', 'HOLY', 'SPIRIT', 'LAMB', 'YOU', 'YOUR', 'I', 'I\'VE', 'I\'M', 'I\'LL', + 'SAVIOUR', 'O', 'YOU\'RE', 'HE', 'HIS', 'HIM', 'ZION', 'EMMANUEL', 'MAJESTY', 'JESUS\'', + 'JIREH', 'JUDAH', 'LION', 'LORD\'S', 'ABRAHAM', 'GOD\'S', 'FATHER\'S', + 'ELIJAH' 'MARTHA', 'CHRISTMAS', 'ALPHA', 'OMEGA'): text_arr[i] = text_arr[i].capitalize() else: text_arr[i] = text_arr[i].lower() diff --git a/openlp/plugins/songs/lib/songcompare.py b/openlp/plugins/songs/lib/songcompare.py index 99a04beb2..195923b46 100644 --- a/openlp/plugins/songs/lib/songcompare.py +++ b/openlp/plugins/songs/lib/songcompare.py @@ -113,7 +113,7 @@ def _remove_typos(diff): if len(diff) >= 3: for index in range(len(diff) - 3, -1, -1): if _op_length(diff[index]) >= MIN_FRAGMENT_SIZE and diff[index + 1][0] != "equal" and \ - _op_length(diff[index + 1]) <= MAX_TYPO_SIZE and _op_length(diff[index + 2]) >= MIN_FRAGMENT_SIZE: + _op_length(diff[index + 1]) <= MAX_TYPO_SIZE and _op_length(diff[index + 2]) >= MIN_FRAGMENT_SIZE: del diff[index + 1] # Remove typo at the end of the string. if len(diff) >= 2: diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index bb56f3498..a5fbb99e0 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -364,7 +364,7 @@ class SongImport(QtCore.QObject): """ if not hasattr(self, 'save_path'): self.save_path = os.path.join(AppLocation.get_section_data_path(self.import_wizard.plugin.name), - 'audio', str(song_id)) + 'audio', str(song_id)) check_directory_exists(self.save_path) if not filename.startswith(self.save_path): old_file, filename = filename, os.path.join(self.save_path, os.path.split(filename)[1]) diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index 50a8698c3..485a8f047 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -140,7 +140,7 @@ class SongShowPlusImport(SongImport): elif block_key == AUTHOR: authors = self.decode(data).split(" / ") for author in authors: - if author.find(",") !=-1: + if author.find(",") != -1: author_parts = author.split(", ") author = author_parts[1] + " " + author_parts[0] self.parse_author(author) @@ -220,4 +220,4 @@ class SongShowPlusImport(SongImport): try: return str(data, chardet.detect(data)['encoding']) except: - return str(data, retrieve_windows_encoding()) \ No newline at end of file + return str(data, retrieve_windows_encoding()) diff --git a/openlp/plugins/songs/lib/sundayplusimport.py b/openlp/plugins/songs/lib/sundayplusimport.py index f63d625c5..f22f8b058 100644 --- a/openlp/plugins/songs/lib/sundayplusimport.py +++ b/openlp/plugins/songs/lib/sundayplusimport.py @@ -138,7 +138,7 @@ class SundayPlusImport(SongImport): elif name == 'Copyright': self.copyright = self.decode(self.unescape(value)) elif name[0:4] == 'CELL': - self.parse(value, cell = name[4:]) + self.parse(value, cell=name[4:]) # We are in a verse group. else: if name == 'MARKER_NAME': @@ -207,4 +207,3 @@ class SundayPlusImport(SongImport): text = text.replace('^^', '"') text = text.replace('^', '\'') return text.strip() - diff --git a/openlp/plugins/songs/lib/test/test.opensong b/openlp/plugins/songs/lib/test/test.opensong deleted file mode 100644 index c75951492..000000000 --- a/openlp/plugins/songs/lib/test/test.opensong +++ /dev/null @@ -1,72 +0,0 @@ - - - Martins Test - MartiÑ & Martin2 Thómpson - 2010 Martin Thompson - 1 - V1 C V2 C2 3a B1 V1 T U Rap1 Rap2 Rap3 - Blah - - - - - - - - TestTheme - TestAltTheme - - - [3a] -. G A B - V3 Line 1 -. G A B - V3 Line 2 - -. A B C -1 v1 Line 1___ -2 v2 Line 1___ -. A B C7 -1 V1 Line 2 -2 V2 Line 2 - -[b1] - Bridge 1 ---- --!! - Bridge 1 line 2 - -[C] - . A B - Chorus 1 - -[C2] -. A B - Chorus 2 - -[T] - T Line 1 - -[Rap] -1 Rap 1 Line 1 -2 Rap 2 Line 1 -1 Rap 1 Line 2 -2 Rap 2 Line 2 - -[rap3] - Rap 3 Line 1 - Rap 3 Line 2 - - -[X] - Unreferenced verse line 1 - - diff --git a/openlp/plugins/songs/lib/test/test.opensong.zip b/openlp/plugins/songs/lib/test/test.opensong.zip deleted file mode 100644 index 62588c8904a2e8e15013fbf5bd9297c92e5cdb8d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 855 zcmWIWW@Zs#U|`^2u$=MIW@{?H(sCvShD3G-23`gkhLY6c621I_)V$*Sy!6lzP6lSa z6muUCF0J5ZU}Sm0%)kI9u7-N&-8K-o`&vY}?Cp!k3wQ$}9di%7Saf&kJ(flX&n+%3 zLadXD9^YG({!*}LBcJEVqDkwxwq&F_JlRtz!*{>u#g}IrMGF$Vif^vm8OBZZC%{)jj+Rk`$AbXjrE?mg1CnpW!g9WK7StNN(PYaY`X_1n4= znRm08alV$&iYN~ejn(|xV7E- z3A5|zeeUsk6~}E3`s>b-CtEV3qe)48g zCf~ukpX@eF`sMoBgtKY4lH2{LkE^z=JDMb@qo!}y>glY#BYfU8{;iW{Xk|3_&UwGo#B6ECxo=v#j>$L1W##>uuU;5 - - Martins 2nd Test - Martin Thompson - 2010 Martin Thompson - 2 - - Blah - - - - - - - - - - - ;Comment -[V] -. A B C -1 v1 Line 1___ -2 v2 Line 1___ -. A B C7 -1 V1 Line 2 -2 V2 Line 2 - -[b1] - Bridge 1 - Bridge 1 line 2 -[C1] - Chorus 1 - -[C2] - Chorus 2 - - diff --git a/openlp/plugins/songs/lib/test/test3.opensong b/openlp/plugins/songs/lib/test/test3.opensong deleted file mode 100644 index 388ab53c7..000000000 --- a/openlp/plugins/songs/lib/test/test3.opensong +++ /dev/null @@ -1,10 +0,0 @@ - - - Test single verse - Martin Thompson - 2010 - 123456 - Worship: Declaration - Line 1 -Line 2 - diff --git a/openlp/plugins/songs/lib/test/test_import_file.py b/openlp/plugins/songs/lib/test/test_import_file.py deleted file mode 100644 index 137d8a7e2..000000000 --- a/openlp/plugins/songs/lib/test/test_import_file.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2014 Raoul Snyman # -# Portions copyright (c) 2008-2014 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, Patrick Zimmermann # -# --------------------------------------------------------------------------- # -# 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 # -############################################################################### -import sys - -from openlp.plugins.songs.lib.opensongimport import OpenSongImport -from openlp.core.lib.db import Manager -from openlp.plugins.songs.lib.db import init_schema - -import logging -LOG_FILENAME = 'test_import_file.log' -logging.basicConfig(filename=LOG_FILENAME,level=logging.INFO) - -from test_opensongimport import wizard_stub - -def test(filenames): - manager = Manager('songs', init_schema) - o = OpenSongImport(manager, filenames=filenames) - o.import_wizard = wizard_stub() - o.commit = False - o.do_import() - o.print_song() - -if __name__ == "__main__": - test(sys.argv[1:]) diff --git a/openlp/plugins/songs/lib/test/test_importing_lots.py b/openlp/plugins/songs/lib/test/test_importing_lots.py deleted file mode 100644 index c7293ae0e..000000000 --- a/openlp/plugins/songs/lib/test/test_importing_lots.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2014 Raoul Snyman # -# Portions copyright (c) 2008-2014 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, Patrick Zimmermann # -# --------------------------------------------------------------------------- # -# 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 # -############################################################################### - -from openlp.plugins.songs.lib.opensongimport import OpenSongImport -from openlp.plugins.songs.lib.db import init_schema -from openlp.core.lib.db import Manager -import os -import codecs - -import logging -LOG_FILENAME = 'import.log' -logging.basicConfig(filename=LOG_FILENAME,level=logging.INFO) - -from test_opensongimport import wizard_stub - -# Useful test function for importing a variety of different files -# Uncomment below depending on what problem trying to make occur! - -def opensong_import_lots(): - ziploc = '/home/mjt/openlp/OpenSong_Data/' - files = [] - files = [os.path.join(ziploc, 'RaoulSongs', 'Songs', 'Jesus Freak')] - # files.extend(glob(ziploc+u'Songs.zip')) - # files.extend(glob(ziploc+u'RaoulSongs.zip')) - # files.extend(glob(ziploc+u'SOF.zip')) - # files.extend(glob(ziploc+u'spanish_songs_for_opensong.zip')) - # files.extend(glob(ziploc+u'opensong_*.zip')) - errfile = codecs.open('import_lots_errors.txt', 'w', 'utf8') - manager = Manager('songs', init_schema) - o = OpenSongImport(manager, filenames=files) - o.import_wizard=wizard_stub() - o.do_import() - -if __name__ == "__main__": - opensong_import_lots() diff --git a/openlp/plugins/songs/lib/ui.py b/openlp/plugins/songs/lib/ui.py index a2fe38c74..14f4777c9 100644 --- a/openlp/plugins/songs/lib/ui.py +++ b/openlp/plugins/songs/lib/ui.py @@ -40,11 +40,11 @@ class SongStrings(object): # These strings should need a good reason to be retranslated elsewhere. Author = translate('OpenLP.Ui', 'Author', 'Singular') Authors = translate('OpenLP.Ui', 'Authors', 'Plural') - AuthorUnknown = 'Author Unknown' # Used to populate the database. + AuthorUnknown = 'Author Unknown' # Used to populate the database. CopyrightSymbol = translate('OpenLP.Ui', '\xa9', 'Copyright symbol.') SongBook = translate('OpenLP.Ui', 'Song Book', 'Singular') SongBooks = translate('OpenLP.Ui', 'Song Books', 'Plural') - SongIncomplete = translate('OpenLP.Ui','Title and/or verses not found') + SongIncomplete = translate('OpenLP.Ui', 'Title and/or verses not found') SongMaintenance = translate('OpenLP.Ui', 'Song Maintenance') Topic = translate('OpenLP.Ui', 'Topic', 'Singular') Topics = translate('OpenLP.Ui', 'Topics', 'Plural') diff --git a/openlp/plugins/songs/lib/upgrade.py b/openlp/plugins/songs/lib/upgrade.py index ee01fb8b0..fdb0f17ef 100644 --- a/openlp/plugins/songs/lib/upgrade.py +++ b/openlp/plugins/songs/lib/upgrade.py @@ -82,4 +82,3 @@ def upgrade_3(session, metadata): op.add_column('songs', Column('temporary', types.Boolean(create_constraint=False), server_default=false())) else: op.add_column('songs', Column('temporary', types.Boolean(), server_default=false())) - diff --git a/openlp/plugins/songs/lib/worshipcenterproimport.py b/openlp/plugins/songs/lib/worshipcenterproimport.py index 80b1b5fe3..b24d2ae83 100644 --- a/openlp/plugins/songs/lib/worshipcenterproimport.py +++ b/openlp/plugins/songs/lib/worshipcenterproimport.py @@ -56,12 +56,12 @@ class WorshipCenterProImport(SongImport): Receive a single file to import. """ try: - conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=%s' % self.import_source) + conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=%s' % self.import_source) except (pyodbc.DatabaseError, pyodbc.IntegrityError, pyodbc.InternalError, pyodbc.OperationalError) as e: log.warn('Unable to connect the WorshipCenter Pro database %s. %s', self.import_source, str(e)) # Unfortunately no specific exception type - self.log_error(self.import_source, - translate('SongsPlugin.WorshipCenterProImport', 'Unable to connect the WorshipCenter Pro database.')) + self.log_error(self.import_source, translate('SongsPlugin.WorshipCenterProImport', + 'Unable to connect the WorshipCenter Pro database.')) return cursor = conn.cursor() cursor.execute('SELECT ID, Field, Value FROM __SONGDATA') diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 95ae4fc33..667afebdd 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -340,7 +340,8 @@ class OpenLyrics(object): The first unicode string are the start tags (for the next slide). The second unicode string are the end tags. - :param text: The text to test. The text must **not** contain html tags, only OpenLP formatting tags are allowed:: + :param text: The text to test. The text must **not** contain html tags, only OpenLP formatting tags + are allowed:: {st}{r}Text text text """ diff --git a/openlp/plugins/songs/lib/zionworximport.py b/openlp/plugins/songs/lib/zionworximport.py index ab6bcb27d..dfdc2373d 100644 --- a/openlp/plugins/songs/lib/zionworximport.py +++ b/openlp/plugins/songs/lib/zionworximport.py @@ -39,7 +39,7 @@ from openlp.plugins.songs.lib.songimport import SongImport log = logging.getLogger(__name__) # Used to strip control chars (except 10=LF, 13=CR) -CONTROL_CHARS_MAP = dict.fromkeys(list(range(10)) + [11, 12] + list(range(14,32)) + [127]) +CONTROL_CHARS_MAP = dict.fromkeys(list(range(10)) + [11, 12] + list(range(14, 32)) + [127]) class ZionWorxImport(SongImport): diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 32d3ddbe6..1c000338c 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -342,7 +342,7 @@ class SongsPlugin(Plugin): """ Remove temporary songs from the database """ - songs = self.manager.get_all_objects(Song, Song.temporary == True) + songs = self.manager.get_all_objects(Song, Song.temporary is True) for song in songs: self.manager.delete_object(Song, song.id)