← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~raoul-snyman/openlp/olp1-import into lp:openlp

 

Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/olp1-import into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  #608427 Song Converter from Version 1 does not support new version 2 schema
  https://bugs.launchpad.net/bugs/608427
  #633354 Song Importer Broke
  https://bugs.launchpad.net/bugs/633354
  #635330 Support openlp.org 1.0 database imports
  https://bugs.launchpad.net/bugs/635330
  #635338 openlp.org v1 import gets encoding wrong
  https://bugs.launchpad.net/bugs/635338


Add in code to display a disabled message if an importer is not available.
-- 
https://code.launchpad.net/~raoul-snyman/openlp/olp1-import/+merge/35468
Your team OpenLP Core is requested to review the proposed merge of lp:~raoul-snyman/openlp/olp1-import into lp:openlp.
=== modified file 'openlp/plugins/songs/forms/songimportform.py'
--- openlp/plugins/songs/forms/songimportform.py	2010-09-06 22:02:48 +0000
+++ openlp/plugins/songs/forms/songimportform.py	2010-09-14 20:41:25 +0000
@@ -57,6 +57,15 @@
         self.registerFields()
         self.finishButton = self.button(QtGui.QWizard.FinishButton)
         self.cancelButton = self.button(QtGui.QWizard.CancelButton)
