← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/bibles into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/bibles into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)


- openlp.org 1.x bible importer
- some clean ups
-- 
https://code.launchpad.net/~googol-hush/openlp/bibles/+merge/42971
Your team OpenLP Core is requested to review the proposed merge of lp:~googol-hush/openlp/bibles into lp:openlp.
=== modified file 'openlp/plugins/bibles/forms/bibleimportform.py'
--- openlp/plugins/bibles/forms/bibleimportform.py	2010-11-12 22:27:57 +0000
+++ openlp/plugins/bibles/forms/bibleimportform.py	2010-12-07 16:43:16 +0000
@@ -99,6 +99,9 @@
         QtCore.QObject.connect(self.OpenSongBrowseButton,
             QtCore.SIGNAL(u'clicked()'),
             self.onOpenSongBrowseButtonClicked)
+        QtCore.QObject.connect(self.OLP1FileButton,
+            QtCore.SIGNAL(u'clicked()'),
+            self.onOLP1FileButtonClicked)
         QtCore.QObject.connect(self.cancelButton,
             QtCore.SIGNAL(u'clicked(bool)'),
             self.onCancelButtonClicked)
@@ -123,7 +126,7 @@
         elif self.currentId() == 1:
             # Select page
             if self.field(u'source_format').toInt()[0] == BibleFormat.OSIS:
-                if self.field(u'osis_location').toString() == u'':
+                if not self.field(u'osis_location').toString():
                     QtGui.QMessageBox.critical(self,
                         translate('BiblesPlugin.ImportWizardForm',
                         'Invalid Bible Location'),
@@ -162,6 +165,16 @@
                         'file to import.'))
                     self.OpenSongFileEdit.setFocus()
                     return False
+            elif self.field(u'source_format').toInt()[0] == BibleFormat.OLP1:
+                if not self.field(u'OLP1_location').toString():
+                    QtGui.QMessageBox.critical(self,
+                        translate('BiblesPlugin.ImportWizardForm',
+                        'Invalid Bible Location'),
+                        translate('BiblesPlugin.ImportWizardForm',
+                        'You need to specify a file to import your '
+                        'Bible from.'))
+                    self.OLP1LocationEdit.setFocus()
+                    return False
             return True
         elif self.currentId() == 2:
             # License details
@@ -244,6 +257,14 @@
             translate('BiblesPlugin.ImportWizardForm', 'Open OpenSong Bible'),
             self.OpenSongFileEdit)
 
