← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol/openlp/python3-sqlite into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol/openlp/python3-sqlite into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~googol/openlp/python3-sqlite/+merge/159488

Hello,

- removed code using the sqlite package (which is not available in python 3)
-- 
https://code.launchpad.net/~googol/openlp/python3-sqlite/+merge/159488
Your team OpenLP Core is requested to review the proposed merge of lp:~googol/openlp/python3-sqlite into lp:openlp.
=== modified file 'openlp/core/lib/uistrings.py'
--- openlp/core/lib/uistrings.py	2013-02-03 19:34:53 +0000
+++ openlp/core/lib/uistrings.py	2013-04-17 20:14:27 +0000
@@ -107,7 +107,6 @@
         self.NFSp = translate('OpenLP.Ui', 'No Files Selected', 'Plural')
         self.NISs = translate('OpenLP.Ui', 'No Item Selected', 'Singular')
         self.NISp = translate('OpenLP.Ui', 'No Items Selected', 'Plural')
-        self.OLPV1 = translate('OpenLP.Ui', 'openlp.org 1.x')
         self.OLPV2 = translate('OpenLP.Ui', 'OpenLP 2')
         self.OLPV2x = translate('OpenLP.Ui', 'OpenLP 2.1')
         self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you wish to continue?')

=== modified file 'openlp/core/ui/exceptionform.py'
--- openlp/core/ui/exceptionform.py	2013-04-02 20:52:31 +0000
+++ openlp/core/ui/exceptionform.py	2013-04-17 20:14:27 +0000
@@ -60,11 +60,6 @@
 except ImportError:
     ENCHANT_VERSION = u'-'
 try:
-    import sqlite
-    SQLITE_VERSION = sqlite.version
-except ImportError:
-    SQLITE_VERSION = u'-'
-try:
     import mako
     MAKO_VERSION = mako.__version__
 except ImportError:
@@ -149,7 +144,6 @@
             u'lxml: %s\n' % etree.__version__ + \
             u'Chardet: %s\n' % CHARDET_VERSION + \
             u'PyEnchant: %s\n' % ENCHANT_VERSION + \
-            u'PySQLite: %s\n' % SQLITE_VERSION + \
             u'Mako: %s\n' % MAKO_VERSION + \
             u'pyICU: %s\n' % ICU_VERSION + \
             u'pyUNO bridge: %s\n' % UNO_VERSION + \

=== modified file 'openlp/core/ui/wizard.py'
--- openlp/core/ui/wizard.py	2013-03-19 19:43:22 +0000
+++ openlp/core/ui/wizard.py	2013-04-17 20:14:27 +0000
@@ -58,8 +58,6 @@
     ImportingType = translate('OpenLP.Ui', 'Importing "%s"...')
     ImportSelect = translate('OpenLP.Ui', 'Select Import Source')
     ImportSelectLong = translate('OpenLP.Ui', 'Select the import format and the location to import from.')
-    NoSqlite = translate('OpenLP.Ui', '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.')
     OpenTypeFile = translate('OpenLP.Ui', 'Open %s File')
     OpenTypeFolder = translate('OpenLP.Ui', 'Open %s Folder')
     PercentSymbolFormat = translate('OpenLP.Ui', '%p%')

=== modified file 'openlp/plugins/bibles/forms/bibleimportform.py'
--- openlp/plugins/bibles/forms/bibleimportform.py	2013-04-05 17:41:01 +0000
+++ openlp/plugins/bibles/forms/bibleimportform.py	2013-04-17 20:14:27 +0000
@@ -94,19 +94,11 @@
         button.
         """
         self.selectStack.setCurrentIndex(index)
-        next_button = self.button(QtGui.QWizard.NextButton)
-        next_button.setEnabled(BibleFormat.get_availability(index))
 
     def custom_init(self):
         """
         Perform any custom initialisation for bible importing.
         """
-        if BibleFormat.get_availability(BibleFormat.OpenLP1):
-            self.openlp1DisabledLabel.hide()
-        else:
-            self.openlp1FileLabel.hide()
-            self.openlp1FileEdit.hide()
-            self.openlp1BrowseButton.hide()
         self.manager.set_process_dialog(self)
         self.loadWebBibles()
         self.restart()
@@ -121,7 +113,6 @@
         self.csvBooksButton.clicked.connect(self.onCsvBooksBrowseButtonClicked)
         self.csvVersesButton.clicked.connect(self.onCsvVersesBrowseButtonClicked)
         self.openSongBrowseButton.clicked.connect(self.onOpenSongBrowseButtonClicked)
-        self.openlp1BrowseButton.clicked.connect(self.onOpenlp1BrowseButtonClicked)
 
     def add_custom_pages(self):
         """