+        if not SongFormat.get_availability(SongFormat.OpenLP1):
+            self.openLP1DisabledWidget.setVisible(True)
+            self.openLP1ImportWidget.setVisible(False)
+        if not SongFormat.get_availability(SongFormat.SongsOfFellowship):
+            self.songsOfFellowshipDisabledWidget.setVisible(True)
+            self.songsOfFellowshipImportWidget.setVisible(False)
+        if not SongFormat.get_availability(SongFormat.Generic):
+            self.genericDisabledWidget.setVisible(True)
+            self.genericImportWidget.setVisible(False)
         self.plugin = plugin
         QtCore.QObject.connect(self.openLP2BrowseButton,
             QtCore.SIGNAL(u'clicked()'),
@@ -64,12 +73,12 @@
         QtCore.QObject.connect(self.openLP1BrowseButton,
             QtCore.SIGNAL(u'clicked()'),
             self.onOpenLP1BrowseButtonClicked)
-        QtCore.QObject.connect(self.openLyricsAddButton,
-            QtCore.SIGNAL(u'clicked()'),
-            self.onOpenLyricsAddButtonClicked)
-        QtCore.QObject.connect(self.openLyricsRemoveButton,
-            QtCore.SIGNAL(u'clicked()'),
-            self.onOpenLyricsRemoveButtonClicked)
+        #QtCore.QObject.connect(self.openLyricsAddButton,
+        #    QtCore.SIGNAL(u'clicked()'),
+        #    self.onOpenLyricsAddButtonClicked)
+        #QtCore.QObject.connect(self.openLyricsRemoveButton,
+        #    QtCore.SIGNAL(u'clicked()'),
+        #    self.onOpenLyricsRemoveButtonClicked)
         QtCore.QObject.connect(self.openSongAddButton,
             QtCore.SIGNAL(u'clicked()'),
             self.onOpenSongAddButtonClicked)
@@ -145,15 +154,16 @@
                     self.openLP1BrowseButton.setFocus()
                     return False
             elif source_format == SongFormat.OpenLyrics:
-                if self.openLyricsFileListWidget.count() == 0:
-                    QtGui.QMessageBox.critical(self,
-                        translate('SongsPlugin.ImportWizardForm',
-                            'No OpenLyrics Files Selected'),
-                        translate('SongsPlugin.ImportWizardForm',
-                            'You need to add at least one OpenLyrics '
-                            'song file to import from.'))
-                    self.openLyricsAddButton.setFocus()
-                    return False
+                #if self.openLyricsFileListWidget.count() == 0:
+                #    QtGui.QMessageBox.critical(self,
+                #        translate('SongsPlugin.ImportWizardForm',
+                #            'No OpenLyrics Files Selected'),
+                #        translate('SongsPlugin.ImportWizardForm',
+                #            'You need to add at least one OpenLyrics '
+                #            'song file to import from.'))
+                #    self.openLyricsAddButton.setFocus()
+                #    return False
+                return False
             elif source_format == SongFormat.OpenSong:
                 if self.openSongFileListWidget.count() == 0:
                     QtGui.QMessageBox.critical(self,
@@ -252,15 +262,15 @@
             self.openLP1FilenameEdit
         )
 
-    def onOpenLyricsAddButtonClicked(self):
-        self.getFiles(
-            translate('SongsPlugin.ImportWizardForm',
-            'Select OpenLyrics Files'),
-            self.openLyricsFileListWidget
-        )
+    #def onOpenLyricsAddButtonClicked(self):
+    #    self.getFiles(
+    #        translate('SongsPlugin.ImportWizardForm',
+    #        'Select OpenLyrics Files'),
+    #        self.openLyricsFileListWidget
+    #    )
 
-    def onOpenLyricsRemoveButtonClicked(self):
-        self.removeSelectedItems(self.openLyricsFileListWidget)
+    #def onOpenLyricsRemoveButtonClicked(self):
+    #    self.removeSelectedItems(self.openLyricsFileListWidget)
 
     def onOpenSongAddButtonClicked(self):
         self.getFiles(
@@ -334,7 +344,7 @@
         self.formatComboBox.setCurrentIndex(0)
         self.openLP2FilenameEdit.setText(u'')
         self.openLP1FilenameEdit.setText(u'')
-        self.openLyricsFileListWidget.clear()
+        #self.openLyricsFileListWidget.clear()
         self.openSongFileListWidget.clear()
         self.wordsOfWorshipFileListWidget.clear()
         self.ccliFileListWidget.clear()

=== modified file 'openlp/plugins/songs/forms/songimportwizard.py'
--- openlp/plugins/songs/forms/songimportwizard.py	2010-08-28 01:31:11 +0000
+++ openlp/plugins/songs/forms/songimportwizard.py	2010-09-14 20:41:25 +0000
@@ -131,26 +131,43 @@
         # openlp.org 1.x
         self.openLP1Page = QtGui.QWidget()
         self.openLP1Page.setObjectName(u'openLP1Page')
-        self.openLP1Layout = QtGui.QFormLayout(self.openLP1Page)
+        self.openLP1Layout = QtGui.QVBoxLayout(self.openLP1Page)
         self.openLP1Layout.setMargin(0)
-        self.openLP1Layout.setSpacing(8)
+        self.openLP1Layout.setSpacing(0)
         self.openLP1Layout.setObjectName(u'openLP1Layout')
-        self.openLP1FilenameLabel = QtGui.QLabel(self.openLP1Page)
+        self.openLP1DisabledWidget = QtGui.QWidget(self.openLP1Page)
+        self.openLP1DisabledLayout = QtGui.QVBoxLayout(self.openLP1DisabledWidget)
+        self.openLP1DisabledLayout.setMargin(0)
+        self.openLP1DisabledLayout.setSpacing(8)
+        self.openLP1DisabledLayout.setObjectName(u'openLP1DisabledLayout')
+        self.openLP1DisabledLabel = QtGui.QLabel(self.openLP1DisabledWidget)
+        self.openLP1DisabledLabel.setWordWrap(True)
+        self.openLP1DisabledLabel.setObjectName(u'openLP1DisabledLabel')
+        self.openLP1DisabledLayout.addWidget(self.openLP1DisabledLabel)
+        self.openLP1DisabledWidget.setVisible(False)
+        self.openLP1Layout.addWidget(self.openLP1DisabledWidget)
+        self.openLP1ImportWidget = QtGui.QWidget(self.openLP1Page)
+        self.openLP1ImportLayout = QtGui.QFormLayout(self.openLP1ImportWidget)
+        self.openLP1ImportLayout.setMargin(0)
+        self.openLP1ImportLayout.setSpacing(8)
+        self.openLP1ImportLayout.setObjectName(u'openLP1ImportLayout')
+        self.openLP1FilenameLabel = QtGui.QLabel(self.openLP1ImportWidget)
         self.openLP1FilenameLabel.setObjectName(u'openLP1FilenameLabel')
-        self.openLP1Layout.setWidget(0, QtGui.QFormLayout.LabelRole,
+        self.openLP1ImportLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
             self.openLP1FilenameLabel)
         self.openLP1FileLayout = QtGui.QHBoxLayout()
         self.openLP1FileLayout.setSpacing(8)
         self.openLP1FileLayout.setObjectName(u'openLP1FileLayout')
-        self.openLP1FilenameEdit = QtGui.QLineEdit(self.openLP1Page)
+        self.openLP1FilenameEdit = QtGui.QLineEdit(self.openLP1ImportWidget)
         self.openLP1FilenameEdit.setObjectName(u'openLP1FilenameEdit')
         self.openLP1FileLayout.addWidget(self.openLP1FilenameEdit)
-        self.openLP1BrowseButton = QtGui.QToolButton(self.openLP1Page)
+        self.openLP1BrowseButton = QtGui.QToolButton(self.openLP1ImportWidget)
         self.openLP1BrowseButton.setIcon(openIcon)
         self.openLP1BrowseButton.setObjectName(u'openLP1BrowseButton')
         self.openLP1FileLayout.addWidget(self.openLP1BrowseButton)
-        self.openLP1Layout.setLayout(0, QtGui.QFormLayout.FieldRole,
+        self.openLP1ImportLayout.setLayout(0, QtGui.QFormLayout.FieldRole,
             self.openLP1FileLayout)
+        self.openLP1Layout.addWidget(self.openLP1ImportWidget)
         self.formatStackedWidget.addWidget(self.openLP1Page)
         # OpenLyrics
         self.openLyricsPage = QtGui.QWidget()
@@ -159,26 +176,31 @@
         self.openLyricsLayout.setSpacing(8)
         self.openLyricsLayout.setMargin(0)
         self.openLyricsLayout.setObjectName(u'OpenLyricsLayout')
-        self.openLyricsFileListWidget = QtGui.QListWidget(self.openLyricsPage)
-        self.openLyricsFileListWidget.setSelectionMode(
-            QtGui.QAbstractItemView.ExtendedSelection)
-        self.openLyricsFileListWidget.setObjectName(u'OpenLyricsFileListWidget')
-        self.openLyricsLayout.addWidget(self.openLyricsFileListWidget)
-        self.openLyricsButtonLayout = QtGui.QHBoxLayout()
-        self.openLyricsButtonLayout.setSpacing(8)
-        self.openLyricsButtonLayout.setObjectName(u'OpenLyricsButtonLayout')
-        self.openLyricsAddButton = QtGui.QPushButton(self.openLyricsPage)
-        self.openLyricsAddButton.setIcon(openIcon)
-        self.openLyricsAddButton.setObjectName(u'OpenLyricsAddButton')
-        self.openLyricsButtonLayout.addWidget(self.openLyricsAddButton)
-        self.openLyricsButtonSpacer = QtGui.QSpacerItem(40, 20,
-            QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
-        self.openLyricsButtonLayout.addItem(self.openLyricsButtonSpacer)
-        self.openLyricsRemoveButton = QtGui.QPushButton(self.openLyricsPage)
-        self.openLyricsRemoveButton.setIcon(deleteIcon)
-        self.openLyricsRemoveButton.setObjectName(u'OpenLyricsRemoveButton')
-        self.openLyricsButtonLayout.addWidget(self.openLyricsRemoveButton)
-        self.openLyricsLayout.addLayout(self.openLyricsButtonLayout)
+        self.openLyricsDisabledLabel = QtGui.QLabel(self.openLyricsPage)
+        self.openLyricsDisabledLabel.setWordWrap(True)
+        self.openLyricsDisabledLabel.setObjectName(u'openLyricsDisabledLabel')
+        self.openLyricsLayout.addWidget(self.openLyricsDisabledLabel)
+        # Commented out for future use.
+        #self.openLyricsFileListWidget = QtGui.QListWidget(self.openLyricsPage)
+        #self.openLyricsFileListWidget.setSelectionMode(
+        #    QtGui.QAbstractItemView.ExtendedSelection)
+        #self.openLyricsFileListWidget.setObjectName(u'OpenLyricsFileListWidget')
+        #self.openLyricsLayout.addWidget(self.openLyricsFileListWidget)
+        #self.openLyricsButtonLayout = QtGui.QHBoxLayout()
+        #self.openLyricsButtonLayout.setSpacing(8)
+        #self.openLyricsButtonLayout.setObjectName(u'OpenLyricsButtonLayout')
+        #self.openLyricsAddButton = QtGui.QPushButton(self.openLyricsPage)
+        #self.openLyricsAddButton.setIcon(openIcon)
+        #self.openLyricsAddButton.setObjectName(u'OpenLyricsAddButton')
+        #self.openLyricsButtonLayout.addWidget(self.openLyricsAddButton)
+        #self.openLyricsButtonSpacer = QtGui.QSpacerItem(40, 20,
+        #    QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
+        #self.openLyricsButtonLayout.addItem(self.openLyricsButtonSpacer)
+        #self.openLyricsRemoveButton = QtGui.QPushButton(self.openLyricsPage)
+        #self.openLyricsRemoveButton.setIcon(deleteIcon)
+        #self.openLyricsRemoveButton.setObjectName(u'OpenLyricsRemoveButton')
+        #self.openLyricsButtonLayout.addWidget(self.openLyricsRemoveButton)
+        #self.openLyricsLayout.addLayout(self.openLyricsButtonLayout)
         self.formatStackedWidget.addWidget(self.openLyricsPage)
         # Open Song
         self.openSongPage = QtGui.QWidget()
@@ -277,22 +299,52 @@
         self.songsOfFellowshipLayout = QtGui.QVBoxLayout(
             self.songsOfFellowshipPage)
         self.songsOfFellowshipLayout.setMargin(0)
-        self.songsOfFellowshipLayout.setSpacing(8)
+        self.songsOfFellowshipLayout.setSpacing(0)
         self.songsOfFellowshipLayout.setObjectName(u'songsOfFellowshipLayout')
+        self.songsOfFellowshipDisabledWidget = QtGui.QWidget(
+            self.songsOfFellowshipPage)
+        self.songsOfFellowshipDisabledWidget.setVisible(False)
+        self.songsOfFellowshipDisabledWidget.setObjectName(
+            u'songsOfFellowshipDisabledWidget')
+        self.songsOfFellowshipDisabledLayout = QtGui.QVBoxLayout(
+            self.songsOfFellowshipDisabledWidget)
+        self.songsOfFellowshipDisabledLayout.setMargin(0)
+        self.songsOfFellowshipDisabledLayout.setSpacing(8)
+        self.songsOfFellowshipDisabledLayout.setObjectName(
+            u'songsOfFellowshipDisabledLayout')
+        self.songsOfFellowshipDisabledLabel = QtGui.QLabel(
+            self.songsOfFellowshipDisabledWidget)
+        self.songsOfFellowshipDisabledLabel.setWordWrap(True)
+        self.songsOfFellowshipDisabledLabel.setObjectName(
+            u'songsOfFellowshipDisabledLabel')
+        self.songsOfFellowshipDisabledLayout.addWidget(
+            self.songsOfFellowshipDisabledLabel)
+        self.songsOfFellowshipLayout.addWidget(
+            self.songsOfFellowshipDisabledWidget)
+        self.songsOfFellowshipImportWidget = QtGui.QWidget(
+            self.songsOfFellowshipPage)
+        self.songsOfFellowshipImportWidget.setObjectName(
+            u'songsOfFellowshipImportWidget')
+        self.songsOfFellowshipImportLayout = QtGui.QVBoxLayout(
+            self.songsOfFellowshipImportWidget)
+        self.songsOfFellowshipImportLayout.setMargin(0)
+        self.songsOfFellowshipImportLayout.setSpacing(8)
+        self.songsOfFellowshipImportLayout.setObjectName(
+            u'songsOfFellowshipImportLayout')
         self.songsOfFellowshipFileListWidget = QtGui.QListWidget(
-            self.songsOfFellowshipPage)
+            self.songsOfFellowshipImportWidget)
         self.songsOfFellowshipFileListWidget.setSelectionMode(
             QtGui.QAbstractItemView.ExtendedSelection)
         self.songsOfFellowshipFileListWidget.setObjectName(
             u'songsOfFellowshipFileListWidget')
-        self.songsOfFellowshipLayout.addWidget(
+        self.songsOfFellowshipImportLayout.addWidget(
             self.songsOfFellowshipFileListWidget)
         self.songsOfFellowshipButtonLayout = QtGui.QHBoxLayout()
         self.songsOfFellowshipButtonLayout.setSpacing(8)
         self.songsOfFellowshipButtonLayout.setObjectName(
             u'songsOfFellowshipButtonLayout')
         self.songsOfFellowshipAddButton = QtGui.QPushButton(
-            self.songsOfFellowshipPage)
+            self.songsOfFellowshipImportWidget)
         self.songsOfFellowshipAddButton.setIcon(openIcon)
         self.songsOfFellowshipAddButton.setObjectName(
             u'songsOfFellowshipAddButton')
@@ -303,42 +355,63 @@
         self.songsOfFellowshipButtonLayout.addItem(
             self.songsOfFellowshipButtonSpacer)
         self.songsOfFellowshipRemoveButton = QtGui.QPushButton(
-            self.songsOfFellowshipPage)
+            self.songsOfFellowshipImportWidget)
         self.songsOfFellowshipRemoveButton.setIcon(deleteIcon)
         self.songsOfFellowshipRemoveButton.setObjectName(
             u'songsOfFellowshipRemoveButton')
         self.songsOfFellowshipButtonLayout.addWidget(
             self.songsOfFellowshipRemoveButton)
-        self.songsOfFellowshipLayout.addLayout(
+        self.songsOfFellowshipImportLayout.addLayout(
             self.songsOfFellowshipButtonLayout)
+        self.songsOfFellowshipLayout.addWidget(
+            self.songsOfFellowshipImportWidget)
         self.formatStackedWidget.addWidget(self.songsOfFellowshipPage)
         # Generic Document/Presentation import
         self.genericPage = QtGui.QWidget()
         self.genericPage.setObjectName(u'genericPage')
         self.genericLayout = QtGui.QVBoxLayout(self.genericPage)
         self.genericLayout.setMargin(0)
-        self.genericLayout.setSpacing(8)
+        self.genericLayout.setSpacing(0)
         self.genericLayout.setObjectName(u'genericLayout')
-        self.genericFileListWidget = QtGui.QListWidget(self.genericPage)
+        self.genericDisabledWidget = QtGui.QWidget(self.genericPage)
+        self.genericDisabledWidget.setObjectName(u'genericDisabledWidget')
+        self.genericDisabledLayout = QtGui.QVBoxLayout(self.genericDisabledWidget)
+        self.genericDisabledLayout.setMargin(0)
+        self.genericDisabledLayout.setSpacing(8)
+        self.genericDisabledLayout.setObjectName(u'genericDisabledLayout')
+        self.genericDisabledLabel = QtGui.QLabel(self.genericDisabledWidget)
+        self.genericDisabledLabel.setWordWrap(True)
+        self.genericDisabledLabel.setObjectName(u'genericDisabledLabel')
+        self.genericDisabledWidget.setVisible(False)
+        self.genericDisabledLayout.addWidget(self.genericDisabledLabel)
+        self.genericLayout.addWidget(self.genericDisabledWidget)
+        self.genericImportWidget = QtGui.QWidget(self.genericPage)
+        self.genericImportWidget.setObjectName(u'genericImportWidget')
+        self.genericImportLayout = QtGui.QVBoxLayout(self.genericImportWidget)
+        self.genericImportLayout.setMargin(0)
+        self.genericImportLayout.setSpacing(8)
+        self.genericImportLayout.setObjectName(u'genericImportLayout')
+        self.genericFileListWidget = QtGui.QListWidget(self.genericImportWidget)
         self.genericFileListWidget.setSelectionMode(
             QtGui.QAbstractItemView.ExtendedSelection)
         self.genericFileListWidget.setObjectName(u'genericFileListWidget')
-        self.genericLayout.addWidget(self.genericFileListWidget)
+        self.genericImportLayout.addWidget(self.genericFileListWidget)
         self.genericButtonLayout = QtGui.QHBoxLayout()
         self.genericButtonLayout.setSpacing(8)
         self.genericButtonLayout.setObjectName(u'genericButtonLayout')
-        self.genericAddButton = QtGui.QPushButton(self.genericPage)
+        self.genericAddButton = QtGui.QPushButton(self.genericImportWidget)
         self.genericAddButton.setIcon(openIcon)
         self.genericAddButton.setObjectName(u'genericAddButton')
         self.genericButtonLayout.addWidget(self.genericAddButton)
         self.genericButtonSpacer = QtGui.QSpacerItem(40, 20,
             QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
         self.genericButtonLayout.addItem(self.genericButtonSpacer)
-        self.genericRemoveButton = QtGui.QPushButton(self.genericPage)
+        self.genericRemoveButton = QtGui.QPushButton(self.genericImportWidget)
         self.genericRemoveButton.setIcon(deleteIcon)
         self.genericRemoveButton.setObjectName(u'genericRemoveButton')
         self.genericButtonLayout.addWidget(self.genericRemoveButton)
-        self.genericLayout.addLayout(self.genericButtonLayout)
+        self.genericImportLayout.addLayout(self.genericButtonLayout)
+        self.genericLayout.addWidget(self.genericImportWidget)
         self.formatStackedWidget.addWidget(self.genericPage)
 #        Commented out for future use.
 #        self.csvPage = QtGui.QWidget()
@@ -434,10 +507,20 @@
             translate('SongsPlugin.ImportWizardForm', 'Filename:'))
         self.openLP1BrowseButton.setText(
             translate('SongsPlugin.ImportWizardForm', 'Browse...'))
-        self.openLyricsAddButton.setText(
-            translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
-        self.openLyricsRemoveButton.setText(
-            translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
+        self.openLP1DisabledLabel.setText(
+            translate('SongsPlugin.ImportWizardForm', 'The openlp.org 1.x '
+            'importer has been disabled due to a missing Python module. If '
+            'you want to use this importer, you will need to install the '
+            '"python-sqlite" module.'))
+        #self.openLyricsAddButton.setText(
+        #    translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
+        #self.openLyricsRemoveButton.setText(
+        #    translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
+        self.openLyricsDisabledLabel.setText(
+            translate('SongsPlugin.ImportWizardForm', 'The OpenLyrics '
+            'importer has not yet been developed, but as you can see, we are '
+            'still intendeding to do so. Hopefully it will be in the next '
+            'release.'))
         self.openSongAddButton.setText(
             translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
         self.openSongRemoveButton.setText(
@@ -454,10 +537,18 @@
             translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
         self.songsOfFellowshipRemoveButton.setText(
             translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
+        self.songsOfFellowshipDisabledLabel.setText(
+            translate('SongsPlugin.ImportWizardForm', 'The Songs of '
+            'Fellowship importer has been disabled because OpenLP cannot '
+            'find OpenOffice.org on your computer.'))
         self.genericAddButton.setText(
             translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
         self.genericRemoveButton.setText(
             translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
+        self.genericDisabledLabel.setText(
+            translate('SongsPlugin.ImportWizardForm', 'The generic document/'
+            'presentation importer has been disabled because OpenLP cannot '
+            'find OpenOffice.org on your computer.'))
 #        self.csvFilenameLabel.setText(
 #            translate('SongsPlugin.ImportWizardForm', 'Filename:'))
 #        self.csvBrowseButton.setText(

=== modified file 'openlp/plugins/songs/lib/importer.py'
--- openlp/plugins/songs/lib/importer.py	2010-09-06 22:02:48 +0000
+++ openlp/plugins/songs/lib/importer.py	2010-09-14 20:41:25 +0000
@@ -26,14 +26,24 @@
 
 from opensongimport import OpenSongImport
 from olpimport import OpenLPSongImport
-from olp1import import OpenLP1SongImport
+from wowimport import WowImport
+from cclifileimport import CCLIFileImport
+# Imports that might fail
+try:
+    from olp1import import OpenLP1SongImport
+    has_openlp1 = True
+except ImportError:
+    has_openlp1 = False
 try:
     from sofimport import SofImport
+    has_sof = True
+except ImportError:
+    has_sof = False
+try:
     from oooimport import OooImport
-    from cclifileimport import CCLIFileImport
-    from wowimport import WowImport
+    has_ooo = True
 except ImportError:
-    pass
+    has_ooo = False
 
 class SongFormat(object):
     """
@@ -41,6 +51,7 @@
     plus a few helper functions to facilitate generic handling of song types
     for importing.
     """
+    _format_availability = {}
     Unknown = -1
     OpenLP2 = 0
     OpenLP1 = 1
@@ -93,4 +104,16 @@
             SongFormat.Generic
         ]
 
+    @staticmethod
+    def set_availability(format, available):
+        SongFormat._format_availability[format] = available
+
+    @staticmethod
+    def get_availability(format):
+        return SongFormat._format_availability.get(format, True)
+
+SongFormat.set_availability(SongFormat.OpenLP1, has_openlp1)
+SongFormat.set_availability(SongFormat.SongsOfFellowship, has_sof)
+SongFormat.set_availability(SongFormat.Generic, has_ooo)
+
 __all__ = [u'SongFormat']

=== modified file 'openlp/plugins/songs/lib/olp1import.py'
--- openlp/plugins/songs/lib/olp1import.py	2010-09-14 14:43:21 +0000
+++ openlp/plugins/songs/lib/olp1import.py	2010-09-14 20:41:25 +0000
@@ -29,10 +29,7 @@
 """
 import logging
 import chardet
-try:
-    import sqlite
-except ImportError:
-    pass
+import sqlite
 
 from openlp.core.lib import translate
 from songimport import SongImport


Follow ups