+    def onOLP1FileButtonClicked(self):
+        """
+        Show the file open dialog for the openlp.org 1.x file.
+        """
+        self.getFileName(
+            translate('BiblesPlugin.ImportWizardForm',
+            'Open openlp.org 1.x Bible'), self.OLP1LocationEdit)
+
     def onCancelButtonClicked(self, checked):
         """
         Stop the import on pressing the cancel button.
@@ -279,6 +300,8 @@
             u'proxy_username', self.UsernameEdit)
         self.SelectPage.registerField(
             u'proxy_password', self.PasswordEdit)
+        self.SelectPage.registerField(
+            u'OLP1_location', self.OLP1LocationEdit)
         self.LicenseDetailsPage.registerField(
             u'license_version', self.VersionNameEdit)
         self.LicenseDetailsPage.registerField(
@@ -306,6 +329,7 @@
             settings.value(u'proxy username', QtCore.QVariant(u'')))
         self.setField(u'proxy_password',
             settings.value(u'proxy password', QtCore.QVariant(u'')))
+        self.setField(u'OLP1_location', QtCore.QVariant(''))
         self.setField(u'license_version',
             QtCore.QVariant(self.VersionNameEdit.text()))
         self.setField(u'license_copyright',
@@ -381,6 +405,9 @@
         Receiver.send_message(u'openlp_process_events')
 
     def preImport(self):
+        """
+        Prepare the UI for the import.
+        """
         bible_type = self.field(u'source_format').toInt()[0]
         self.finishButton.setVisible(False)
         self.ImportProgressBar.setMinimum(0)
@@ -396,6 +423,9 @@
         Receiver.send_message(u'openlp_process_events')
 
     def performImport(self):
+        """
+        Perform the actual import.
+        """
         bible_type = self.field(u'source_format').toInt()[0]
         license_version = unicode(self.field(u'license_version').toString())
         license_copyright = unicode(self.field(u'license_copyright').toString())
@@ -442,6 +472,12 @@
                     unicode(self.field(u'proxy_username').toString()),
                 proxy_password=unicode(self.field(u'proxy_password').toString())
             )
+        elif bible_type == BibleFormat.OLP1:
+            # Import an openlp.org 1.x bible.
+            importer = self.manager.import_bible(BibleFormat.OLP1,
+                name=license_version,
+                filename=unicode(self.field(u'OLP1_location').toString())
+            )
         if importer.do_import():
             self.manager.save_meta_data(license_version, license_version,
                 license_copyright, license_permissions)
@@ -455,9 +491,8 @@
                 self.ImportProgressLabel.setText(translate(
                     'BiblesPlugin.ImportWizardForm', 'Finished import.'))
         else:
-            self.ImportProgressLabel.setText(
-                translate('BiblesPlugin.ImportWizardForm',
-                'Your Bible import failed.'))
+            self.ImportProgressLabel.setText(translate(
+                'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.'))
             delete_database(self.bibleplugin.settingsSection, importer.file)
 
     def postImport(self):

=== modified file 'openlp/plugins/bibles/forms/bibleimportwizard.py'
--- openlp/plugins/bibles/forms/bibleimportwizard.py	2010-10-08 17:07:49 +0000
+++ openlp/plugins/bibles/forms/bibleimportwizard.py	2010-12-07 16:43:16 +0000
@@ -38,6 +38,7 @@
             QtGui.QWizard.IndependentPages |
             QtGui.QWizard.NoBackButtonOnStartPage |
             QtGui.QWizard.NoBackButtonOnLastPage)
+        # Welcome page
         self.WelcomePage = QtGui.QWizardPage()
         self.WelcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap,
             QtGui.QPixmap(u':/wizards/wizard_importbible.bmp'))
@@ -61,6 +62,7 @@
             QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
         self.WelcomeLayout.addItem(spacerItem1)
         BibleImportWizard.addPage(self.WelcomePage)
+        # Select page
         self.SelectPage = QtGui.QWizardPage()
         self.SelectPage.setObjectName(u'SelectPage')
         self.selectPageLayout = QtGui.QVBoxLayout(self.SelectPage)
@@ -79,6 +81,7 @@
         self.FormatComboBox.addItem(u'')
         self.FormatComboBox.addItem(u'')
         self.FormatComboBox.addItem(u'')
+        self.FormatComboBox.addItem(u'')
         self.FormatSelectLayout.addWidget(self.FormatComboBox)
         spacerItem2 = QtGui.QSpacerItem(40, 20,
             QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
@@ -86,6 +89,7 @@
         self.selectPageLayout.addLayout(self.FormatSelectLayout)
         self.FormatWidget = QtGui.QStackedWidget(self.SelectPage)
         self.FormatWidget.setObjectName(u'FormatWidget')
+        generalIcon = build_icon(u':/general/general_open.png')
         self.OsisPage = QtGui.QWidget()
         self.OsisPage.setObjectName(u'OsisPage')
         self.OsisLayout = QtGui.QFormLayout(self.OsisPage)
@@ -106,7 +110,6 @@
         self.OsisLocationLayout.addWidget(self.OSISLocationEdit)
         self.OsisFileButton = QtGui.QToolButton(self.OsisPage)
         self.OsisFileButton.setMaximumSize(QtCore.QSize(32, 16777215))
-        generalIcon = build_icon(u':/general/general_open.png')
         self.OsisFileButton.setIcon(generalIcon)
         self.OsisFileButton.setObjectName(u'OsisFileButton')
         self.OsisLocationLayout.addWidget(self.OsisFileButton)
@@ -251,8 +254,35 @@
         self.WebDownloadTabWidget.addTab(self.ProxyServerTab, u'')
         self.WebDownloadLayout.addWidget(self.WebDownloadTabWidget)
         self.FormatWidget.addWidget(self.WebDownloadPage)
+        self.OLP1Page = QtGui.QWidget()
+        self.OLP1Page.setObjectName(u'OLP1Page')
+        self.OLP1Layout = QtGui.QFormLayout(self.OLP1Page)
+        self.OLP1Layout.setFieldGrowthPolicy(
+            QtGui.QFormLayout.ExpandingFieldsGrow)
+        self.OLP1Layout.setMargin(0)
+        self.OLP1Layout.setSpacing(8)
+        self.OLP1Layout.setObjectName(u'OLP1Layout')
+        self.OLP1LocationLabel = QtGui.QLabel(self.OLP1Page)
+        self.OLP1LocationLabel.setObjectName(u'OLP1LocationLabel')
+        self.OLP1Layout.setWidget(1, QtGui.QFormLayout.LabelRole,
+            self.OLP1LocationLabel)
+        self.OLP1LocationLayout = QtGui.QHBoxLayout()
+        self.OLP1LocationLayout.setSpacing(8)
+        self.OLP1LocationLayout.setObjectName(u'OLP1LocationLayout')
+        self.OLP1LocationEdit = QtGui.QLineEdit(self.OLP1Page)
+        self.OLP1LocationEdit.setObjectName(u'OLP1LocationEdit')
+        self.OLP1LocationLayout.addWidget(self.OLP1LocationEdit)
+        self.OLP1FileButton = QtGui.QToolButton(self.OLP1Page)
+        self.OLP1FileButton.setMaximumSize(QtCore.QSize(32, 16777215))
+        self.OLP1FileButton.setIcon(generalIcon)
+        self.OLP1FileButton.setObjectName(u'OLP1FileButton')
+        self.OLP1LocationLayout.addWidget(self.OLP1FileButton)
+        self.OLP1Layout.setLayout(1, QtGui.QFormLayout.FieldRole,
+            self.OLP1LocationLayout)
+        self.FormatWidget.addWidget(self.OLP1Page)
         self.selectPageLayout.addWidget(self.FormatWidget)
         BibleImportWizard.addPage(self.SelectPage)
+        # License page
         self.LicenseDetailsPage = QtGui.QWizardPage()
         self.LicenseDetailsPage.setObjectName(u'LicenseDetailsPage')
         self.LicenseDetailsLayout = QtGui.QFormLayout(self.LicenseDetailsPage)
@@ -284,6 +314,7 @@
         self.LicenseDetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
             self.PermissionsEdit)
         BibleImportWizard.addPage(self.LicenseDetailsPage)
+        # Progress page
         self.ImportPage = QtGui.QWizardPage()
         self.ImportPage.setObjectName(u'ImportPage')
         self.ImportLayout = QtGui.QVBoxLayout(self.ImportPage)
@@ -313,17 +344,17 @@
         self.TitleLabel.setText(
             u'<span style="font-size:14pt; font-weight:600;">%s</span>' % \
             translate('BiblesPlugin.ImportWizardForm',
-                'Welcome to the Bible Import Wizard'))
+            'Welcome to the Bible Import Wizard'))
         self.InformationLabel.setText(
             translate('BiblesPlugin.ImportWizardForm',
-                'This wizard will help you to import Bibles from a '
-                'variety of formats. Click the next button below to start the '
-                'process by selecting a format to import from.'))
+            'This wizard will help you to import Bibles from a '
+            'variety of formats. Click the next button below to start the '
+            'process by selecting a format to import from.'))
         self.SelectPage.setTitle(translate('BiblesPlugin.ImportWizardForm',
             'Select Import Source'))
         self.SelectPage.setSubTitle(
             translate('BiblesPlugin.ImportWizardForm',
-                'Select the import format, and where to import from.'))
+            'Select the import format, and where to import from.'))
         self.FormatLabel.setText(
             translate('BiblesPlugin.ImportWizardForm', 'Format:'))
         self.FormatComboBox.setItemText(0,
@@ -334,6 +365,10 @@
             translate('BiblesPlugin.ImportWizardForm', 'OpenSong'))
         self.FormatComboBox.setItemText(3,
             translate('BiblesPlugin.ImportWizardForm', 'Web Download'))
+        self.FormatComboBox.setItemText(4,
+            translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x'))
+        self.OLP1LocationLabel.setText(
+            translate('BiblesPlugin.ImportWizardForm', 'File location:'))
         self.OsisLocationLabel.setText(
             translate('BiblesPlugin.ImportWizardForm', 'File location:'))
         self.BooksLocationLabel.setText(
@@ -362,12 +397,12 @@
         self.WebDownloadTabWidget.setTabText(
             self.WebDownloadTabWidget.indexOf(self.ProxyServerTab),
             translate('BiblesPlugin.ImportWizardForm',
-                'Proxy Server (Optional)'))
+            'Proxy Server (Optional)'))
         self.LicenseDetailsPage.setTitle(
             translate('BiblesPlugin.ImportWizardForm', 'License Details'))
         self.LicenseDetailsPage.setSubTitle(
             translate('BiblesPlugin.ImportWizardForm',
-                'Set up the Bible\'s license details.'))
+            'Set up the Bible\'s license details.'))
         self.VersionNameLabel.setText(
             translate('BiblesPlugin.ImportWizardForm', 'Version name:'))
         self.CopyrightLabel.setText(
@@ -378,7 +413,7 @@
             translate('BiblesPlugin.ImportWizardForm', 'Importing'))
         self.ImportPage.setSubTitle(
             translate('BiblesPlugin.ImportWizardForm',
-                'Please wait while your Bible is imported.'))
+            'Please wait while your Bible is imported.'))
         self.ImportProgressLabel.setText(
             translate('BiblesPlugin.ImportWizardForm', 'Ready.'))
         self.ImportProgressBar.setFormat(u'%p%')

=== modified file 'openlp/plugins/bibles/lib/csvbible.py'
--- openlp/plugins/bibles/lib/csvbible.py	2010-09-14 18:18:47 +0000
+++ openlp/plugins/bibles/lib/csvbible.py	2010-12-07 16:43:16 +0000
@@ -30,7 +30,7 @@
 
 from PyQt4 import QtCore
 
-from openlp.core.lib import Receiver
+from openlp.core.lib import Receiver, translate
 from db import BibleDB
 
 log = logging.getLogger(__name__)
@@ -46,28 +46,25 @@
         This class assumes the files contain all the information and
         a clean bible is being loaded.
         """