@@ -259,29 +250,6 @@
         self.webProxyLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.webPasswordEdit)
         self.webTabWidget.addTab(self.webProxyTab, u'')
         self.selectStack.addWidget(self.webTabWidget)
-        self.openlp1Widget = QtGui.QWidget(self.selectPage)
-        self.openlp1Widget.setObjectName(u'Openlp1Widget')
-        self.openlp1Layout = QtGui.QFormLayout(self.openlp1Widget)
-        self.openlp1Layout.setMargin(0)
-        self.openlp1Layout.setObjectName(u'Openlp1Layout')
-        self.openlp1FileLabel = QtGui.QLabel(self.openlp1Widget)
-        self.openlp1FileLabel.setObjectName(u'Openlp1FileLabel')
-        self.openlp1FileLayout = QtGui.QHBoxLayout()
-        self.openlp1FileLayout.setObjectName(u'Openlp1FileLayout')
-        self.openlp1FileEdit = QtGui.QLineEdit(self.openlp1Widget)
-        self.openlp1FileEdit.setObjectName(u'Openlp1FileEdit')
-        self.openlp1FileLayout.addWidget(self.openlp1FileEdit)
-        self.openlp1BrowseButton = QtGui.QToolButton(self.openlp1Widget)
-        self.openlp1BrowseButton.setIcon(self.open_icon)
-        self.openlp1BrowseButton.setObjectName(u'Openlp1BrowseButton')
-        self.openlp1FileLayout.addWidget(self.openlp1BrowseButton)
-        self.openlp1Layout.addRow(self.openlp1FileLabel, self.openlp1FileLayout)
-        self.openlp1DisabledLabel = QtGui.QLabel(self.openlp1Widget)
-        self.openlp1DisabledLabel.setWordWrap(True)
-        self.openlp1DisabledLabel.setObjectName(u'Openlp1DisabledLabel')
-        self.openlp1Layout.addRow(self.openlp1DisabledLabel)
-        self.openlp1Layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer)
-        self.selectStack.addWidget(self.openlp1Widget)
         self.selectPageLayout.addLayout(self.selectStack)
         self.addPage(self.selectPage)
         # License Page
@@ -330,8 +298,6 @@
         self.formatComboBox.setItemText(BibleFormat.OpenSong, WizardStrings.OS)
         self.formatComboBox.setItemText(BibleFormat.WebDownload,
             translate('BiblesPlugin.ImportWizardForm', 'Web Download'))
-        self.formatComboBox.setItemText(BibleFormat.OpenLP1, UiStrings().OLPV1)
-        self.openlp1FileLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:'))
         self.osisFileLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:'))
         self.csvBooksLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Books file:'))
         self.csvVersesLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Verses file:'))
@@ -364,14 +330,12 @@
             'Please wait while your Bible is imported.'))
         self.progress_label.setText(WizardStrings.Ready)
         self.progress_bar.setFormat(u'%p%')
-        self.openlp1DisabledLabel.setText(WizardStrings.NoSqlite)
         # Align all QFormLayouts towards each other.
         labelWidth = max(self.formatLabel.minimumSizeHint().width(),
             self.osisFileLabel.minimumSizeHint().width(),
             self.csvBooksLabel.minimumSizeHint().width(),
             self.csvVersesLabel.minimumSizeHint().width(),
-            self.openSongFileLabel.minimumSizeHint().width(),
-            self.openlp1FileLabel.minimumSizeHint().width())
+            self.openSongFileLabel.minimumSizeHint().width())
         self.spacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
 
     def validateCurrentPage(self):
@@ -406,11 +370,6 @@
             elif self.field(u'source_format') == BibleFormat.WebDownload:
                 self.versionNameEdit.setText(self.webTranslationComboBox.currentText())
                 return True
