make stuff prettier...

This commit is contained in:
Tomas Groth 2016-03-20 09:28:41 +01:00
parent dca65148c4
commit 45b122f768
3 changed files with 45 additions and 45 deletions

View File

@ -48,7 +48,6 @@ from .importers.powerpraise import PowerPraiseImport
from .importers.presentationmanager import PresentationManagerImport
from .importers.lyrix import LyrixImport
from .importers.videopsalm import VideoPsalmImport
from .importers.opspro import OpsProImport
log = logging.getLogger(__name__)
@ -82,10 +81,10 @@ if is_win():
HAS_OPSPRO = False
if is_win():
try:
from .importers.opspro import OpsProImport
from .importers.opspro import OPSProImport
HAS_OPSPRO = True
except ImportError:
log.exception('Error importing %s', 'OpsProImport')
log.exception('Error importing %s', 'OPSProImport')
class SongFormatSelect(object):
@ -164,21 +163,21 @@ class SongFormat(object):
Lyrix = 9
MediaShout = 10
OpenSong = 11
PowerPraise = 12
PowerSong = 13
PresentationManager = 14
ProPresenter = 15
SongBeamer = 16
SongPro = 17
SongShowPlus = 18
SongsOfFellowship = 19
SundayPlus = 20
VideoPsalm = 21
WordsOfWorship = 22
WorshipAssistant = 23
WorshipCenterPro = 24
ZionWorx = 25
OPSPro = 26
OPSPro = 12
PowerPraise = 13
PowerSong = 14
PresentationManager = 15
ProPresenter = 16
SongBeamer = 17
SongPro = 18
SongShowPlus = 19
SongsOfFellowship = 20
SundayPlus = 21
VideoPsalm = 22
WordsOfWorship = 23
WorshipAssistant = 24
WorshipCenterPro = 25
ZionWorx = 26
# Set optional attribute defaults
__defaults__ = {
@ -281,6 +280,17 @@ class SongFormat(object):
'name': WizardStrings.OS,
'prefix': 'openSong'
},
OPSPro: {
'name': 'OPS Pro',
'prefix': 'OPSPro',
'canDisable': True,
'selectMode': SongFormatSelect.SingleFile,
'filter': '%s (*.mdb)' % translate('SongsPlugin.ImportWizardForm', 'OPS Pro database'),
'disabledLabelText': translate('SongsPlugin.ImportWizardForm',
'The OPS Pro importer is only supported on Windows. It has been '
'disabled due to a missing Python module. If you want to use this '
'importer, you will need to install the "pyodbc" module.')
},
PowerPraise: {
'class': PowerPraiseImport,
'name': 'PowerPraise',
@ -391,17 +401,6 @@ class SongFormat(object):
'First convert your ZionWorx database to a CSV text file, as '
'explained in the <a href="http://manual.openlp.org/songs.html'
'#importing-from-zionworx">User Manual</a>.')
},
OPSPro: {
'name': 'OPS Pro',
'prefix': 'OPSPro',
'canDisable': True,
'selectMode': SongFormatSelect.SingleFile,
'filter': '%s (*.mdb)' % translate('SongsPlugin.ImportWizardForm', 'OPS Pro database'),
'disabledLabelText': translate('SongsPlugin.ImportWizardForm',
'The OPS Pro importer is only supported on Windows. It has been '
'disabled due to a missing Python module. If you want to use this '
'importer, you will need to install the "pyodbc" module.')
}
}
@ -423,6 +422,7 @@ class SongFormat(object):
SongFormat.Lyrix,
SongFormat.MediaShout,
SongFormat.OpenSong,
SongFormat.OPSPro,
SongFormat.PowerPraise,
SongFormat.PowerSong,
SongFormat.PresentationManager,
@ -436,8 +436,7 @@ class SongFormat(object):
SongFormat.WordsOfWorship,
SongFormat.WorshipAssistant,
SongFormat.WorshipCenterPro,
SongFormat.ZionWorx,
SongFormat.OPSPro
SongFormat.ZionWorx
])
@staticmethod
@ -488,7 +487,7 @@ if HAS_WORSHIPCENTERPRO:
SongFormat.set(SongFormat.WorshipCenterPro, 'class', WorshipCenterProImport)
SongFormat.set(SongFormat.OPSPro, 'availability', HAS_OPSPRO)
if HAS_OPSPRO:
SongFormat.set(SongFormat.OPSPro, 'class', OpsProImport)
SongFormat.set(SongFormat.OPSPro, 'class', OPSProImport)
__all__ = ['SongFormat', 'SongFormatSelect']