+        log.info(self.__class__.__name__)
         BibleDB.__init__(self, parent, **kwargs)
-        log.info(self.__class__.__name__)
-        if u'booksfile' not in kwargs:
-            raise KeyError(u'You have to supply a file to import books from.')
         self.booksfile = kwargs[u'booksfile']
-        if u'versefile' not in kwargs:
-            raise KeyError(u'You have to supply a file to import verses from.')
         self.versesfile = kwargs[u'versefile']
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'bibles_stop_import'), self.stop_import)
 
     def do_import(self):
-        #Populate the Tables
         success = True
         books_file = None
+        book_ptr = None
+        verse_file = None
+        # Populate the Tables
         try:
             books_file = open(self.booksfile, 'r')
             dialect = csv.Sniffer().sniff(books_file.read(1024))
             books_file.seek(0)
             books_reader = csv.reader(books_file, dialect)
             for line in books_reader:
-                # cancel pressed
                 if self.stop_import_flag:
                     break
                 details = chardet.detect(line[1])
@@ -82,25 +79,24 @@
                 books_file.close()
         if not success:
             return False
-        verse_file = None
         try:
-            book_ptr = None
             verse_file = open(self.versesfile, 'r')
             dialect = csv.Sniffer().sniff(verse_file.read(1024))
             verse_file.seek(0)
             verse_reader = csv.reader(verse_file, dialect)
             for line in verse_reader:
-                if self.stop_import_flag:  # cancel pressed
+                if self.stop_import_flag:
                     break
                 details = chardet.detect(line[3])
                 if book_ptr != line[0]:
                     book = self.get_book(line[0])
                     book_ptr = book.name
-                    self.wizard.incrementProgressBar(
-                        u'Importing %s %s' % (book.name, line[1]))
+                    self.wizard.incrementProgressBar(u'%s %s %s...' % (
+                        translate('BiblesPlugin.CSVImport', 'Importing'),
+                        book.name, line[1]))
                     self.session.commit()
                 self.create_verse(book.id, line[1], line[2],
-                                  unicode(line[3], details['encoding']))
+                    unicode(line[3], details['encoding']))
                 Receiver.send_message(u'openlp_process_events')
             self.session.commit()
         except IOError:
@@ -110,7 +106,6 @@
             if verse_file:
                 verse_file.close()
         if self.stop_import_flag:
-            self.wizard.incrementProgressBar(u'Import canceled!')
             return False
         else:
             return success

=== modified file 'openlp/plugins/bibles/lib/db.py'
--- openlp/plugins/bibles/lib/db.py	2010-11-13 20:13:24 +0000
+++ openlp/plugins/bibles/lib/db.py	2010-12-07 16:43:16 +0000
@@ -231,7 +231,7 @@
 
     def create_chapter(self, book_id, chapter, textlist):
         """
-        Add a chapter and it's verses to a book.
+        Add a chapter and its verses to a book.
 
         ``book_id``
             The id of the book being appended.

=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py	2010-12-02 14:00:32 +0000
+++ openlp/plugins/bibles/lib/http.py	2010-12-07 16:43:16 +0000
@@ -333,24 +333,17 @@
         Init confirms the bible exists and stores the database path.
         """
         BibleDB.__init__(self, parent, **kwargs)
