Fix all formatting errors

This commit is contained in:
Tim Bentley 2014-03-21 21:38:08 +00:00
parent 9dfc446ebd
commit bbe4169c24
42 changed files with 111 additions and 354 deletions

View File

@ -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')

View File

@ -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'),
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)
])
(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]

View File

@ -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:

View File

@ -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:

View File

@ -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,7 +170,7 @@ 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()))
filename = str(self.pptEdit.text().replace('/', '\\'))
@ -178,7 +179,7 @@ class PPTViewer(QtGui.QWidget):
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')

View File

@ -144,6 +144,3 @@ class HTTPSServer(HTTPServer):
server_side=True)
self.server_bind()
self.server_activate()

View File

@ -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

View File

@ -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):

View File

@ -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.'))

View File

@ -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()]

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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,8 +243,7 @@ def init_schema(url):
mapper(Author, authors_table)
mapper(Book, song_books_table)
mapper(MediaFile, media_files_table)
mapper(Song, songs_table,
properties={
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),

View File

@ -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)

View File

@ -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):

View File

@ -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())

View File

@ -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):

View File

@ -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

View File

@ -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
@ -350,8 +349,8 @@ class SofImport(OooImport):
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'):
'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()

View File

@ -207,4 +207,3 @@ class SundayPlusImport(SongImport):
text = text.replace('^^', '"')
text = text.replace('^', '\'')
return text.strip()

View File

@ -1,72 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<song>
<title>Martins Test</title>
<author>MartiÑ &amp; Martin2 Thómpson</author>
<copyright>2010 Martin Thompson</copyright>
<hymn_number>1</hymn_number>
<presentation>V1 C V2 C2 3a B1 V1 T U Rap1 Rap2 Rap3</presentation>
<ccli>Blah</ccli>
<capo print="false"></capo>
<key></key>
<aka></aka>
<key_line></key_line>
<user1></user1>
<user2></user2>
<user3></user3>
<theme>TestTheme</theme>
<alttheme>TestAltTheme</alttheme>
<tempo></tempo>
<time_sig></time_sig>
<lyrics>[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
</lyrics>
<style index="default_style">
<title enabled="true" valign="bottom" align="center" include_verse="false" margin-left="0" margin-right="0" margin-top="0" margin-bottom="0" font="Helvetica" size="26" bold="true" italic="true" underline="false" color="#FFFFFF" border="true" border_color="#000000" shadow="true" shadow_color="#000000" fill="false" fill_color="#000000"/>
<subtitle enabled="true" valign="bottom" align="center" descriptive="false" margin-left="0" margin-right="0" margin-top="0" margin-bottom="0" font="Helvetica" size="18" bold="true" italic="true" underline="false" color="#FFFFFF" border="true" border_color="#000000" shadow="true" shadow_color="#000000" fill="false" fill_color="#000000"/>
<song_subtitle>author</song_subtitle>
<body enabled="true" auto_scale="false" valign="middle" align="center" highlight_chorus="true" margin-left="0" margin-right="0" margin-top="0" margin-bottom="0" font="Helvetica" size="34" bold="true" italic="false" underline="false" color="#FFFFFF" border="true" border_color="#000000" shadow="true" shadow_color="#000000" fill="false" fill_color="#FF0000">
<tabs/>
</body>
<background strip_footer="0" color="#408080" position="1"/>
</style></song>

View File

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<song>
<title>Martins 2nd Test</title>
<author>Martin Thompson</author>
<copyright>2010 Martin Thompson</copyright>
<hymn_number>2</hymn_number>
<presentation></presentation>
<ccli>Blah</ccli>
<capo print="false"></capo>
<key></key>
<aka></aka>
<key_line></key_line>
<user1></user1>
<user2></user2>
<user3></user3>
<theme></theme>
<tempo></tempo>
<time_sig></time_sig>
<lyrics>;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
</lyrics>
<style index="default_style">
<title enabled="true" valign="bottom" align="center" include_verse="false" margin-left="0" margin-right="0" margin-top="0" margin-bottom="0" font="Helvetica" size="26" bold="true" italic="true" underline="false" color="#FFFFFF" border="true" border_color="#000000" shadow="true" shadow_color="#000000" fill="false" fill_color="#000000"/>
<subtitle enabled="true" valign="bottom" align="center" descriptive="false" margin-left="0" margin-right="0" margin-top="0" margin-bottom="0" font="Helvetica" size="18" bold="true" italic="true" underline="false" color="#FFFFFF" border="true" border_color="#000000" shadow="true" shadow_color="#000000" fill="false" fill_color="#000000"/>
<song_subtitle>author</song_subtitle>
<body enabled="true" auto_scale="false" valign="middle" align="center" highlight_chorus="true" margin-left="0" margin-right="0" margin-top="0" margin-bottom="0" font="Helvetica" size="34" bold="true" italic="false" underline="false" color="#FFFFFF" border="true" border_color="#000000" shadow="true" shadow_color="#000000" fill="false" fill_color="#FF0000">
<tabs/>
</body>
<background strip_footer="0" color="#408080" position="1"/>
</style></song>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<song>
<title>Test single verse</title>
<author>Martin Thompson</author>
<copyright>2010</copyright>
<ccli>123456</ccli>
<theme>Worship: Declaration</theme>
<lyrics> Line 1
Line 2
</lyrics></song>

View File

@ -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:])

View File

@ -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()

View File

@ -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()))

View File

@ -60,8 +60,8 @@ class WorshipCenterProImport(SongImport):
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')

View File

@ -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
"""

View File

@ -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)