View File

@ -25,9 +25,7 @@ a OPS Pro database into the OpenLP database.
"""
import logging
import re
import os
if os.name == 'nt':
import pyodbc
import pyodbc
import struct
from openlp.core.common import translate
@ -36,16 +34,16 @@ from openlp.plugins.songs.lib.importers.songimport import SongImport
log = logging.getLogger(__name__)
class OpsProImport(SongImport):
class OPSProImport(SongImport):
"""
The :class:`OpsProImport` class provides the ability to import the
The :class:`OPSProImport` class provides the ability to import the
WorshipCenter Pro Access Database
"""
def __init__(self, manager, **kwargs):
"""
Initialise the WorshipCenter Pro importer.
"""
super(OpsProImport, self).__init__(manager, **kwargs)
super(OPSProImport, self).__init__(manager, **kwargs)
def do_import(self):
"""
@ -58,7 +56,7 @@ class OpsProImport(SongImport):
except (pyodbc.DatabaseError, pyodbc.IntegrityError, pyodbc.InternalError, pyodbc.OperationalError) as e:
log.warning('Unable to connect the OPS Pro database %s. %s', self.import_source, str(e))
# Unfortunately no specific exception type
self.log_error(self.import_source, translate('SongsPlugin.OpsProImport',
self.log_error(self.import_source, translate('SongsPlugin.OPSProImport',
'Unable to connect the OPS Pro database.'))
return
cursor = conn.cursor()

View File

@ -26,10 +26,13 @@ import os
import json
from unittest import TestCase, SkipTest
if os.name != 'nt':
raise SkipTest('Not Windows, skipping test')
from tests.functional import patch, MagicMock
from openlp.core.common import Registry
from openlp.plugins.songs.lib.importers.opspro import OpsProImport
from openlp.plugins.songs.lib.importers.opspro import OPSProImport
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'opsprosongs'))
@ -53,7 +56,7 @@ class TestOpsProSongImport(TestCase):
mocked_manager = MagicMock()
# WHEN: An importer object is created
importer = OpsProImport(mocked_manager, filenames=[])
importer = OPSProImport(mocked_manager, filenames=[])
# THEN: The importer object should not be None
self.assertIsNotNone(importer, 'Import should not be none')
@ -65,7 +68,7 @@ class TestOpsProSongImport(TestCase):
"""
# GIVEN: A mocked out SongImport class, a mocked out "manager" and a mocked song and lyrics entry
mocked_manager = MagicMock()
importer = OpsProImport(mocked_manager, filenames=[])
importer = OPSProImport(mocked_manager, filenames=[])
importer.finish = MagicMock()
song, lyrics = self._build_test_data('you are so faithfull.txt', False)
@ -85,7 +88,7 @@ class TestOpsProSongImport(TestCase):
"""
# GIVEN: A mocked out SongImport class, a mocked out "manager" and a mocked song and lyrics entry
mocked_manager = MagicMock()
importer = OpsProImport(mocked_manager, filenames=[])
importer = OPSProImport(mocked_manager, filenames=[])
importer.finish = MagicMock()
song, lyrics = self._build_test_data('amazing grace.txt', False)
@ -105,7 +108,7 @@ class TestOpsProSongImport(TestCase):
"""
# GIVEN: A mocked out SongImport class, a mocked out "manager" and a mocked song and lyrics entry
mocked_manager = MagicMock()
importer = OpsProImport(mocked_manager, filenames=[])
importer = OPSProImport(mocked_manager, filenames=[])
importer.finish = MagicMock()
song, lyrics = self._build_test_data('amazing grace2.txt', True)
@ -125,7 +128,7 @@ class TestOpsProSongImport(TestCase):
"""
# GIVEN: A mocked out SongImport class, a mocked out "manager" and a mocked song and lyrics entry
mocked_manager = MagicMock()
importer = OpsProImport(mocked_manager, filenames=[])
importer = OPSProImport(mocked_manager, filenames=[])
importer.finish = MagicMock()
song, lyrics = self._build_test_data('amazing grace3.txt', True)