forked from openlp/openlp
completed work
This commit is contained in:
commit
a66a77bdec
|
@ -99,6 +99,9 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||||
QtCore.QObject.connect(self.OpenSongBrowseButton,
|
QtCore.QObject.connect(self.OpenSongBrowseButton,
|
||||||
QtCore.SIGNAL(u'clicked()'),
|
QtCore.SIGNAL(u'clicked()'),
|
||||||
self.onOpenSongBrowseButtonClicked)
|
self.onOpenSongBrowseButtonClicked)
|
||||||
|
QtCore.QObject.connect(self.OLP1FileButton,
|
||||||
|
QtCore.SIGNAL(u'clicked()'),
|
||||||
|
self.onOLP1FileButtonClicked)
|
||||||
QtCore.QObject.connect(self.cancelButton,
|
QtCore.QObject.connect(self.cancelButton,
|
||||||
QtCore.SIGNAL(u'clicked(bool)'),
|
QtCore.SIGNAL(u'clicked(bool)'),
|
||||||
self.onCancelButtonClicked)
|
self.onCancelButtonClicked)
|
||||||
|
@ -123,7 +126,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||||
elif self.currentId() == 1:
|
elif self.currentId() == 1:
|
||||||
# Select page
|
# Select page
|
||||||
if self.field(u'source_format').toInt()[0] == BibleFormat.OSIS:
|
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,
|
QtGui.QMessageBox.critical(self,
|
||||||
translate('BiblesPlugin.ImportWizardForm',
|
translate('BiblesPlugin.ImportWizardForm',
|
||||||
'Invalid Bible Location'),
|
'Invalid Bible Location'),
|
||||||
|
@ -162,9 +165,21 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||||
'file to import.'))
|
'file to import.'))
|
||||||
self.OpenSongFileEdit.setFocus()
|
self.OpenSongFileEdit.setFocus()
|
||||||
return False
|
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
|
return True
|
||||||
elif self.currentId() == 2:
|
elif self.currentId() == 2:
|
||||||
# License details
|
# License details
|
||||||
|
if self.field(u'source_format').toInt()[0] == BibleFormat.OLP1:
|
||||||
|
return True
|
||||||
license_version = unicode(self.field(u'license_version').toString())
|
license_version = unicode(self.field(u'license_version').toString())
|
||||||
license_copyright = \
|
license_copyright = \
|
||||||
unicode(self.field(u'license_copyright').toString())
|
unicode(self.field(u'license_copyright').toString())
|
||||||
|
@ -244,6 +259,14 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||||
translate('BiblesPlugin.ImportWizardForm', 'Open OpenSong Bible'),
|
translate('BiblesPlugin.ImportWizardForm', 'Open OpenSong Bible'),
|
||||||
self.OpenSongFileEdit)
|
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):
|
def onCancelButtonClicked(self, checked):
|
||||||
"""
|
"""
|
||||||
Stop the import on pressing the cancel button.
|
Stop the import on pressing the cancel button.
|
||||||
|
@ -279,6 +302,8 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||||
u'proxy_username', self.UsernameEdit)
|
u'proxy_username', self.UsernameEdit)
|
||||||
self.SelectPage.registerField(
|
self.SelectPage.registerField(
|
||||||
u'proxy_password', self.PasswordEdit)
|
u'proxy_password', self.PasswordEdit)
|
||||||
|
self.SelectPage.registerField(
|
||||||
|
u'OLP1_location', self.OLP1LocationEdit)
|
||||||
self.LicenseDetailsPage.registerField(
|
self.LicenseDetailsPage.registerField(
|
||||||
u'license_version', self.VersionNameEdit)
|
u'license_version', self.VersionNameEdit)
|
||||||
self.LicenseDetailsPage.registerField(
|
self.LicenseDetailsPage.registerField(
|
||||||
|
@ -306,6 +331,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||||
settings.value(u'proxy username', QtCore.QVariant(u'')))
|
settings.value(u'proxy username', QtCore.QVariant(u'')))
|
||||||
self.setField(u'proxy_password',
|
self.setField(u'proxy_password',
|
||||||
settings.value(u'proxy password', QtCore.QVariant(u'')))
|
settings.value(u'proxy password', QtCore.QVariant(u'')))
|
||||||
|
self.setField(u'OLP1_location', QtCore.QVariant(''))
|
||||||
self.setField(u'license_version',
|
self.setField(u'license_version',
|
||||||
QtCore.QVariant(self.VersionNameEdit.text()))
|
QtCore.QVariant(self.VersionNameEdit.text()))
|
||||||
self.setField(u'license_copyright',
|
self.setField(u'license_copyright',
|
||||||
|
@ -442,6 +468,12 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||||
unicode(self.field(u'proxy_username').toString()),
|
unicode(self.field(u'proxy_username').toString()),
|
||||||
proxy_password=unicode(self.field(u'proxy_password').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():
|
if importer.do_import():
|
||||||
self.manager.save_meta_data(license_version, license_version,
|
self.manager.save_meta_data(license_version, license_version,
|
||||||
license_copyright, license_permissions)
|
license_copyright, license_permissions)
|
||||||
|
|
|
@ -38,6 +38,7 @@ class Ui_BibleImportWizard(object):
|
||||||
QtGui.QWizard.IndependentPages |
|
QtGui.QWizard.IndependentPages |
|
||||||
QtGui.QWizard.NoBackButtonOnStartPage |
|
QtGui.QWizard.NoBackButtonOnStartPage |
|
||||||
QtGui.QWizard.NoBackButtonOnLastPage)
|
QtGui.QWizard.NoBackButtonOnLastPage)
|
||||||
|
# Welcome page
|
||||||
self.WelcomePage = QtGui.QWizardPage()
|
self.WelcomePage = QtGui.QWizardPage()
|
||||||
self.WelcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap,
|
self.WelcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap,
|
||||||
QtGui.QPixmap(u':/wizards/wizard_importbible.bmp'))
|
QtGui.QPixmap(u':/wizards/wizard_importbible.bmp'))
|
||||||
|
@ -61,6 +62,7 @@ class Ui_BibleImportWizard(object):
|
||||||
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||||
self.WelcomeLayout.addItem(spacerItem1)
|
self.WelcomeLayout.addItem(spacerItem1)
|
||||||
BibleImportWizard.addPage(self.WelcomePage)
|
BibleImportWizard.addPage(self.WelcomePage)
|
||||||
|
# Select page
|
||||||
self.SelectPage = QtGui.QWizardPage()
|
self.SelectPage = QtGui.QWizardPage()
|
||||||
self.SelectPage.setObjectName(u'SelectPage')
|
self.SelectPage.setObjectName(u'SelectPage')
|
||||||
self.selectPageLayout = QtGui.QVBoxLayout(self.SelectPage)
|
self.selectPageLayout = QtGui.QVBoxLayout(self.SelectPage)
|
||||||
|
@ -79,6 +81,7 @@ class Ui_BibleImportWizard(object):
|
||||||
self.FormatComboBox.addItem(u'')
|
self.FormatComboBox.addItem(u'')
|
||||||
self.FormatComboBox.addItem(u'')
|
self.FormatComboBox.addItem(u'')
|
||||||
self.FormatComboBox.addItem(u'')
|
self.FormatComboBox.addItem(u'')
|
||||||
|
self.FormatComboBox.addItem(u'')
|
||||||
self.FormatSelectLayout.addWidget(self.FormatComboBox)
|
self.FormatSelectLayout.addWidget(self.FormatComboBox)
|
||||||
spacerItem2 = QtGui.QSpacerItem(40, 20,
|
spacerItem2 = QtGui.QSpacerItem(40, 20,
|
||||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||||
|
@ -86,6 +89,7 @@ class Ui_BibleImportWizard(object):
|
||||||
self.selectPageLayout.addLayout(self.FormatSelectLayout)
|
self.selectPageLayout.addLayout(self.FormatSelectLayout)
|
||||||
self.FormatWidget = QtGui.QStackedWidget(self.SelectPage)
|
self.FormatWidget = QtGui.QStackedWidget(self.SelectPage)
|
||||||
self.FormatWidget.setObjectName(u'FormatWidget')
|
self.FormatWidget.setObjectName(u'FormatWidget')
|
||||||
|
generalIcon = build_icon(u':/general/general_open.png')
|
||||||
self.OsisPage = QtGui.QWidget()
|
self.OsisPage = QtGui.QWidget()
|
||||||
self.OsisPage.setObjectName(u'OsisPage')
|
self.OsisPage.setObjectName(u'OsisPage')
|
||||||
self.OsisLayout = QtGui.QFormLayout(self.OsisPage)
|
self.OsisLayout = QtGui.QFormLayout(self.OsisPage)
|
||||||
|
@ -106,7 +110,6 @@ class Ui_BibleImportWizard(object):
|
||||||
self.OsisLocationLayout.addWidget(self.OSISLocationEdit)
|
self.OsisLocationLayout.addWidget(self.OSISLocationEdit)
|
||||||
self.OsisFileButton = QtGui.QToolButton(self.OsisPage)
|
self.OsisFileButton = QtGui.QToolButton(self.OsisPage)
|
||||||
self.OsisFileButton.setMaximumSize(QtCore.QSize(32, 16777215))
|
self.OsisFileButton.setMaximumSize(QtCore.QSize(32, 16777215))
|
||||||
generalIcon = build_icon(u':/general/general_open.png')
|
|
||||||
self.OsisFileButton.setIcon(generalIcon)
|
self.OsisFileButton.setIcon(generalIcon)
|
||||||
self.OsisFileButton.setObjectName(u'OsisFileButton')
|
self.OsisFileButton.setObjectName(u'OsisFileButton')
|
||||||
self.OsisLocationLayout.addWidget(self.OsisFileButton)
|
self.OsisLocationLayout.addWidget(self.OsisFileButton)
|
||||||
|
@ -251,8 +254,35 @@ class Ui_BibleImportWizard(object):
|
||||||
self.WebDownloadTabWidget.addTab(self.ProxyServerTab, u'')
|
self.WebDownloadTabWidget.addTab(self.ProxyServerTab, u'')
|
||||||
self.WebDownloadLayout.addWidget(self.WebDownloadTabWidget)
|
self.WebDownloadLayout.addWidget(self.WebDownloadTabWidget)
|
||||||
self.FormatWidget.addWidget(self.WebDownloadPage)
|
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)
|
self.selectPageLayout.addWidget(self.FormatWidget)
|
||||||
BibleImportWizard.addPage(self.SelectPage)
|
BibleImportWizard.addPage(self.SelectPage)
|
||||||
|
# License page
|
||||||
self.LicenseDetailsPage = QtGui.QWizardPage()
|
self.LicenseDetailsPage = QtGui.QWizardPage()
|
||||||
self.LicenseDetailsPage.setObjectName(u'LicenseDetailsPage')
|
self.LicenseDetailsPage.setObjectName(u'LicenseDetailsPage')
|
||||||
self.LicenseDetailsLayout = QtGui.QFormLayout(self.LicenseDetailsPage)
|
self.LicenseDetailsLayout = QtGui.QFormLayout(self.LicenseDetailsPage)
|
||||||
|
@ -284,6 +314,7 @@ class Ui_BibleImportWizard(object):
|
||||||
self.LicenseDetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
|
self.LicenseDetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
|
||||||
self.PermissionsEdit)
|
self.PermissionsEdit)
|
||||||
BibleImportWizard.addPage(self.LicenseDetailsPage)
|
BibleImportWizard.addPage(self.LicenseDetailsPage)
|
||||||
|
# Progress page
|
||||||
self.ImportPage = QtGui.QWizardPage()
|
self.ImportPage = QtGui.QWizardPage()
|
||||||
self.ImportPage.setObjectName(u'ImportPage')
|
self.ImportPage.setObjectName(u'ImportPage')
|
||||||
self.ImportLayout = QtGui.QVBoxLayout(self.ImportPage)
|
self.ImportLayout = QtGui.QVBoxLayout(self.ImportPage)
|
||||||
|
@ -311,7 +342,7 @@ class Ui_BibleImportWizard(object):
|
||||||
BibleImportWizard.setWindowTitle(
|
BibleImportWizard.setWindowTitle(
|
||||||
translate('BiblesPlugin.ImportWizardForm', 'Bible Import Wizard'))
|
translate('BiblesPlugin.ImportWizardForm', 'Bible Import Wizard'))
|
||||||
self.TitleLabel.setText(
|
self.TitleLabel.setText(
|
||||||
u'<span style="font-size:14pt; font-weight:600;">%s</span>' % \
|
u'<span style="font-size:14pt; font-weight:600;">%s</span>' %
|
||||||
translate('BiblesPlugin.ImportWizardForm',
|
translate('BiblesPlugin.ImportWizardForm',
|
||||||
'Welcome to the Bible Import Wizard'))
|
'Welcome to the Bible Import Wizard'))
|
||||||
self.InformationLabel.setText(
|
self.InformationLabel.setText(
|
||||||
|
@ -334,6 +365,10 @@ class Ui_BibleImportWizard(object):
|
||||||
translate('BiblesPlugin.ImportWizardForm', 'OpenSong'))
|
translate('BiblesPlugin.ImportWizardForm', 'OpenSong'))
|
||||||
self.FormatComboBox.setItemText(3,
|
self.FormatComboBox.setItemText(3,
|
||||||
translate('BiblesPlugin.ImportWizardForm', 'Web Download'))
|
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(
|
self.OsisLocationLabel.setText(
|
||||||
translate('BiblesPlugin.ImportWizardForm', 'File location:'))
|
translate('BiblesPlugin.ImportWizardForm', 'File location:'))
|
||||||
self.BooksLocationLabel.setText(
|
self.BooksLocationLabel.setText(
|
||||||
|
|
|
@ -231,7 +231,7 @@ class BibleDB(QtCore.QObject, Manager):
|
||||||
|
|
||||||
def create_chapter(self, book_id, chapter, textlist):
|
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``
|
``book_id``
|
||||||
The id of the book being appended.
|
The id of the book being appended.
|
||||||
|
|
|
@ -33,9 +33,10 @@ from openlp.core.utils import AppLocation
|
||||||
from openlp.plugins.bibles.lib import parse_reference
|
from openlp.plugins.bibles.lib import parse_reference
|
||||||
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
|
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
|
||||||
|
|
||||||
|
from csvbible import CSVBible
|
||||||
|
from olp1 import OpenLP1Bible
|
||||||
from opensong import OpenSongBible
|
from opensong import OpenSongBible
|
||||||
from osis import OSISBible
|
from osis import OSISBible
|
||||||
from csvbible import CSVBible
|
|
||||||
from http import HTTPBible
|
from http import HTTPBible
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -61,6 +62,7 @@ class BibleFormat(object):
|
||||||
CSV = 1
|
CSV = 1
|
||||||
OpenSong = 2
|
OpenSong = 2
|
||||||
WebDownload = 3
|
WebDownload = 3
|
||||||
|
OLP1 = 4
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_class(format):
|
def get_class(format):
|
||||||
|
@ -78,6 +80,8 @@ class BibleFormat(object):
|
||||||
return OpenSongBible
|
return OpenSongBible
|
||||||
elif format == BibleFormat.WebDownload:
|
elif format == BibleFormat.WebDownload:
|
||||||
return HTTPBible
|
return HTTPBible
|
||||||
|
elif format == BibleFormat.OLP1:
|
||||||
|
return OpenLP1Bible
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -90,7 +94,8 @@ class BibleFormat(object):
|
||||||
BibleFormat.OSIS,
|
BibleFormat.OSIS,
|
||||||
BibleFormat.CSV,
|
BibleFormat.CSV,
|
||||||
BibleFormat.OpenSong,
|
BibleFormat.OpenSong,
|
||||||
BibleFormat.WebDownload
|
BibleFormat.WebDownload,
|
||||||
|
BibleFormat.OLP1
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
# -*- 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 openlp.core.lib import Receiver, translate
|
||||||
|
from openlp.core.lib import 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(__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)
|
||||||
|
|
||||||
|
def do_import(self):
|
||||||
|
"""
|
||||||
|
Imports an openlp.org v1 bible.
|
||||||
|
"""
|
||||||
|
# TODO: stop_import_flag
|
||||||
|
# TODO: update progress bar
|
||||||
|
connection = None
|
||||||
|
cursor = None
|
||||||
|
self.wizard.incrementProgressBar(u'Preparing for import...')
|
||||||
|
try:
|
||||||
|
connection = sqlite.connect(self.filename)
|
||||||
|
cursor = connection.cursor()
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
# Import books.
|
||||||
|
cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
|
||||||
|
books = cursor.fetchall()
|
||||||
|
for book in books:
|
||||||
|
testament_id = int(book[1])
|
||||||
|
name = unicode(book[2], u'cp1252')
|
||||||
|
abbreviation = unicode(book[3], u'cp1252')
|
||||||
|
self.create_book(name, abbreviation, testament_id)
|
||||||
|
self.session.commit()
|
||||||
|
# Import chapters/verses.
|
||||||
|
cursor.execute(u'SELECT id, book_id, chapter, verse, text || \'\' AS '
|
||||||
|
'text FROM verse')
|
||||||
|
verses = cursor.fetchall()
|
||||||
|
for verse in verses:
|
||||||
|
book_id = int(verse[1])
|
||||||
|
chapter = int(verse[2])
|
||||||
|
verse_number = int(verse[3])
|
||||||
|
text = unicode(verse[4], u'cp1252')
|
||||||
|
self.create_verse(book_id, chapter, verse_number, text)
|
||||||
|
self.session.commit()
|
||||||
|
return True
|
||||||
|
|
Loading…
Reference in New Issue