-        if u'download_source' not in kwargs:
-            raise KeyError(u'Missing keyword argument "download_source"')
-        if u'download_name' not in kwargs:
-            raise KeyError(u'Missing keyword argument "download_name"')
         self.download_source = kwargs[u'download_source']
         self.download_name = kwargs[u'download_name']
+        self.proxy_server = None
+        self.proxy_username = None
+        self.proxy_password = None
         if u'proxy_server' in kwargs:
             self.proxy_server = kwargs[u'proxy_server']
-        else:
-            self.proxy_server = None
         if u'proxy_username' in kwargs:
             self.proxy_username = kwargs[u'proxy_username']
-        else:
-            self.proxy_username = None
         if u'proxy_password' in kwargs:
             self.proxy_password = kwargs[u'proxy_password']
-        else:
-            self.proxy_password = None
 
     def do_import(self):
         """

=== modified file 'openlp/plugins/bibles/lib/manager.py'
--- openlp/plugins/bibles/lib/manager.py	2010-11-15 17:47:33 +0000
+++ openlp/plugins/bibles/lib/manager.py	2010-12-07 16:43:16 +0000
@@ -33,10 +33,11 @@
 from openlp.plugins.bibles.lib import parse_reference
 from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
 
+from csvbible import CSVBible
+from http import HTTPBible
+from olp1 import OpenLP1Bible
 from opensong import OpenSongBible
 from osis import OSISBible
-from csvbible import CSVBible
-from http import HTTPBible
 
 log = logging.getLogger(__name__)
 
@@ -61,6 +62,7 @@
     CSV = 1
     OpenSong = 2
     WebDownload = 3
+    OLP1 = 4
 
     @staticmethod
     def get_class(format):
@@ -78,6 +80,8 @@
             return OpenSongBible
         elif format == BibleFormat.WebDownload:
             return HTTPBible
+        elif format == BibleFormat.OLP1:
+            return OpenLP1Bible
         else:
             return None
 
@@ -90,7 +94,8 @@
             BibleFormat.OSIS,
             BibleFormat.CSV,
             BibleFormat.OpenSong,
-            BibleFormat.WebDownload
+            BibleFormat.WebDownload,
+            BibleFormat.OLP1
         ]
 
 

=== added file 'openlp/plugins/bibles/lib/olp1.py'
--- openlp/plugins/bibles/lib/olp1.py	1970-01-01 00:00:00 +0000
+++ openlp/plugins/bibles/lib/olp1.py	2010-12-07 16:43:16 +0000
@@ -0,0 +1,90 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection                                      #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2010 Raoul Snyman                                        #
+# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael      #
+# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian      #
+# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble,    #
+# Carsten Tinggaard, Frode Woldsund                                           #
+# --------------------------------------------------------------------------- #
+# 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
+
+from PyQt4 import QtCore
+
+from openlp.core.lib import Receiver, translate
+from db import BibleDB
+
+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']
+        self.name = kwargs[u'name']
+        QtCore.QObject.connect(Receiver.get_receiver(),
+            QtCore.SIGNAL(u'bibles_stop_import'), self.stop_import)
+
+    def do_import(self):
+        """
+        Imports an openlp.org v1 bible.
+        """
+        connection = None
+        cursor = None
+        try:
+            connection = sqlite.connect(self.filename)
+            cursor = connection.cursor()
+        except:
+            return False
+        # Create all books.
+        cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
+        books = cursor.fetchall()
+        for book in books:
+            if self.stop_import_flag:
+                return False
+            book_id = int(book[0])
+            testament_id = int(book[1])
+            name = unicode(book[2], u'cp1252')
+            abbreviation = unicode(book[3], u'cp1252')
+            self.create_book(name, abbreviation, testament_id)
+            # Update the progess bar.
+            self.wizard.incrementProgressBar(u'%s %s...' % (translate(
+                'BiblesPlugin.OpenLP1Import', 'Importing'), 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:
+                    return False
+                chapter = int(verse[0])
+                verse_number = int(verse[1])
+                text = unicode(verse[2], u'cp1252')
+                self.create_verse(book_id, chapter, verse_number, text)
+                Receiver.send_message(u'openlp_process_events')
+            self.session.commit()
+        return True

=== modified file 'openlp/plugins/bibles/lib/opensong.py'
--- openlp/plugins/bibles/lib/opensong.py	2010-09-14 18:18:47 +0000
+++ openlp/plugins/bibles/lib/opensong.py	2010-12-07 16:43:16 +0000
@@ -44,10 +44,8 @@
         Constructor to create and set up an instance of the OpenSongBible
         class. This class is used to import Bibles from OpenSong's XML format.
         """