-            elif self.field(u'source_format') == BibleFormat.OpenLP1:
-                if not self.field(u'openlp1_location'):
-                    critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % UiStrings().OLPV1)
-                    self.openlp1FileEdit.setFocus()
-                    return False
             return True
         elif self.currentPage() == self.licenseDetailsPage:
             license_version = self.field(u'license_version')
@@ -484,13 +443,6 @@
         """
         self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OS, self.openSongFileEdit, u'last directory import')
 
-    def onOpenlp1BrowseButtonClicked(self):
-        """
-        Show the file open dialog for the openlp.org 1.x file.
-        """
-        self.get_file_name(WizardStrings.OpenTypeFile % UiStrings().OLPV1, self.openlp1FileEdit, u'last directory import',
-            u'%s (*.bible)' % translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x Bible Files'))
-
     def register_fields(self):
         """
         Register the bible import wizard fields.
@@ -505,7 +457,6 @@
         self.selectPage.registerField(u'proxy_server', self.webServerEdit)
         self.selectPage.registerField(u'proxy_username', self.webUserEdit)
         self.selectPage.registerField(u'proxy_password', self.webPasswordEdit)
-        self.selectPage.registerField(u'openlp1_location', self.openlp1FileEdit)
         self.licenseDetailsPage.registerField(u'license_version', self.versionNameEdit)
         self.licenseDetailsPage.registerField(u'license_copyright', self.copyrightEdit)
         self.licenseDetailsPage.registerField(u'license_permissions', self.permissionsEdit)
@@ -529,7 +480,6 @@
         self.setField(u'proxy_server', settings.value(u'proxy address'))
         self.setField(u'proxy_username', settings.value(u'proxy username'))
         self.setField(u'proxy_password', settings.value(u'proxy password'))
-        self.setField(u'openlp1_location', '')
         self.setField(u'license_version', self.versionNameEdit.text())
         self.setField(u'license_copyright', self.copyrightEdit.text())
         self.setField(u'license_permissions', self.permissionsEdit.text())
@@ -615,12 +565,6 @@
                 proxy_username=self.field(u'proxy_username'),
                 proxy_password=self.field(u'proxy_password')
             )
-        elif bible_type == BibleFormat.OpenLP1:
-            # Import an openlp.org 1.x bible.
-            importer = self.manager.import_bible(BibleFormat.OpenLP1,
-                name=license_version,
-                filename=self.field(u'openlp1_location')
-            )
         if importer.do_import(license_version):
             self.manager.save_meta_data(license_version, license_version,
                 license_copyright, license_permissions)

=== modified file 'openlp/plugins/bibles/lib/manager.py'
--- openlp/plugins/bibles/lib/manager.py	2013-03-19 19:43:22 +0000
+++ openlp/plugins/bibles/lib/manager.py	2013-04-17 20:14:27 +0000
@@ -38,28 +38,21 @@
 from http import HTTPBible
 from opensong import OpenSongBible
 from osis import OSISBible
-# Imports that might fail.
-try:
-    from openlp1 import OpenLP1Bible
-    HAS_OPENLP1 = True
-except ImportError:
-    HAS_OPENLP1 = False
+
+
 
 log = logging.getLogger(__name__)
 
+
 class BibleFormat(object):
     """
-    This is a special enumeration class that holds the various types of Bibles,
-    plus a few helper functions to facilitate generic handling of Bible types
-    for importing.
+    This is a special enumeration class that holds the various types of Bibles.
     """
-    _format_availability = {}
     Unknown = -1
     OSIS = 0
     CSV = 1
     OpenSong = 2
     WebDownload = 3
-    OpenLP1 = 4
 
     @staticmethod
     def get_class(format):
@@ -77,8 +70,6 @@
             return OpenSongBible
         elif format == BibleFormat.WebDownload:
             return HTTPBible
-        elif format == BibleFormat.OpenLP1:
-            return OpenLP1Bible
         else:
             return None
 
@@ -92,17 +83,8 @@
             BibleFormat.CSV,
             BibleFormat.OpenSong,
             BibleFormat.WebDownload,
-            BibleFormat.OpenLP1
         ]
 
