Refactor SongFormatAttr into SongFormat. PascalCase for enumeration.

This commit is contained in:
Samuel Findlay 2012-06-03 23:50:57 +10:00
parent d9ed9aaa5c
commit 7b97c15fc7
4 changed files with 231 additions and 244 deletions

View File

@ -36,8 +36,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, SettingsManager, translate
from openlp.core.lib.ui import UiStrings, critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
from openlp.plugins.songs.lib.importer import SongFormat, SongFormatAttr, \
SongFormatSelect
from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect
log = logging.getLogger(__name__)
@ -88,7 +87,7 @@ class SongImportForm(OpenLPWizard):
Song wizard specific initialisation.
"""
for format in SongFormat.get_format_list():
if not SongFormatAttr.get(format, SongFormatAttr.availability):
if not SongFormat.get(format, SongFormat.Availability):
self.formatWidgets[format][u'disabledWidget'].setVisible(True)
self.formatWidgets[format][u'importWidget'].setVisible(False)
@ -97,7 +96,7 @@ class SongImportForm(OpenLPWizard):
Song wizard specific signals.
"""
for format in SongFormat.get_format_list():
select_mode = SongFormatAttr.get(format, SongFormatAttr.select_mode)
select_mode = SongFormat.get(format, SongFormat.SelectMode)
if select_mode == SongFormatSelect.MultipleFiles:
QtCore.QObject.connect(self.formatWidgets[format][u'addButton'],
QtCore.SIGNAL(u'clicked()'), self.onAddButtonClicked)
@ -161,9 +160,9 @@ class SongImportForm(OpenLPWizard):
self.sourcePage.setSubTitle(WizardStrings.ImportSelectLong)
self.formatLabel.setText(WizardStrings.FormatLabel)
for format in SongFormat.get_format_list():
format_name, custom_combo_text, select_mode = SongFormatAttr.get(
format, SongFormatAttr.name, SongFormatAttr.combo_box_text,
SongFormatAttr.select_mode)
format_name, custom_combo_text, select_mode = SongFormat.get(
format, SongFormat.Name, SongFormat.ComboBoxText,
SongFormat.SelectMode)
combo_box_text = custom_combo_text if custom_combo_text \
else format_name
self.formatComboBox.setItemText(format, combo_box_text)
@ -182,7 +181,7 @@ class SongImportForm(OpenLPWizard):
translate('SongsPlugin.ImportWizardForm', f_label))
for format in self.disablableFormats:
self.formatWidgets[format][u'disabledLabel'].setText(
SongFormatAttr.get(format, SongFormatAttr.disabled_label_text))
SongFormat.get(format, SongFormat.DisabledLabelText))
self.progressPage.setTitle(WizardStrings.Importing)
self.progressPage.setSubTitle(
translate('SongsPlugin.ImportWizardForm',
@ -194,8 +193,8 @@ class SongImportForm(OpenLPWizard):
self.errorSaveToButton.setText(translate('SongsPlugin.ImportWizardForm',
'Save to File'))
# Align all QFormLayouts towards each other.
formats = filter(lambda f: u'filepathLabel' in
self.formatWidgets[f], SongFormat.get_format_list())
formats = filter(lambda f: u'filepathLabel' in self.formatWidgets[f],
SongFormat.get_format_list())
labels = [self.formatWidgets[f][u'filepathLabel'] for f in formats]
# Get max width of all labels
max_label_width = max(self.formatLabel.minimumSizeHint().width(),
@ -228,9 +227,9 @@ class SongImportForm(OpenLPWizard):
format = self.currentFormat
QtCore.QSettings().setValue(u'songs/last import type',
format)
select_mode, class_, error_msg = \
SongFormatAttr.get(format, SongFormatAttr.select_mode,
SongFormatAttr.class_, SongFormatAttr.invalid_source_msg)
select_mode, class_, error_msg = SongFormat.get(format,
SongFormat.SelectMode, SongFormat.Class,
SongFormat.InvalidSourceMsg)
if select_mode == SongFormatSelect.MultipleFiles:
import_source = self.getListOfFiles(
self.formatWidgets[format][u'fileListWidget'])
@ -293,9 +292,8 @@ class SongImportForm(OpenLPWizard):
def onBrowseButtonClicked(self):
format = self.currentFormat
select_mode, format_name, filter = SongFormatAttr.get(format,
SongFormatAttr.select_mode, SongFormatAttr.name,
SongFormatAttr.filter)
select_mode, format_name, filter = SongFormat.get(format,
SongFormat.SelectMode, SongFormat.Name, SongFormat.Filter)
filepathEdit = self.formatWidgets[format][u'filepathEdit']
if select_mode == SongFormatSelect.SingleFile:
self.getFileName(WizardStrings.OpenTypeFile % format_name,
@ -306,9 +304,9 @@ class SongImportForm(OpenLPWizard):
def onAddButtonClicked(self):
format = self.currentFormat
select_mode, format_name, filter, custom_title = SongFormatAttr.get(
format, SongFormatAttr.select_mode, SongFormatAttr.name,
SongFormatAttr.filter, SongFormatAttr.get_files_title)
select_mode, format_name, filter, custom_title = SongFormat.get(format,
SongFormat.SelectMode, SongFormat.Name, SongFormat.Filter,
SongFormat.GetFilesTitle)
title = custom_title if custom_title \
else WizardStrings.OpenTypeFile % format_name
if select_mode == SongFormatSelect.MultipleFiles:
@ -341,7 +339,7 @@ class SongImportForm(OpenLPWizard):
last_import_type = 0
self.formatComboBox.setCurrentIndex(last_import_type)
for format in SongFormat.get_format_list():
select_mode = SongFormatAttr.get(format, SongFormatAttr.select_mode)
select_mode = SongFormat.get(format, SongFormat.SelectMode)
if select_mode == SongFormatSelect.MultipleFiles:
self.formatWidgets[format][u'fileListWidget'].clear()
else:
@ -366,8 +364,7 @@ class SongImportForm(OpenLPWizard):
the actual importing.
"""
source_format = self.currentFormat
select_mode = SongFormatAttr.get(source_format,
SongFormatAttr.select_mode)
select_mode = SongFormat.get(source_format, SongFormat.SelectMode)
if select_mode == SongFormatSelect.SingleFile:
importer = self.plugin.importSongs(source_format, filename=unicode(
self.formatWidgets[source_format][u'filepathEdit'].text()))
@ -401,9 +398,8 @@ class SongImportForm(OpenLPWizard):
def addFileSelectItem(self):
format = self.currentFormat
prefix, can_disable, select_mode = SongFormatAttr.get(
format, SongFormatAttr.prefix, SongFormatAttr.can_disable,
SongFormatAttr.select_mode)
prefix, can_disable, select_mode = SongFormat.get(format,
SongFormat.Prefix, SongFormat.CanDisable, SongFormat.SelectMode)
page = QtGui.QWidget()
page.setObjectName(prefix + u'Page')
if can_disable:
@ -507,8 +503,8 @@ class SongImportSourcePage(QtGui.QWizardPage):
"""
wizard = self.wizard()
format = wizard.currentFormat
select_mode, format_available = SongFormatAttr.get(format,
SongFormatAttr.select_mode, SongFormatAttr.availability)
select_mode, format_available = SongFormat.get(format,
SongFormat.SelectMode, SongFormat.Availability)
if format_available:
if select_mode == SongFormatSelect.MultipleFiles:
if wizard.formatWidgets[format][u'fileListWidget'].count() > 0:

View File

@ -65,11 +65,42 @@ except ImportError:
log.exception('Error importing %s', 'OooImport')
HAS_OOO = False
class SongFormatSelect(object):
"""
This is a special enumeration class listing available file selection modes.
"""
SingleFile = 0
MultipleFiles = 1
SingleFolder = 2
class SongFormat(object):
"""
This is a special enumeration class that holds the various types of song
importers and some helper functions to facilitate access.
This is a special static class that holds an enumeration of the various
song formats handled by the importer, the attributes of each song format,
and a few helper functions.
Required attributes for each song format:
* ``Class`` Import class, e.g. OpenLyricsImport
* ``Name`` Name of the format, e.g. u'OpenLyrics'
* ``Prefix`` Prefix for Qt objects. Use camelCase, e.g. u'openLyrics'
See ``SongImportForm.addFileSelectItem()``.
Optional attributes for each song format:
* ``CanDisable`` Whether song format importer is disablable.
* ``Availability`` Whether song format importer is available.
* ``SelectMode`` Whether format accepts single file, multiple files, or
single folder (as per SongFormatSelect options).
* ``Filter`` File extension filter for QFileDialog.
Optional/custom text Strings for SongImportForm widgets:
* ``ComboBoxText`` Combo box selector (default value is format Name).
* ``DisabledLabelText`` Required for disablable song formats.
* ``GetFilesTitle`` Title for QFileDialog (default includes format Name).
* ``InvalidSourceMsg`` Message displayed when source does not validate with
Class.isValidSource().
"""
# Song Formats
Unknown = -1
OpenLyrics = 0
OpenLP2 = 1
@ -88,6 +119,161 @@ class SongFormat(object):
WordsOfWorship = 14
#CSV = 15
# Required attributes
Class = -10
Name = -11
Prefix = -12
# Optional attributes
CanDisable = -20
Availability = -21
SelectMode = -22
Filter = -23
# Optional/custom text values
ComboBoxText = -30
DisabledLabelText = -31
GetFilesTitle = -32
InvalidSourceMsg = -33
# Set optional attribute defaults
_defaults = {
CanDisable: False,
Availability: True,
SelectMode: SongFormatSelect.MultipleFiles,
Filter: u'',
ComboBoxText: None,
DisabledLabelText: u'',
GetFilesTitle: None,
InvalidSourceMsg: None
}
# Set attribute values for each Song Format
_attributes = {
OpenLyrics: {
Class: OpenLyricsImport,
Name: u'OpenLyrics',
Prefix: u'openLyrics',
Filter: u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
'OpenLyrics Files'),
ComboBoxText: translate('SongsPlugin.ImportWizardForm',
'OpenLyrics or OpenLP 2.0 Exported Song')
},
OpenLP2: {
Class: OpenLPSongImport,
Name: UiStrings().OLPV2,
Prefix: u'openLP2',
SelectMode: SongFormatSelect.SingleFile,
Filter: u'%s (*.sqlite)' % (translate(
'SongsPlugin.ImportWizardForm', 'OpenLP 2.0 Databases'))
},
OpenLP1: {
Name: UiStrings().OLPV1,
Prefix: u'openLP1',
CanDisable: True,
SelectMode: SongFormatSelect.SingleFile,
Filter: u'%s (*.olp)' % translate('SongsPlugin.ImportWizardForm',
'openlp.org v1.x Databases'),
DisabledLabelText: WizardStrings.NoSqlite
},
Generic: {
Name: translate('SongsPlugin.ImportWizardForm',
'Generic Document/Presentation'),
Prefix: u'generic',
CanDisable: True,
DisabledLabelText: translate('SongsPlugin.ImportWizardForm',
'The generic document/presentation importer has been disabled '
'because OpenLP cannot access OpenOffice or LibreOffice.'),
GetFilesTitle: translate('SongsPlugin.ImportWizardForm',
'Select Document/Presentation Files')
},
CCLI: {
Class: CCLIFileImport,
Name: u'CCLI/SongSelect',
Prefix: u'ccli',
Filter: u'%s (*.usr *.txt)' % translate(
'SongsPlugin.ImportWizardForm', 'CCLI SongSelect Files')
},
DreamBeam: {
Class: DreamBeamImport,
Name: u'DreamBeam',
Prefix: u'dreamBeam',
Filter: u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
'DreamBeam Song Files')
},
EasySlides: {
Class: EasySlidesImport,
Name: u'EasySlides',
Prefix: u'easySlides',
SelectMode: SongFormatSelect.SingleFile,
Filter: u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
'EasySlides XML File')
},
EasyWorship: {
Class: EasyWorshipSongImport,
Name: u'EasyWorship',
Prefix: u'ew',
SelectMode: SongFormatSelect.SingleFile,
Filter: u'%s (*.db)' % translate('SongsPlugin.ImportWizardForm',
'EasyWorship Song Database')
},
FoilPresenter: {
Class: FoilPresenterImport,
Name: u'Foilpresenter',
Prefix: u'foilPresenter',
Filter: u'%s (*.foil)' % translate('SongsPlugin.ImportWizardForm',
'Foilpresenter Song Files')
},
OpenSong: {
Class: OpenSongImport,
Name: WizardStrings.OS,
Prefix: u'openSong'
},
PowerSong: {
Class: PowerSongImport,
Name: u'PowerSong 1.0',
Prefix: u'powerSong',
SelectMode: SongFormatSelect.SingleFolder,
InvalidSourceMsg: translate('SongsPlugin.ImportWizardForm',
'You need to specify a valid PowerSong 1.0 database folder.')
},
SongBeamer: {
Class: SongBeamerImport,
Name: u'SongBeamer',
Prefix: u'songBeamer',
Filter: u'%s (*.sng)' % translate('SongsPlugin.ImportWizardForm',
'SongBeamer Files')
},
SongShowPlus: {
Class: SongShowPlusImport,
Name: u'SongShow Plus',
Prefix: u'songShowPlus',
Filter: u'%s (*.sbsong)' % translate('SongsPlugin.ImportWizardForm',
'SongShow Plus Song Files')
},
SongsOfFellowship: {
Name: u'Songs of Fellowship',
Prefix: u'songsOfFellowship',
CanDisable: True,
Filter: u'%s (*.rtf)' % translate('SongsPlugin.ImportWizardForm',
'Songs Of Fellowship Song Files'),
DisabledLabelText: translate('SongsPlugin.ImportWizardForm',
'The Songs of Fellowship importer has been disabled because '
'OpenLP cannot access OpenOffice or LibreOffice.')
},
WordsOfWorship: {
Class: WowImport,
Name: u'Words of Worship',
Prefix: u'wordsOfWorship',
Filter: u'%s (*.wsg *.wow-song)' % translate(
'SongsPlugin.ImportWizardForm', 'Words Of Worship Song Files')
# },
# CSV: {
# class_: CSVImport,
# name: WizardStrings.CSV,
# prefix: u'csv',
# select_mode: SongFormatSelect.SingleFile
}
}
@staticmethod
def get_format_list():
"""
@ -110,198 +296,7 @@ class SongFormat(object):
SongFormat.SongsOfFellowship,
SongFormat.WordsOfWorship
]
class SongFormatSelect(object):
"""
This is a special enumeration class listing available file selection modes.
"""
SingleFile = 0
MultipleFiles = 1
SingleFolder = 2
class SongFormatAttr(object):
"""
This is a special static class that holds the attributes of each song format
to aid the importing of each song type.
The various definable attributes are enumerated as follows:
Required attributes for each song format:
* ``class_`` Import class, e.g. OpenLyricsImport
* ``name`` Name of this format, e.g. u'OpenLyrics'
* ``prefix`` Prefix for objects. Use camelCase, e.g. u'openLyrics'
See ``SongImportForm.addFileSelectItem()``.
Optional attributes for each song format:
* ``can_disable`` Whether song format is disablable.
* ``availability`` Whether song format is available.
* ``select_mode`` Whether format accepts single file, multiple files, or
single folder.
* ``filter`` File extension filter for QFileDialog.
Optional/custom text values for SongImportForm widgets:
* ``combo_box_text`` Combo box selector (default is format name).
* ``disabled_label_text`` Required for disablable song formats.
* ``get_files_title`` Title for QFileDialog (default includes format
name).
* ``invalid_source_msg`` Message shown when source does not validate with
class_.isValidSource().
"""
# Required attributes
class_ = 0
name = 1
prefix = 2
# Optional attributes
can_disable = 10
availability = 11
select_mode = 12
filter = 13
# Optional/custom text values
combo_box_text = 20
disabled_label_text = 21
get_files_title = 22
invalid_source_msg = 23
# Set optional attribute defaults
_defaults = {
can_disable: False,
availability: True,
select_mode: SongFormatSelect.MultipleFiles,
filter: u'',
combo_box_text: None,
disabled_label_text: u'',
get_files_title: None,
invalid_source_msg: None
}
# Set attribute values
_attributes = {
SongFormat.OpenLyrics: {
class_: OpenLyricsImport,
name: u'OpenLyrics',
prefix: u'openLyrics',
filter: u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
'OpenLyrics Files'),
combo_box_text: translate('SongsPlugin.ImportWizardForm',
'OpenLyrics or OpenLP 2.0 Exported Song')
},
SongFormat.OpenLP2: {
class_: OpenLPSongImport,
name: UiStrings().OLPV2,
prefix: u'openLP2',
select_mode: SongFormatSelect.SingleFile,
filter: u'%s (*.sqlite)' % (translate(
'SongsPlugin.ImportWizardForm', 'OpenLP 2.0 Databases'))
},
SongFormat.OpenLP1: {
name: UiStrings().OLPV1,
prefix: u'openLP1',
can_disable: True,
select_mode: SongFormatSelect.SingleFile,
filter: u'%s (*.olp)' % translate('SongsPlugin.ImportWizardForm',
'openlp.org v1.x Databases'),
disabled_label_text: WizardStrings.NoSqlite
},
SongFormat.Generic: {
name: translate('SongsPlugin.ImportWizardForm',
'Generic Document/Presentation'),
prefix: u'generic',
can_disable: True,
disabled_label_text: translate('SongsPlugin.ImportWizardForm',
'The generic document/presentation importer has been disabled '
'because OpenLP cannot access OpenOffice or LibreOffice.'),
get_files_title: translate('SongsPlugin.ImportWizardForm',
'Select Document/Presentation Files')
},
SongFormat.CCLI: {
class_: CCLIFileImport,
name: u'CCLI/SongSelect',
prefix: u'ccli',
filter: u'%s (*.usr *.txt)' % translate(
'SongsPlugin.ImportWizardForm', 'CCLI SongSelect Files')
},
SongFormat.DreamBeam: {
class_: DreamBeamImport,
name: u'DreamBeam',
prefix: u'dreamBeam',
filter: u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
'DreamBeam Song Files')
},
SongFormat.EasySlides: {
class_: EasySlidesImport,
name: u'EasySlides',
prefix: u'easySlides',
select_mode: SongFormatSelect.SingleFile,
filter: u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
'EasySlides XML File')
},
SongFormat.EasyWorship: {
class_: EasyWorshipSongImport,
name: u'EasyWorship',
prefix: u'ew',
select_mode: SongFormatSelect.SingleFile,
filter: u'%s (*.db)' % translate('SongsPlugin.ImportWizardForm',
'EasyWorship Song Database')
},
SongFormat.FoilPresenter: {
class_: FoilPresenterImport,
name: u'Foilpresenter',
prefix: u'foilPresenter',
filter: u'%s (*.foil)' % translate('SongsPlugin.ImportWizardForm',
'Foilpresenter Song Files')
},
SongFormat.OpenSong: {
class_: OpenSongImport,
name: WizardStrings.OS,
prefix: u'openSong'
},
SongFormat.PowerSong: {
class_: PowerSongImport,
name: u'PowerSong 1.0',
prefix: u'powerSong',
select_mode: SongFormatSelect.SingleFolder,
invalid_source_msg: translate('SongsPlugin.ImportWizardForm',
'You need to specify a valid PowerSong 1.0 database folder.')
},
SongFormat.SongBeamer: {
class_: SongBeamerImport,
name: u'SongBeamer',
prefix: u'songBeamer',
filter: u'%s (*.sng)' % translate('SongsPlugin.ImportWizardForm',
'SongBeamer Files')
},
SongFormat.SongShowPlus: {
class_: SongShowPlusImport,
name: u'SongShow Plus',
prefix: u'songShowPlus',
filter: u'%s (*.sbsong)' % translate('SongsPlugin.ImportWizardForm',
'SongShow Plus Song Files')
},
SongFormat.SongsOfFellowship: {
name: u'Songs of Fellowship',
prefix: u'songsOfFellowship',
can_disable: True,
filter: u'%s (*.rtf)' % translate('SongsPlugin.ImportWizardForm',
'Songs Of Fellowship Song Files'),
disabled_label_text: translate('SongsPlugin.ImportWizardForm',
'The Songs of Fellowship importer has been disabled because '
'OpenLP cannot access OpenOffice or LibreOffice.')
},
SongFormat.WordsOfWorship: {
class_: WowImport,
name: u'Words of Worship',
prefix: u'wordsOfWorship',
filter: u'%s (*.wsg *.wow-song)' % translate(
'SongsPlugin.ImportWizardForm', 'Words Of Worship Song Files')
# },
# SongFormat.CSV: {
# class_: CSVImport,
# name: WizardStrings.CSV,
# prefix: u'csv',
# select_mode: SongFormatSelect.SingleFile
}
}
@staticmethod
def get(format, *attributes):
"""
@ -311,7 +306,7 @@ class SongFormatAttr(object):
A song format from SongFormat.
``*attributes``
Zero or more song format attributes from SongFormatAttr.
Zero or more song format attributes from SongFormat.
Return type depends on number of supplied attributes:
* 0 : Return dict containing all defined attributes for the format.
@ -319,16 +314,16 @@ class SongFormatAttr(object):
* >1 : Return tuple of requested attribute values.
"""
if not attributes:
return SongFormatAttr._attributes.get(format)
return SongFormat._attributes.get(format)
elif len(attributes) == 1:
default = SongFormatAttr._defaults.get(attributes[0])
return SongFormatAttr._attributes[format].get(attributes[0],
default = SongFormat._defaults.get(attributes[0])
return SongFormat._attributes[format].get(attributes[0],
default)
else:
values = []
for attr in attributes:
default = SongFormatAttr._defaults.get(attr)
values.append(SongFormatAttr._attributes[format].get(attr,
default = SongFormat._defaults.get(attr)
values.append(SongFormat._attributes[format].get(attr,
default))
return tuple(values)
@ -337,20 +332,16 @@ class SongFormatAttr(object):
"""
Set specified song format attribute to the supplied value.
"""
SongFormatAttr._attributes[format][attribute] = value
SongFormat._attributes[format][attribute] = value
SongFormatAttr.set(SongFormat.OpenLP1, SongFormatAttr.availability, HAS_OPENLP1)
SongFormat.set(SongFormat.OpenLP1, SongFormat.Availability, HAS_OPENLP1)
if HAS_OPENLP1:
SongFormatAttr.set(SongFormat.OpenLP1, SongFormatAttr.class_,
OpenLP1SongImport)
SongFormatAttr.set(SongFormat.SongsOfFellowship, SongFormatAttr.availability,
HAS_SOF)
SongFormat.set(SongFormat.OpenLP1, SongFormat.Class, OpenLP1SongImport)
SongFormat.set(SongFormat.SongsOfFellowship, SongFormat.Availability, HAS_SOF)
if HAS_SOF:
SongFormatAttr.set(SongFormat.SongsOfFellowship, SongFormatAttr.class_,
SofImport)
SongFormatAttr.set(SongFormat.Generic, SongFormatAttr.availability, HAS_OOO)
SongFormat.set(SongFormat.SongsOfFellowship, SongFormat.Class, SofImport)
SongFormat.set(SongFormat.Generic, SongFormat.Availability, HAS_OOO)
if HAS_OOO:
SongFormatAttr.set(SongFormat.Generic, SongFormatAttr.class_,
OooImport)
SongFormat.set(SongFormat.Generic, SongFormat.Class, OooImport)
__all__ = [u'SongFormat', u'SongFormatSelect', u'SongFormatAttr']
__all__ = [u'SongFormat', u'SongFormatSelect']

View File

@ -87,9 +87,9 @@ class PowerSongImport(SongImport):
"""
Receive either a list of files or a folder (unicode) to import.
"""
from importer import SongFormat, SongFormatAttr
PS_string = SongFormatAttr.get(SongFormat.PowerSong,
SongFormatAttr.name)
from importer import SongFormat, SongFormat
PS_string = SongFormat.get(SongFormat.PowerSong,
SongFormat.Name)
if isinstance(self.importSource, unicode):
if os.path.isdir(self.importSource):
dir = self.importSource

View File

@ -39,7 +39,7 @@ from openlp.core.utils.actions import ActionList
from openlp.plugins.songs.lib import clean_song, upgrade, SongMediaItem, \
SongsTab
from openlp.plugins.songs.lib.db import init_schema, Song
from openlp.plugins.songs.lib.importer import SongFormatAttr
from openlp.plugins.songs.lib.importer import SongFormat
from openlp.plugins.songs.lib.olpimport import OpenLPSongImport
log = logging.getLogger(__name__)
@ -194,7 +194,7 @@ class SongsPlugin(Plugin):
self.manager.save_object(song)
def importSongs(self, format, **kwargs):
class_ = SongFormatAttr.get(format, SongFormatAttr.class_)
class_ = SongFormat.get(format, SongFormat.Class)
importer = class_(self.manager, **kwargs)
importer.register(self.mediaItem.importWizard)
return importer