-        log.debug(__name__)
+        log.debug(self.__class__.__name__)
         BibleDB.__init__(self, parent, **kwargs)
-        if 'filename' not in kwargs:
-            raise KeyError(u'You have to supply a file name to import from.')
         self.filename = kwargs['filename']
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'bibles_stop_import'), self.stop_import)
@@ -59,7 +57,6 @@
         log.debug(u'Starting OpenSong import from "%s"' % self.filename)
         if not isinstance(self.filename, unicode):
             self.filename = unicode(self.filename, u'utf8')
-        self.wizard.incrementProgressBar(u'Preparing for import...')
         file = None
         success = True
         try:
@@ -87,10 +84,9 @@
                             unicode(verse.text)
                         )
                         Receiver.send_message(u'openlp_process_events')
-                    self.wizard.incrementProgressBar(
-                        QtCore.QString('%s %s %s' % (
-                            translate('BiblesPlugin.Opensong', 'Importing'),
-                            db_book.name, chapter.attrib[u'n'])))
+                    self.wizard.incrementProgressBar(u'%s %s %s...' % (
+                        translate('BiblesPlugin.Opensong', 'Importing'),
+                        db_book.name, chapter.attrib[u'n']))
                     self.session.commit()
         except IOError:
             log.exception(u'Loading bible from OpenSong file failed')
@@ -99,7 +95,6 @@
             if file:
                 file.close()
         if self.stop_import_flag:
-            self.wizard.incrementProgressBar(u'Import canceled!')
             return False
         else:
             return success

=== modified file 'openlp/plugins/bibles/lib/osis.py'
--- openlp/plugins/bibles/lib/osis.py	2010-09-14 18:18:47 +0000
+++ openlp/plugins/bibles/lib/osis.py	2010-12-07 16:43:16 +0000
@@ -33,7 +33,7 @@
 
 from PyQt4 import QtCore
 
-from openlp.core.lib import Receiver
+from openlp.core.lib import Receiver, translate
 from openlp.core.utils import AppLocation
 from db import BibleDB
 
@@ -50,11 +50,11 @@
         Constructor to create and set up an instance of the OpenSongBible
         class. This class is used to import Bibles from OpenSong's XML format.
         """
-        log.debug(__name__)
+        log.debug(self.__class__.__name__)
         BibleDB.__init__(self, parent, **kwargs)
-        if u'filename' not in kwargs:
-            raise KeyError(u'You have to supply a file name to import from.')
         self.filename = kwargs[u'filename']
+        fbibles = None
+        self.books = {}
         self.verse_regex = re.compile(
             r'<verse osisID="([a-zA-Z0-9 ]*).([0-9]*).([0-9]*)">(.*?)</verse>')
         self.note_regex = re.compile(r'<note(.*?)>(.*?)</note>')
@@ -72,11 +72,9 @@
         self.divineName_regex = re.compile(
             r'<divineName(.*?)>(.*?)</divineName>')
         self.spaces_regex = re.compile(r'([ ]{2,})')
-        self.books = {}
         filepath = os.path.join(
             AppLocation.get_directory(AppLocation.PluginsDir), u'bibles',
             u'resources', u'osisbooks.csv')
-        fbibles = None
         try:
             fbibles = open(filepath, u'r')
             for line in fbibles:
@@ -96,9 +94,15 @@
         Loads a Bible from file.
         """
         log.debug(u'Starting OSIS import from "%s"' % self.filename)
-        self.wizard.incrementProgressBar(
-            u'Detecting encoding (this may take a few minutes)...')
         detect_file = None
+        db_book = None
+        osis = None
+        success = True
+        last_chapter = 0
+        testament = 1
+        match_count = 0
+        self.wizard.incrementProgressBar(translate('BiblesPlugin.OsisImport',
+            'Detecting encoding (this may take a few minutes)...'))
         try:
             detect_file = open(self.filename, u'r')
             details = chardet.detect(detect_file.read(1048576))
@@ -108,14 +112,8 @@
         finally:
             if detect_file:
                 detect_file.close()
-        osis = None
-        success = True
         try:
             osis = codecs.open(self.filename, u'r', details['encoding'])
-            last_chapter = 0
-            testament = 1
-            match_count = 0
-            db_book = None
             for file_record in osis:
                 if self.stop_import_flag:
                     break
@@ -142,9 +140,9 @@
                     if last_chapter != chapter:
                         if last_chapter != 0:
                             self.session.commit()
-                        self.wizard.incrementProgressBar(
-                            u'Importing %s %s...' % \
-                            (self.books[match.group(1)][0], chapter))
+                        self.wizard.incrementProgressBar(u'%s %s %s...' % (
+                            translate('BiblesPlugin.OsisImport', 'Importing'),
+                            self.books[match.group(1)][0], chapter))
                         last_chapter = chapter
                     # All of this rigmarol below is because the mod2osis
                     # tool from the Sword library embeds XML in the OSIS
@@ -171,7 +169,6 @@
                     self.create_verse(db_book.id, chapter, verse, verse_text)
                     Receiver.send_message(u'openlp_process_events')
             self.session.commit()
-            self.wizard.incrementProgressBar(u'Finishing import...')
             if match_count == 0:
                 success = False
         except (ValueError, IOError):
@@ -181,7 +178,6 @@
             if osis:
                 osis.close()
         if self.stop_import_flag:
-            self.wizard.incrementProgressBar(u'Import canceled!')
             return False
         else:
             return success


Follow ups