forked from openlp/openlp
make stuff prettier...
This commit is contained in:
parent
dca65148c4
commit
45b122f768
@ -48,7 +48,6 @@ from .importers.powerpraise import PowerPraiseImport
|
|||||||
from .importers.presentationmanager import PresentationManagerImport
|
from .importers.presentationmanager import PresentationManagerImport
|
||||||
from .importers.lyrix import LyrixImport
|
from .importers.lyrix import LyrixImport
|
||||||
from .importers.videopsalm import VideoPsalmImport
|
from .importers.videopsalm import VideoPsalmImport
|
||||||
from .importers.opspro import OpsProImport
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -82,10 +81,10 @@ if is_win():
|
|||||||
HAS_OPSPRO = False
|
HAS_OPSPRO = False
|
||||||
if is_win():
|
if is_win():
|
||||||
try:
|
try:
|
||||||
from .importers.opspro import OpsProImport
|
from .importers.opspro import OPSProImport
|
||||||
HAS_OPSPRO = True
|
HAS_OPSPRO = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
log.exception('Error importing %s', 'OpsProImport')
|
log.exception('Error importing %s', 'OPSProImport')
|
||||||
|
|
||||||
|
|
||||||
class SongFormatSelect(object):
|
class SongFormatSelect(object):
|
||||||
@ -164,21 +163,21 @@ class SongFormat(object):
|
|||||||
Lyrix = 9
|
Lyrix = 9
|
||||||
MediaShout = 10
|
MediaShout = 10
|
||||||
OpenSong = 11
|
OpenSong = 11
|
||||||
PowerPraise = 12
|
OPSPro = 12
|
||||||
PowerSong = 13
|
PowerPraise = 13
|
||||||
PresentationManager = 14
|
PowerSong = 14
|
||||||
ProPresenter = 15
|
PresentationManager = 15
|
||||||
SongBeamer = 16
|
ProPresenter = 16
|
||||||
SongPro = 17
|
SongBeamer = 17
|
||||||
SongShowPlus = 18
|
SongPro = 18
|
||||||
SongsOfFellowship = 19
|
SongShowPlus = 19
|
||||||
SundayPlus = 20
|
SongsOfFellowship = 20
|
||||||
VideoPsalm = 21
|
SundayPlus = 21
|
||||||
WordsOfWorship = 22
|
VideoPsalm = 22
|
||||||
WorshipAssistant = 23
|
WordsOfWorship = 23
|
||||||
WorshipCenterPro = 24
|
WorshipAssistant = 24
|
||||||
ZionWorx = 25
|
WorshipCenterPro = 25
|
||||||
OPSPro = 26
|
ZionWorx = 26
|
||||||
|
|
||||||
# Set optional attribute defaults
|
# Set optional attribute defaults
|
||||||
__defaults__ = {
|
__defaults__ = {
|
||||||
@ -281,6 +280,17 @@ class SongFormat(object):
|
|||||||
'name': WizardStrings.OS,
|
'name': WizardStrings.OS,
|
||||||
'prefix': 'openSong'
|
'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: {
|
PowerPraise: {
|
||||||
'class': PowerPraiseImport,
|
'class': PowerPraiseImport,
|
||||||
'name': 'PowerPraise',
|
'name': 'PowerPraise',
|
||||||
@ -391,17 +401,6 @@ class SongFormat(object):
|
|||||||
'First convert your ZionWorx database to a CSV text file, as '
|
'First convert your ZionWorx database to a CSV text file, as '
|
||||||
'explained in the <a href="http://manual.openlp.org/songs.html'
|
'explained in the <a href="http://manual.openlp.org/songs.html'
|
||||||
'#importing-from-zionworx">User Manual</a>.')
|
'#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.Lyrix,
|
||||||
SongFormat.MediaShout,
|
SongFormat.MediaShout,
|
||||||
SongFormat.OpenSong,
|
SongFormat.OpenSong,
|
||||||
|
SongFormat.OPSPro,
|
||||||
SongFormat.PowerPraise,
|
SongFormat.PowerPraise,
|
||||||
SongFormat.PowerSong,
|
SongFormat.PowerSong,
|
||||||
SongFormat.PresentationManager,
|
SongFormat.PresentationManager,
|
||||||
@ -436,8 +436,7 @@ class SongFormat(object):
|
|||||||
SongFormat.WordsOfWorship,
|
SongFormat.WordsOfWorship,
|
||||||
SongFormat.WorshipAssistant,
|
SongFormat.WorshipAssistant,
|
||||||
SongFormat.WorshipCenterPro,
|
SongFormat.WorshipCenterPro,
|
||||||
SongFormat.ZionWorx,
|
SongFormat.ZionWorx
|
||||||
SongFormat.OPSPro
|
|
||||||
])
|
])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -488,7 +487,7 @@ if HAS_WORSHIPCENTERPRO:
|
|||||||
SongFormat.set(SongFormat.WorshipCenterPro, 'class', WorshipCenterProImport)
|
SongFormat.set(SongFormat.WorshipCenterPro, 'class', WorshipCenterProImport)
|
||||||
SongFormat.set(SongFormat.OPSPro, 'availability', HAS_OPSPRO)
|
SongFormat.set(SongFormat.OPSPro, 'availability', HAS_OPSPRO)
|
||||||
if HAS_OPSPRO:
|
if HAS_OPSPRO:
|
||||||
SongFormat.set(SongFormat.OPSPro, 'class', OpsProImport)
|
SongFormat.set(SongFormat.OPSPro, 'class', OPSProImport)
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['SongFormat', 'SongFormatSelect']
|
__all__ = ['SongFormat', 'SongFormatSelect']
|
||||||
|
@ -25,8 +25,6 @@ a OPS Pro database into the OpenLP database.
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import os
|
|
||||||
if os.name == 'nt':
|
|
||||||
import pyodbc
|
import pyodbc
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
@ -36,16 +34,16 @@ from openlp.plugins.songs.lib.importers.songimport import SongImport
|
|||||||
log = logging.getLogger(__name__)
|
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
|
WorshipCenter Pro Access Database
|
||||||
"""
|
"""
|
||||||
def __init__(self, manager, **kwargs):
|
def __init__(self, manager, **kwargs):
|
||||||
"""
|
"""
|
||||||
Initialise the WorshipCenter Pro importer.
|
Initialise the WorshipCenter Pro importer.
|
||||||
"""
|
"""
|
||||||
super(OpsProImport, self).__init__(manager, **kwargs)
|
super(OPSProImport, self).__init__(manager, **kwargs)
|
||||||
|
|
||||||
def do_import(self):
|
def do_import(self):
|
||||||
"""
|
"""
|
||||||
@ -58,7 +56,7 @@ class OpsProImport(SongImport):
|
|||||||
except (pyodbc.DatabaseError, pyodbc.IntegrityError, pyodbc.InternalError, pyodbc.OperationalError) as e:
|
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))
|
log.warning('Unable to connect the OPS Pro database %s. %s', self.import_source, str(e))
|
||||||
# Unfortunately no specific exception type
|
# 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.'))
|
'Unable to connect the OPS Pro database.'))
|
||||||
return
|
return
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
@ -26,10 +26,13 @@ import os
|
|||||||
import json
|
import json
|
||||||
from unittest import TestCase, SkipTest
|
from unittest import TestCase, SkipTest
|
||||||
|
|
||||||
|
if os.name != 'nt':
|
||||||
|
raise SkipTest('Not Windows, skipping test')
|
||||||
|
|
||||||
from tests.functional import patch, MagicMock
|
from tests.functional import patch, MagicMock
|
||||||
|
|
||||||
from openlp.core.common import Registry
|
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'))
|
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'opsprosongs'))
|
||||||
|
|
||||||
@ -53,7 +56,7 @@ class TestOpsProSongImport(TestCase):
|
|||||||
mocked_manager = MagicMock()
|
mocked_manager = MagicMock()
|
||||||
|
|
||||||
# WHEN: An importer object is created
|
# WHEN: An importer object is created
|
||||||
importer = OpsProImport(mocked_manager, filenames=[])
|
importer = OPSProImport(mocked_manager, filenames=[])
|
||||||
|
|
||||||
# THEN: The importer object should not be None
|
# THEN: The importer object should not be None
|
||||||
self.assertIsNotNone(importer, 'Import 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
|
# GIVEN: A mocked out SongImport class, a mocked out "manager" and a mocked song and lyrics entry
|
||||||
mocked_manager = MagicMock()
|
mocked_manager = MagicMock()
|
||||||
importer = OpsProImport(mocked_manager, filenames=[])
|
importer = OPSProImport(mocked_manager, filenames=[])
|
||||||
importer.finish = MagicMock()
|
importer.finish = MagicMock()
|
||||||
song, lyrics = self._build_test_data('you are so faithfull.txt', False)
|
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
|
# GIVEN: A mocked out SongImport class, a mocked out "manager" and a mocked song and lyrics entry
|
||||||
mocked_manager = MagicMock()
|
mocked_manager = MagicMock()
|
||||||
importer = OpsProImport(mocked_manager, filenames=[])
|
importer = OPSProImport(mocked_manager, filenames=[])
|
||||||
importer.finish = MagicMock()
|
importer.finish = MagicMock()
|
||||||
song, lyrics = self._build_test_data('amazing grace.txt', False)
|
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
|
# GIVEN: A mocked out SongImport class, a mocked out "manager" and a mocked song and lyrics entry
|
||||||
mocked_manager = MagicMock()
|
mocked_manager = MagicMock()
|
||||||
importer = OpsProImport(mocked_manager, filenames=[])
|
importer = OPSProImport(mocked_manager, filenames=[])
|
||||||
importer.finish = MagicMock()
|
importer.finish = MagicMock()
|
||||||
song, lyrics = self._build_test_data('amazing grace2.txt', True)
|
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
|
# GIVEN: A mocked out SongImport class, a mocked out "manager" and a mocked song and lyrics entry
|
||||||
mocked_manager = MagicMock()
|
mocked_manager = MagicMock()
|
||||||
importer = OpsProImport(mocked_manager, filenames=[])
|
importer = OPSProImport(mocked_manager, filenames=[])
|
||||||
importer.finish = MagicMock()
|
importer.finish = MagicMock()
|
||||||
song, lyrics = self._build_test_data('amazing grace3.txt', True)
|
song, lyrics = self._build_test_data('amazing grace3.txt', True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user