-    @staticmethod
-    def set_availability(format, available):
-        BibleFormat._format_availability[format] = available
-
-    @staticmethod
-    def get_availability(format):
-        return BibleFormat._format_availability.get(format, True)
-
 
 class BibleManager(object):
     """
@@ -463,6 +445,5 @@
 
     main_window = property(_get_main_window)
 
-BibleFormat.set_availability(BibleFormat.OpenLP1, HAS_OPENLP1)
 
 __all__ = [u'BibleFormat']

=== removed file 'openlp/plugins/bibles/lib/openlp1.py'
--- openlp/plugins/bibles/lib/openlp1.py	2013-03-07 08:05:43 +0000
+++ openlp/plugins/bibles/lib/openlp1.py	1970-01-01 00:00:00 +0000
@@ -1,113 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
-
-###############################################################################
-# OpenLP - Open Source Lyrics Projection                                      #
-# --------------------------------------------------------------------------- #
-# Copyright (c) 2008-2013 Raoul Snyman                                        #
-# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan      #
-# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub,      #
-# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer.   #
-# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru,          #
-# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith,             #
-# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock,              #
-# Frode Woldsund, Martin Zibricky, Patrick Zimmermann                         #
-# --------------------------------------------------------------------------- #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; version 2 of the License.                              #
-#                                                                             #
-# This program is distributed in the hope that it will be useful, but WITHOUT #
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    #
-# more details.                                                               #
-#                                                                             #
-# You should have received a copy of the GNU General Public License along     #
-# with this program; if not, write to the Free Software Foundation, Inc., 59  #
-# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
-###############################################################################
-
-import logging
-import sqlite
-import sys
-
-from openlp.core.ui.wizard import WizardStrings
-from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
-
-log = logging.getLogger(__name__)
-
-class OpenLP1Bible(BibleDB):
-    """
-    This class provides the OpenLPv1 bible importer.
-    """
-    def __init__(self, parent, **kwargs):
-        """
-        Constructor.
-        """
-        log.debug(self.__class__.__name__)
-        BibleDB.__init__(self, parent, **kwargs)
-        self.filename = kwargs[u'filename']
-
-    def do_import(self, bible_name=None):
-        """
-        Imports an openlp.org v1 bible.
-        """
-        connection = None
-        cursor = None
-        try:
-            connection = sqlite.connect(self.filename.encode(sys.getfilesystemencoding()))
-            cursor = connection.cursor()
-        except sqlite.DatabaseError:
-            log.exception(u'File "%s" is encrypted or not a sqlite database, '
-                'therefore not an openlp.org 1.x database either' % self.filename)
-            # Please add an user error here!
-            # This file is not an openlp.org 1.x bible database.
-            return False
-        #Create the bible language
-        language_id = self.get_language(bible_name)
-        if not language_id:
-            log.exception(u'Importing books from "%s" failed' % self.filename)
-            return False
-        # Create all books.
-        try:
-            cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
-        except sqlite.DatabaseError as error:
-            log.exception(u'DatabaseError: %s' % error)
-            # Please add an user error here!
-            # This file is not an openlp.org 1.x bible database.
-            return False
-        books = cursor.fetchall()
-        self.wizard.progress_bar.setMaximum(len(books) + 1)
-        for book in books:
-            if self.stop_import_flag:
-                connection.close()
-                return False
-            book_id = int(book[0])
-            testament_id = int(book[1])
-            name = unicode(book[2], u'cp1252')
-            abbreviation = unicode(book[3], u'cp1252')
-            book_ref_id = self.get_book_ref_id_by_name(name, len(books),
-                language_id)
-            if not book_ref_id:
-                log.exception(u'Importing books from "%s" failed' % self.filename)
-                return False
-            book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
-            db_book = self.create_book(name, book_ref_id, book_details[u'testament_id'])
-            # Update the progess bar.
-            self.wizard.increment_progress_bar(WizardStrings.ImportingType % name)
-            # Import the verses for this book.
-            cursor.execute(u'SELECT chapter, verse, text || \'\' AS text FROM '
-                'verse WHERE book_id=%s' % book_id)
-            verses = cursor.fetchall()
-            for verse in verses:
-                if self.stop_import_flag:
-                    connection.close()
-                    return False
-                chapter = int(verse[0])
-                verse_number = int(verse[1])
-                text = unicode(verse[2], u'cp1252')
-                self.create_verse(db_book.id, chapter, verse_number, text)
-                self.application.process_events()
-            self.session.commit()
-        connection.close()
-        return True

=== modified file 'openlp/plugins/songs/lib/importer.py'
--- openlp/plugins/songs/lib/importer.py	2013-03-07 08:05:43 +0000
+++ openlp/plugins/songs/lib/importer.py	2013-04-17 20:14:27 +0000
@@ -50,13 +50,11 @@
 from foilpresenterimport import FoilPresenterImport
 from zionworximport import ZionWorxImport
 # Imports that might fail
+
+
 log = logging.getLogger(__name__)
-try:
-    from olp1import import OpenLP1SongImport
-    HAS_OPENLP1 = True
-except ImportError:
-    log.exception('Error importing %s', 'OpenLP1SongImport')
-    HAS_OPENLP1 = False
+
+
 try:
     from sofimport import SofImport
     HAS_SOF = True
@@ -144,23 +142,22 @@
     Unknown = -1
     OpenLyrics = 0
     OpenLP2 = 1
-    OpenLP1 = 2
-    Generic = 3
-    CCLI = 4
-    DreamBeam = 5
-    EasySlides = 6
-    EasyWorship = 7
-    FoilPresenter = 8
-    MediaShout = 9
-    OpenSong = 10
-    PowerSong = 11
-    SongBeamer = 12
-    SongPro = 13
-    SongShowPlus = 14
-    SongsOfFellowship = 15
-    SundayPlus = 16
-    WordsOfWorship = 17
-    ZionWorx = 18
+    Generic = 2
+    CCLI = 3
+    DreamBeam = 4
+    EasySlides = 5
+    EasyWorship = 6
+    FoilPresenter = 7
+    MediaShout = 8
+    OpenSong = 9
+    PowerSong = 10
+    SongBeamer = 11
+    SongPro = 12
+    SongShowPlus = 13
+    SongsOfFellowship = 14
+    SundayPlus = 15
+    WordsOfWorship = 16
+    ZionWorx = 17
 
     # Set optional attribute defaults
     __defaults__ = {
@@ -191,14 +188,6 @@
             u'selectMode': SongFormatSelect.SingleFile,
             u'filter': u'%s (*.sqlite)' % (translate('SongsPlugin.ImportWizardForm', 'OpenLP 2.0 Databases'))
         },
-        OpenLP1: {
-            u'name': UiStrings().OLPV1,
-            u'prefix': u'openLP1',
-            u'canDisable': True,
-            u'selectMode': SongFormatSelect.SingleFile,
-            u'filter': u'%s (*.olp)' % translate('SongsPlugin.ImportWizardForm', 'openlp.org v1.x Databases'),
-            u'disabledLabelText': WizardStrings.NoSqlite
-        },
         Generic: {
             u'name': translate('SongsPlugin.ImportWizardForm', 'Generic Document/Presentation'),
             u'prefix': u'generic',
@@ -332,7 +321,6 @@
         return [
             SongFormat.OpenLyrics,
             SongFormat.OpenLP2,
-            SongFormat.OpenLP1,
             SongFormat.Generic,
             SongFormat.CCLI,
             SongFormat.DreamBeam,
@@ -387,9 +375,7 @@
         """
         SongFormat.__attributes__[format][attribute] = value
 
