Merge refactor-song-import

This commit is contained in:
Samuel Findlay 2012-06-09 06:31:15 +10:00
commit 598ef7fff3
4 changed files with 137 additions and 160 deletions

View File

@ -87,7 +87,7 @@ class SongImportForm(OpenLPWizard):
Song wizard specific initialisation. Song wizard specific initialisation.
""" """
for format in SongFormat.get_format_list(): for format in SongFormat.get_format_list():
if not SongFormat.get(format, SongFormat.Availability): if not SongFormat.get(format, u'availability'):
self.formatWidgets[format][u'disabledWidget'].setVisible(True) self.formatWidgets[format][u'disabledWidget'].setVisible(True)
self.formatWidgets[format][u'importWidget'].setVisible(False) self.formatWidgets[format][u'importWidget'].setVisible(False)
@ -96,7 +96,7 @@ class SongImportForm(OpenLPWizard):
Song wizard specific signals. Song wizard specific signals.
""" """
for format in SongFormat.get_format_list(): for format in SongFormat.get_format_list():
select_mode = SongFormat.get(format, SongFormat.SelectMode) select_mode = SongFormat.get(format, u'selectMode')
if select_mode == SongFormatSelect.MultipleFiles: if select_mode == SongFormatSelect.MultipleFiles:
QtCore.QObject.connect(self.formatWidgets[format][u'addButton'], QtCore.QObject.connect(self.formatWidgets[format][u'addButton'],
QtCore.SIGNAL(u'clicked()'), self.onAddButtonClicked) QtCore.SIGNAL(u'clicked()'), self.onAddButtonClicked)
@ -164,8 +164,8 @@ class SongImportForm(OpenLPWizard):
self.formatLabel.setText(WizardStrings.FormatLabel) self.formatLabel.setText(WizardStrings.FormatLabel)
for format in SongFormat.get_format_list(): for format in SongFormat.get_format_list():
format_name, custom_combo_text, description_text, select_mode = \ format_name, custom_combo_text, description_text, select_mode = \
SongFormat.get(format, SongFormat.Name, SongFormat.ComboBoxText, SongFormat.get(format, u'name', u'comboBoxText',
SongFormat.DescriptionText, SongFormat.SelectMode) u'descriptionText', u'selectMode')
combo_box_text = (custom_combo_text if custom_combo_text else combo_box_text = (custom_combo_text if custom_combo_text else
format_name) format_name)
self.formatComboBox.setItemText(format, combo_box_text) self.formatComboBox.setItemText(format, combo_box_text)
@ -187,7 +187,7 @@ class SongImportForm(OpenLPWizard):
translate('SongsPlugin.ImportWizardForm', f_label)) translate('SongsPlugin.ImportWizardForm', f_label))
for format in self.disablableFormats: for format in self.disablableFormats:
self.formatWidgets[format][u'disabledLabel'].setText( self.formatWidgets[format][u'disabledLabel'].setText(
SongFormat.get(format, SongFormat.DisabledLabelText)) SongFormat.get(format, u'disabledLabelText'))
self.progressPage.setTitle(WizardStrings.Importing) self.progressPage.setTitle(WizardStrings.Importing)
self.progressPage.setSubTitle( self.progressPage.setSubTitle(
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
@ -214,7 +214,7 @@ class SongImportForm(OpenLPWizard):
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
# Align descriptionLabels with rest of layout # Align descriptionLabels with rest of layout
for format in SongFormat.get_format_list(): for format in SongFormat.get_format_list():
if SongFormat.get(format, SongFormat.DescriptionText) is not None: if SongFormat.get(format, u'descriptionText') is not None:
self.formatWidgets[format][u'descriptionSpacer'].changeSize( self.formatWidgets[format][u'descriptionSpacer'].changeSize(
max_label_width + self.formatHSpacing, 0, max_label_width + self.formatHSpacing, 0,
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
@ -239,8 +239,7 @@ class SongImportForm(OpenLPWizard):
QtCore.QSettings().setValue(u'songs/last import type', QtCore.QSettings().setValue(u'songs/last import type',
format) format)
select_mode, class_, error_msg = SongFormat.get(format, select_mode, class_, error_msg = SongFormat.get(format,
SongFormat.SelectMode, SongFormat.Class, u'selectMode', u'class', u'invalidSourceMsg')
SongFormat.InvalidSourceMsg)
if select_mode == SongFormatSelect.MultipleFiles: if select_mode == SongFormatSelect.MultipleFiles:
import_source = self.getListOfFiles( import_source = self.getListOfFiles(
self.formatWidgets[format][u'fileListWidget']) self.formatWidgets[format][u'fileListWidget'])
@ -303,8 +302,8 @@ class SongImportForm(OpenLPWizard):
def onBrowseButtonClicked(self): def onBrowseButtonClicked(self):
format = self.currentFormat format = self.currentFormat
select_mode, format_name, filter = SongFormat.get(format, select_mode, format_name, filter = SongFormat.get(format, u'selectMode',
SongFormat.SelectMode, SongFormat.Name, SongFormat.Filter) u'name', u'filter')
filepathEdit = self.formatWidgets[format][u'filepathEdit'] filepathEdit = self.formatWidgets[format][u'filepathEdit']
if select_mode == SongFormatSelect.SingleFile: if select_mode == SongFormatSelect.SingleFile:
self.getFileName(WizardStrings.OpenTypeFile % format_name, self.getFileName(WizardStrings.OpenTypeFile % format_name,
@ -316,8 +315,8 @@ class SongImportForm(OpenLPWizard):
def onAddButtonClicked(self): def onAddButtonClicked(self):
format = self.currentFormat format = self.currentFormat
select_mode, format_name, filter, custom_title = SongFormat.get(format, select_mode, format_name, filter, custom_title = SongFormat.get(format,
SongFormat.SelectMode, SongFormat.Name, SongFormat.Filter, u'selectMode', u'name', u'filter',
SongFormat.GetFilesTitle) u'getFilesTitle')
title = custom_title if custom_title \ title = custom_title if custom_title \
else WizardStrings.OpenTypeFile % format_name else WizardStrings.OpenTypeFile % format_name
if select_mode == SongFormatSelect.MultipleFiles: if select_mode == SongFormatSelect.MultipleFiles:
@ -350,7 +349,7 @@ class SongImportForm(OpenLPWizard):
last_import_type = 0 last_import_type = 0
self.formatComboBox.setCurrentIndex(last_import_type) self.formatComboBox.setCurrentIndex(last_import_type)
for format in SongFormat.get_format_list(): for format in SongFormat.get_format_list():
select_mode = SongFormat.get(format, SongFormat.SelectMode) select_mode = SongFormat.get(format, u'selectMode')
if select_mode == SongFormatSelect.MultipleFiles: if select_mode == SongFormatSelect.MultipleFiles:
self.formatWidgets[format][u'fileListWidget'].clear() self.formatWidgets[format][u'fileListWidget'].clear()
else: else:
@ -375,7 +374,7 @@ class SongImportForm(OpenLPWizard):
the actual importing. the actual importing.
""" """
source_format = self.currentFormat source_format = self.currentFormat
select_mode = SongFormat.get(source_format, SongFormat.SelectMode) select_mode = SongFormat.get(source_format, u'selectMode')
if select_mode == SongFormatSelect.SingleFile: if select_mode == SongFormatSelect.SingleFile:
importer = self.plugin.importSongs(source_format, filename=unicode( importer = self.plugin.importSongs(source_format, filename=unicode(
self.formatWidgets[source_format][u'filepathEdit'].text())) self.formatWidgets[source_format][u'filepathEdit'].text()))
@ -410,8 +409,7 @@ class SongImportForm(OpenLPWizard):
def addFileSelectItem(self): def addFileSelectItem(self):
format = self.currentFormat format = self.currentFormat
prefix, can_disable, description_text, select_mode = SongFormat.get( prefix, can_disable, description_text, select_mode = SongFormat.get(
format, SongFormat.Prefix, SongFormat.CanDisable, format, u'prefix', u'canDisable', u'descriptionText', u'selectMode')
SongFormat.DescriptionText, SongFormat.SelectMode)
page = QtGui.QWidget() page = QtGui.QWidget()
page.setObjectName(prefix + u'Page') page.setObjectName(prefix + u'Page')
if can_disable: if can_disable:
@ -532,8 +530,8 @@ class SongImportSourcePage(QtGui.QWizardPage):
""" """
wizard = self.wizard() wizard = self.wizard()
format = wizard.currentFormat format = wizard.currentFormat
select_mode, format_available = SongFormat.get(format, select_mode, format_available = SongFormat.get(format, u'selectMode',
SongFormat.SelectMode, SongFormat.Availability) u'availability')
if format_available: if format_available:
if select_mode == SongFormatSelect.MultipleFiles: if select_mode == SongFormatSelect.MultipleFiles:
if wizard.formatWidgets[format][u'fileListWidget'].count() > 0: if wizard.formatWidgets[format][u'fileListWidget'].count() > 0:

View File

@ -82,47 +82,42 @@ class SongFormat(object):
Required attributes for each song format: Required attributes for each song format:
``Class`` ``u'class'``
Import class, e.g. ``OpenLyricsImport`` Import class, e.g. ``OpenLyricsImport``
``Name`` ``u'name'``
Name of the format, e.g. ``u'OpenLyrics'`` Name of the format, e.g. ``u'OpenLyrics'``
``Prefix`` ``u'prefix'``
Prefix for Qt objects. Use mixedCase, e.g. ``u'openLyrics'`` Prefix for Qt objects. Use mixedCase, e.g. ``u'openLyrics'``
See ``SongImportForm.addFileSelectItem()`` See ``SongImportForm.addFileSelectItem()``
Optional attributes for each song format: Optional attributes for each song format:
``CanDisable`` ``u'canDisable'``
Whether song format importer is disablable. Whether song format importer is disablable.
``Availability`` ``u'availability'``
Whether song format importer is available. Whether song format importer is available.
``SelectMode`` ``u'selectMode'``
Whether format accepts single file, multiple files, or single folder Whether format accepts single file, multiple files, or single folder
(as per ``SongFormatSelect`` options). (as per ``SongFormatSelect`` options).
``Filter`` ``u'filter'``
File extension filter for ``QFileDialog``. File extension filter for ``QFileDialog``.
Optional/custom text Strings for ``SongImportForm`` widgets: Optional/custom text Strings for ``SongImportForm`` widgets:
``ComboBoxText`` ``u'comboBoxText'``
Combo box selector (default value is the format's ``Name``). Combo box selector (default value is the format's ``u'name'``).
``DisabledLabelText`` ``u'disabledLabelText'``
Required for disablable song formats. Required for disablable song formats.
``GetFilesTitle`` ``u'getFilesTitle'``
Title for ``QFileDialog`` (default includes the format's ``Name``). Title for ``QFileDialog`` (default includes the format's ``u'name'``).
``InvalidSourceMsg`` ``u'invalidSourceMsg'``
Message displayed if ``Class.isValidSource()`` returns ``False``. Message displayed if ``isValidSource()`` returns ``False``.
``DescriptionText`` ``u'descriptionText'``
Short description (1-2 lines) about the song format. Short description (1-2 lines) about the song format.
""" """
# Enumeration of song formats and their attributes # Song formats (ordered alphabetically after Generic)
# * Numerical order of song formats is significant as it determines the # * Numerical order of song formats is significant as it determines the
# order used by formatComboBox. # order used by formatComboBox.
# * Attribute ints are negative so they don't clash with song format ints.
# * Each group of attribute values increments by 10 to facilitate addition
# of more attributes in future.
# Song formats (ordered alphabetically after Generic)
Unknown = -1 Unknown = -1
OpenLyrics = 0 OpenLyrics = 0
OpenLP2 = 1 OpenLP2 = 1
@ -142,172 +137,156 @@ class SongFormat(object):
ZionWorx = 15 ZionWorx = 15
#CSV = 16 #CSV = 16
# 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
DescriptionText = -34
# Set optional attribute defaults # Set optional attribute defaults
_defaults = { __defaults__ = {
CanDisable: False, u'canDisable': False,
Availability: True, u'availability': True,
SelectMode: SongFormatSelect.MultipleFiles, u'selectMode': SongFormatSelect.MultipleFiles,
Filter: u'', u'filter': u'',
ComboBoxText: None, u'comboBoxText': None,
DisabledLabelText: u'', u'disabledLabelText': u'',
GetFilesTitle: None, u'getFilesTitle': None,
InvalidSourceMsg: None, u'invalidSourceMsg': None,
DescriptionText: None u'descriptionText': None
} }
# Set attribute values for each Song Format # Set attribute values for each Song Format
_attributes = { __attributes__ = {
OpenLyrics: { OpenLyrics: {
Class: OpenLyricsImport, u'class': OpenLyricsImport,
Name: u'OpenLyrics', u'name': u'OpenLyrics',
Prefix: u'openLyrics', u'prefix': u'openLyrics',
Filter: u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm', u'filter': u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
'OpenLyrics Files'), 'OpenLyrics Files'),
ComboBoxText: translate('SongsPlugin.ImportWizardForm', u'comboBoxText': translate('SongsPlugin.ImportWizardForm',
'OpenLyrics or OpenLP 2.0 Exported Song') 'OpenLyrics or OpenLP 2.0 Exported Song')
}, },
OpenLP2: { OpenLP2: {
Class: OpenLPSongImport, u'class': OpenLPSongImport,
Name: UiStrings().OLPV2, u'name': UiStrings().OLPV2,
Prefix: u'openLP2', u'prefix': u'openLP2',
SelectMode: SongFormatSelect.SingleFile, u'selectMode': SongFormatSelect.SingleFile,
Filter: u'%s (*.sqlite)' % (translate( u'filter': u'%s (*.sqlite)' % (translate(
'SongsPlugin.ImportWizardForm', 'OpenLP 2.0 Databases')) 'SongsPlugin.ImportWizardForm', 'OpenLP 2.0 Databases'))
}, },
OpenLP1: { OpenLP1: {
Name: UiStrings().OLPV1, u'name': UiStrings().OLPV1,
Prefix: u'openLP1', u'prefix': u'openLP1',
CanDisable: True, u'canDisable': True,
SelectMode: SongFormatSelect.SingleFile, u'selectMode': SongFormatSelect.SingleFile,
Filter: u'%s (*.olp)' % translate('SongsPlugin.ImportWizardForm', u'filter': u'%s (*.olp)' % translate('SongsPlugin.ImportWizardForm',
'openlp.org v1.x Databases'), 'openlp.org v1.x Databases'),
DisabledLabelText: WizardStrings.NoSqlite u'disabledLabelText': WizardStrings.NoSqlite
}, },
Generic: { Generic: {
Name: translate('SongsPlugin.ImportWizardForm', u'name': translate('SongsPlugin.ImportWizardForm',
'Generic Document/Presentation'), 'Generic Document/Presentation'),
Prefix: u'generic', u'prefix': u'generic',
CanDisable: True, u'canDisable': True,
DisabledLabelText: translate('SongsPlugin.ImportWizardForm', u'disabledLabelText': translate('SongsPlugin.ImportWizardForm',
'The generic document/presentation importer has been disabled ' 'The generic document/presentation importer has been disabled '
'because OpenLP cannot access OpenOffice or LibreOffice.'), 'because OpenLP cannot access OpenOffice or LibreOffice.'),
GetFilesTitle: translate('SongsPlugin.ImportWizardForm', u'getFilesTitle': translate('SongsPlugin.ImportWizardForm',
'Select Document/Presentation Files') 'Select Document/Presentation Files')
}, },
CCLI: { CCLI: {
Class: CCLIFileImport, u'class': CCLIFileImport,
Name: u'CCLI/SongSelect', u'name': u'CCLI/SongSelect',
Prefix: u'ccli', u'prefix': u'ccli',
Filter: u'%s (*.usr *.txt)' % translate( u'filter': u'%s (*.usr *.txt)' % translate(
'SongsPlugin.ImportWizardForm', 'CCLI SongSelect Files') 'SongsPlugin.ImportWizardForm', 'CCLI SongSelect Files')
}, },
DreamBeam: { DreamBeam: {
Class: DreamBeamImport, u'class': DreamBeamImport,
Name: u'DreamBeam', u'name': u'DreamBeam',
Prefix: u'dreamBeam', u'prefix': u'dreamBeam',
Filter: u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm', u'filter': u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
'DreamBeam Song Files') 'DreamBeam Song Files')
}, },
EasySlides: { EasySlides: {
Class: EasySlidesImport, u'class': EasySlidesImport,
Name: u'EasySlides', u'name': u'EasySlides',
Prefix: u'easySlides', u'prefix': u'easySlides',
SelectMode: SongFormatSelect.SingleFile, u'selectMode': SongFormatSelect.SingleFile,
Filter: u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm', u'filter': u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
'EasySlides XML File') 'EasySlides XML File')
}, },
EasyWorship: { EasyWorship: {
Class: EasyWorshipSongImport, u'class': EasyWorshipSongImport,
Name: u'EasyWorship', u'name': u'EasyWorship',
Prefix: u'ew', u'prefix': u'ew',
SelectMode: SongFormatSelect.SingleFile, u'selectMode': SongFormatSelect.SingleFile,
Filter: u'%s (*.db)' % translate('SongsPlugin.ImportWizardForm', u'filter': u'%s (*.db)' % translate('SongsPlugin.ImportWizardForm',
'EasyWorship Song Database') 'EasyWorship Song Database')
}, },
FoilPresenter: { FoilPresenter: {
Class: FoilPresenterImport, u'class': FoilPresenterImport,
Name: u'Foilpresenter', u'name': u'Foilpresenter',
Prefix: u'foilPresenter', u'prefix': u'foilPresenter',
Filter: u'%s (*.foil)' % translate('SongsPlugin.ImportWizardForm', u'filter': u'%s (*.foil)' % translate(
'Foilpresenter Song Files') 'SongsPlugin.ImportWizardForm', 'Foilpresenter Song Files')
}, },
OpenSong: { OpenSong: {
Class: OpenSongImport, u'class': OpenSongImport,
Name: WizardStrings.OS, u'name': WizardStrings.OS,
Prefix: u'openSong' u'prefix': u'openSong'
}, },
PowerSong: { PowerSong: {
Class: PowerSongImport, u'class': PowerSongImport,
Name: u'PowerSong 1.0', u'name': u'PowerSong 1.0',
Prefix: u'powerSong', u'prefix': u'powerSong',
SelectMode: SongFormatSelect.SingleFolder, u'selectMode': SongFormatSelect.SingleFolder,
InvalidSourceMsg: translate('SongsPlugin.ImportWizardForm', u'invalidSourceMsg': translate('SongsPlugin.ImportWizardForm',
'You need to specify a valid PowerSong 1.0 database folder.') 'You need to specify a valid PowerSong 1.0 database folder.')
}, },
SongBeamer: { SongBeamer: {
Class: SongBeamerImport, u'class': SongBeamerImport,
Name: u'SongBeamer', u'name': u'SongBeamer',
Prefix: u'songBeamer', u'prefix': u'songBeamer',
Filter: u'%s (*.sng)' % translate('SongsPlugin.ImportWizardForm', u'filter': u'%s (*.sng)' % translate('SongsPlugin.ImportWizardForm',
'SongBeamer Files') 'SongBeamer Files')
}, },
SongShowPlus: { SongShowPlus: {
Class: SongShowPlusImport, u'class': SongShowPlusImport,
Name: u'SongShow Plus', u'name': u'SongShow Plus',
Prefix: u'songShowPlus', u'prefix': u'songShowPlus',
Filter: u'%s (*.sbsong)' % translate('SongsPlugin.ImportWizardForm', u'filter': u'%s (*.sbsong)' % translate(
'SongShow Plus Song Files') 'SongsPlugin.ImportWizardForm', 'SongShow Plus Song Files')
}, },
SongsOfFellowship: { SongsOfFellowship: {
Name: u'Songs of Fellowship', u'name': u'Songs of Fellowship',
Prefix: u'songsOfFellowship', u'prefix': u'songsOfFellowship',
CanDisable: True, u'canDisable': True,
Filter: u'%s (*.rtf)' % translate('SongsPlugin.ImportWizardForm', u'filter': u'%s (*.rtf)' % translate('SongsPlugin.ImportWizardForm',
'Songs Of Fellowship Song Files'), 'Songs Of Fellowship Song Files'),
DisabledLabelText: translate('SongsPlugin.ImportWizardForm', u'disabledLabelText': translate('SongsPlugin.ImportWizardForm',
'The Songs of Fellowship importer has been disabled because ' 'The Songs of Fellowship importer has been disabled because '
'OpenLP cannot access OpenOffice or LibreOffice.') 'OpenLP cannot access OpenOffice or LibreOffice.')
}, },
WordsOfWorship: { WordsOfWorship: {
Class: WowImport, u'class': WowImport,
Name: u'Words of Worship', u'name': u'Words of Worship',
Prefix: u'wordsOfWorship', u'prefix': u'wordsOfWorship',
Filter: u'%s (*.wsg *.wow-song)' % translate( u'filter': u'%s (*.wsg *.wow-song)' % translate(
'SongsPlugin.ImportWizardForm', 'Words Of Worship Song Files') 'SongsPlugin.ImportWizardForm', 'Words Of Worship Song Files')
}, },
ZionWorx: { ZionWorx: {
Class: ZionWorxImport, u'class': ZionWorxImport,
Name: u'ZionWorx', u'name': u'ZionWorx',
Prefix: u'zionWorx', u'prefix': u'zionWorx',
SelectMode: SongFormatSelect.SingleFile, u'selectMode': SongFormatSelect.SingleFile,
ComboBoxText: translate('SongsPlugin.ImportWizardForm', u'comboBoxText': translate('SongsPlugin.ImportWizardForm',
'ZionWorx (CSV)'), 'ZionWorx (CSV)'),
DescriptionText: translate('SongsPlugin.ImportWizardForm', u'descriptionText': translate('SongsPlugin.ImportWizardForm',
'First dump your ZionWorx database to a CSV text file, using ' 'First dump your ZionWorx database to a CSV text file, using '
'freeware utility TdbDataX "TurboDB Data Exchange" from ' 'freeware utility TdbDataX "TurboDB Data Exchange" from '
'dataWeb (see the User Manual).') 'dataWeb (see the User Manual).')
# }, # },
# CSV: { # CSV: {
# class_: CSVImport, # u'class': CSVImport,
# name: WizardStrings.CSV, # u'name': WizardStrings.CSV,
# prefix: u'csv', # u'prefix': u'csv',
# select_mode: SongFormatSelect.SingleFile # u'selectMode': SongFormatSelect.SingleFile
} }
} }
@ -352,16 +331,16 @@ class SongFormat(object):
:>1: Return tuple of requested attribute values. :>1: Return tuple of requested attribute values.
""" """
if not attributes: if not attributes:
return SongFormat._attributes.get(format) return SongFormat.__attributes__.get(format)
elif len(attributes) == 1: elif len(attributes) == 1:
default = SongFormat._defaults.get(attributes[0]) default = SongFormat.__defaults__.get(attributes[0])
return SongFormat._attributes[format].get(attributes[0], return SongFormat.__attributes__[format].get(attributes[0],
default) default)
else: else:
values = [] values = []
for attr in attributes: for attr in attributes:
default = SongFormat._defaults.get(attr) default = SongFormat.__defaults__.get(attr)
values.append(SongFormat._attributes[format].get(attr, values.append(SongFormat.__attributes__[format].get(attr,
default)) default))
return tuple(values) return tuple(values)
@ -370,16 +349,16 @@ class SongFormat(object):
""" """
Set specified song format attribute to the supplied value. Set specified song format attribute to the supplied value.
""" """
SongFormat._attributes[format][attribute] = value SongFormat.__attributes__[format][attribute] = value
SongFormat.set(SongFormat.OpenLP1, SongFormat.Availability, HAS_OPENLP1) SongFormat.set(SongFormat.OpenLP1, u'availability', HAS_OPENLP1)
if HAS_OPENLP1: if HAS_OPENLP1:
SongFormat.set(SongFormat.OpenLP1, SongFormat.Class, OpenLP1SongImport) SongFormat.set(SongFormat.OpenLP1, u'class', OpenLP1SongImport)
SongFormat.set(SongFormat.SongsOfFellowship, SongFormat.Availability, HAS_SOF) SongFormat.set(SongFormat.SongsOfFellowship, u'availability', HAS_SOF)
if HAS_SOF: if HAS_SOF:
SongFormat.set(SongFormat.SongsOfFellowship, SongFormat.Class, SofImport) SongFormat.set(SongFormat.SongsOfFellowship, u'class', SofImport)
SongFormat.set(SongFormat.Generic, SongFormat.Availability, HAS_OOO) SongFormat.set(SongFormat.Generic, u'availability', HAS_OOO)
if HAS_OOO: if HAS_OOO:
SongFormat.set(SongFormat.Generic, SongFormat.Class, OooImport) SongFormat.set(SongFormat.Generic, u'class', OooImport)
__all__ = [u'SongFormat', u'SongFormatSelect'] __all__ = [u'SongFormat', u'SongFormatSelect']

View File

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

View File

@ -194,7 +194,7 @@ class SongsPlugin(Plugin):
self.manager.save_object(song) self.manager.save_object(song)
def importSongs(self, format, **kwargs): def importSongs(self, format, **kwargs):
class_ = SongFormat.get(format, SongFormat.Class) class_ = SongFormat.get(format, u'class')
importer = class_(self.manager, **kwargs) importer = class_(self.manager, **kwargs)
importer.register(self.mediaItem.importWizard) importer.register(self.mediaItem.importWizard)
return importer return importer