-SongFormat.set(SongFormat.OpenLP1, u'availability', HAS_OPENLP1)
-if HAS_OPENLP1:
-    SongFormat.set(SongFormat.OpenLP1, u'class', OpenLP1SongImport)
+
 SongFormat.set(SongFormat.SongsOfFellowship, u'availability', HAS_SOF)
 if HAS_SOF:
     SongFormat.set(SongFormat.SongsOfFellowship, u'class', SofImport)

=== removed file 'openlp/plugins/songs/lib/olp1import.py'
--- openlp/plugins/songs/lib/olp1import.py	2013-03-07 08:05:43 +0000
+++ openlp/plugins/songs/lib/olp1import.py	1970-01-01 00:00:00 +0000
@@ -1,227 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
-
-###############################################################################
-# OpenLP - Open Source Lyrics Projection                                      #
-# --------------------------------------------------------------------------- #
-# Copyright (c) 2008-2013 Raoul Snyman                                        #
-# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan      #
-# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub,      #
-# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer.   #
-# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru,          #
-# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith,             #
-# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock,              #
-# Frode Woldsund, Martin Zibricky, Patrick Zimmermann                         #
-# --------------------------------------------------------------------------- #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; version 2 of the License.                              #
-#                                                                             #
-# This program is distributed in the hope that it will be useful, but WITHOUT #
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    #
-# more details.                                                               #
-#                                                                             #
-# You should have received a copy of the GNU General Public License along     #
-# with this program; if not, write to the Free Software Foundation, Inc., 59  #
-# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
-###############################################################################
-"""
-The :mod:`olp1import` module provides the functionality for importing
-openlp.org 1.x song databases into the current installation database.
-"""
-
-import logging
-from chardet.universaldetector import UniversalDetector
-import sqlite
-import sys
-import os
-
-from openlp.core.lib import Registry, translate
-from openlp.plugins.songs.lib import retrieve_windows_encoding
-from songimport import SongImport
-
-log = logging.getLogger(__name__)
-
-class OpenLP1SongImport(SongImport):
-    """
-    The :class:`OpenLP1SongImport` class provides OpenLP with the ability to
-    import song databases from installations of openlp.org 1.x.
-    """
-    lastEncoding = u'windows-1252'
-
-    def __init__(self, manager, **kwargs):
-        """
-        Initialise the import.
-
-        ``manager``
-            The song manager for the running OpenLP installation.
-
-        ``filename``
-            The database providing the data to import.
-        """
-        SongImport.__init__(self, manager, **kwargs)
-
-    def doImport(self):
-        """
-        Run the import for an openlp.org 1.x song database.
-        """
-        if not self.import_source.endswith(u'.olp'):
-            self.logError(self.import_source,
-                translate('SongsPlugin.OpenLP1SongImport', 'Not a valid openlp.org 1.x song database.'))
-            return
-        encoding = self.getEncoding()
-        if not encoding:
-            return
-        # Connect to the database.
-        connection = sqlite.connect(self.import_source, mode=0444, encoding=(encoding, 'replace'))
-        cursor = connection.cursor()
-        # Determine if the db supports linking audio to songs.
-        cursor.execute(u'SELECT name FROM sqlite_master '
-            u'WHERE type = \'table\' AND name = \'tracks\'')
-        db_has_tracks = len(cursor.fetchall()) > 0
-        # Determine if the db contains theme information.
-        cursor.execute(u'SELECT name FROM sqlite_master '
-            u'WHERE type = \'table\' AND name = \'settings\'')
-        db_has_themes = len(cursor.fetchall()) > 0
-        # "cache" our list of authors.
-        cursor.execute(u'-- types int, unicode')
-        cursor.execute(u'SELECT authorid, authorname FROM authors')
-        authors = cursor.fetchall()
-        if db_has_tracks:
-            # "cache" our list of tracks.
-            cursor.execute(u'-- types int, unicode')
-            cursor.execute(u'SELECT trackid, fulltrackname FROM tracks')
-            tracks = cursor.fetchall()
-        if db_has_themes:
-            # "cache" our list of themes.
-            themes = {}
-            cursor.execute(u'-- types int, unicode')
-            cursor.execute(u'SELECT settingsid, settingsname FROM settings')
-            for theme_id, theme_name in cursor.fetchall():
-                if theme_name in self.theme_manager.get_themes():
-                    themes[theme_id] = theme_name
-        # Import the songs.
-        cursor.execute(u'-- types int, unicode, unicode, unicode')
-        cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS ' \
-                u'lyrics, copyrightinfo FROM songs')
-        songs = cursor.fetchall()
-        self.import_wizard.progress_bar.setMaximum(len(songs))
-        for song in songs:
-            self.setDefaults()
-            if self.stop_import_flag:
-                break
-            song_id = song[0]
-            self.title = song[1]
-            lyrics = song[2].replace(u'\r\n', u'\n')
-            self.addCopyright(song[3])
-            if db_has_themes:
-                cursor.execute(u'-- types int')
-                cursor.execute(
-                    u'SELECT settingsid FROM songs WHERE songid = %s' % song_id)
-                theme_id = cursor.fetchone()[0]
-                self.themeName = themes.get(theme_id, u'')
-            verses = lyrics.split(u'\n\n')
-            for verse in verses:
-                if verse.strip():
-                    self.addVerse(verse.strip())
-            cursor.execute(u'-- types int')
-            cursor.execute(u'SELECT authorid FROM songauthors '
-                u'WHERE songid = %s' % song_id)
-            author_ids = cursor.fetchall()
-            for author_id in author_ids:
-                if self.stop_import_flag:
-                    break
-                for author in authors:
-                    if author[0] == author_id[0]:
-                        self.parse_author(author[1])
-                        break
-            if self.stop_import_flag:
-                break
-            if db_has_tracks:
-                cursor.execute(u'-- types int, int')
-                cursor.execute(u'SELECT trackid, listindex '
-                    u'FROM songtracks '
-                    u'WHERE songid = %s ORDER BY listindex' % song_id)
-                track_ids = cursor.fetchall()
-                for track_id, listindex in track_ids:
-                    if self.stop_import_flag:
-                        break
-                    for track in tracks:
-                        if track[0] == track_id:
-                            media_file = self.expandMediaFile(track[1])
-                            self.addMediaFile(media_file, listindex)
-                            break
-            if self.stop_import_flag:
-                break
-            if not self.finish():
-                self.logError(self.import_source)
-
-    def getEncoding(self):
-        """
-        Detect character encoding of an openlp.org 1.x song database.
-        """
-        # Connect to the database.
-        connection = sqlite.connect(self.import_source.encode(
-            sys.getfilesystemencoding()), mode=0444)
-        cursor = connection.cursor()
-
-        detector = UniversalDetector()
-        # Detect charset by authors.
-        cursor.execute(u'SELECT authorname FROM authors')
-        authors = cursor.fetchall()
-        for author in authors:
-            detector.feed(author[0])
-            if detector.done:
-                detector.close()
-                return detector.result[u'encoding']
-        # Detect charset by songs.
-        cursor.execute(u'SELECT songtitle, copyrightinfo, '
-            u'lyrics || \'\' AS lyrics FROM songs')
-        songs = cursor.fetchall()
-        for index in [0, 1, 2]:
-            for song in songs:
-                detector.feed(song[index])
-                if detector.done:
-                    detector.close()
-                    return detector.result[u'encoding']
-        # Detect charset by songs.
-        cursor.execute(u'SELECT name FROM sqlite_master '
-            u'WHERE type = \'table\' AND name = \'tracks\'')
-        if cursor.fetchall():
-            cursor.execute(u'SELECT fulltrackname FROM tracks')
-            tracks = cursor.fetchall()
-            for track in tracks:
-                detector.feed(track[0])
-                if detector.done:
-                    detector.close()
-                    return detector.result[u'encoding']
-        detector.close()
-        return retrieve_windows_encoding(detector.result[u'encoding'])
-
-    def expandMediaFile(self, filename):
-        """
-        When you're on Windows, this function expands the file name to include
-        the path to OpenLP's application data directory. If you are not on
-        Windows, it returns the original file name.
-
-        ``filename``
-            The filename to expand.
-        """
-        if sys.platform != u'win32' and not os.environ.get(u'ALLUSERSPROFILE') and not os.environ.get(u'APPDATA'):
-            return filename
-        common_app_data = os.path.join(os.environ[u'ALLUSERSPROFILE'],
-            os.path.split(os.environ[u'APPDATA'])[1])
-        if not common_app_data:
-            return filename
-        return os.path.join(common_app_data, u'openlp.org', 'Audio', filename)
-
-    def _get_theme_manager(self):
-        """
-        Adds the theme manager to the class dynamically
-        """
-        if not hasattr(self, u'_theme_manager'):
-            self._theme_manager = Registry().get(u'theme_manager')
-        return self._theme_manager
-
-    theme_manager = property(_get_theme_manager)

=== modified file 'scripts/check_dependencies.py'
--- scripts/check_dependencies.py	2013-03-30 21:54:42 +0000
+++ scripts/check_dependencies.py	2013-04-17 20:14:27 +0000
@@ -88,7 +88,6 @@
 
 
 OPTIONAL_MODULES = [
-    ('sqlite', ' (SQLite 2 support)'),
     ('MySQLdb', ' (MySQL support)'),
     ('psycopg2', ' (PostgreSQL support)'),
     ('nose', ' (testing framework)'),


Follow ups