forked from openlp/openlp
Moved openlp database upgrade script to scripts directory.
Removed old bible import form. Removed some debugging in the OSIS and bible db classes.
This commit is contained in:
parent
3e425803e3
commit
4500b02824
@ -1,259 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2009 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2009 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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 #
|
||||
###############################################################################
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import build_icon
|
||||
|
||||
class Ui_BibleImportDialog(object):
|
||||
def setupUi(self, BibleImportDialog):
|
||||
BibleImportDialog.setObjectName(u'BibleImportDialog')
|
||||
BibleImportDialog.resize(500, 686)
|
||||
icon = build_icon(u':/icon/openlp.org-icon-32.bmp')
|
||||
BibleImportDialog.setWindowIcon(icon)
|
||||
self.LicenceDetailsGroupBox = QtGui.QGroupBox(BibleImportDialog)
|
||||
self.LicenceDetailsGroupBox.setGeometry(QtCore.QRect(10, 400, 480, 151))
|
||||
self.LicenceDetailsGroupBox.setMinimumSize(QtCore.QSize(0, 123))
|
||||
self.LicenceDetailsGroupBox.setObjectName(u'LicenceDetailsGroupBox')
|
||||
self.formLayout = QtGui.QFormLayout(self.LicenceDetailsGroupBox)
|
||||
self.formLayout.setMargin(8)
|
||||
self.formLayout.setHorizontalSpacing(8)
|
||||
self.formLayout.setObjectName(u'formLayout')
|
||||
self.VersionNameLabel = QtGui.QLabel(self.LicenceDetailsGroupBox)
|
||||
self.VersionNameLabel.setObjectName(u'VersionNameLabel')
|
||||
self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.VersionNameLabel)
|
||||
self.VersionNameEdit = QtGui.QLineEdit(self.LicenceDetailsGroupBox)
|
||||
self.VersionNameEdit.setObjectName(u'VersionNameEdit')
|
||||
self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.VersionNameEdit)
|
||||
self.CopyrightLabel = QtGui.QLabel(self.LicenceDetailsGroupBox)
|
||||
self.CopyrightLabel.setObjectName(u'CopyrightLabel')
|
||||
self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.CopyrightLabel)
|
||||
self.CopyrightEdit = QtGui.QLineEdit(self.LicenceDetailsGroupBox)
|
||||
self.CopyrightEdit.setObjectName(u'CopyrightEdit')
|
||||
self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.CopyrightEdit)
|
||||
self.PermisionLabel = QtGui.QLabel(self.LicenceDetailsGroupBox)
|
||||
self.PermisionLabel.setObjectName(u'PermisionLabel')
|
||||
self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.PermisionLabel)
|
||||
self.PermisionEdit = QtGui.QLineEdit(self.LicenceDetailsGroupBox)
|
||||
self.PermisionEdit.setObjectName(u'PermisionEdit')
|
||||
self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.PermisionEdit)
|
||||
self.MessageLabel = QtGui.QLabel(BibleImportDialog)
|
||||
self.MessageLabel.setGeometry(QtCore.QRect(20, 670, 271, 17))
|
||||
self.MessageLabel.setObjectName(u'MessageLabel')
|
||||
self.ProgressGroupBox = QtGui.QGroupBox(BibleImportDialog)
|
||||
self.ProgressGroupBox.setGeometry(QtCore.QRect(10, 550, 480, 70))
|
||||
self.ProgressGroupBox.setObjectName(u'ProgressGroupBox')
|
||||
self.gridLayout_3 = QtGui.QGridLayout(self.ProgressGroupBox)
|
||||
self.gridLayout_3.setObjectName(u'gridLayout_3')
|
||||
self.ProgressBar = QtGui.QProgressBar(self.ProgressGroupBox)
|
||||
self.ProgressBar.setProperty(u'value', QtCore.QVariant(0))
|
||||
self.ProgressBar.setInvertedAppearance(False)
|
||||
self.ProgressBar.setObjectName(u'ProgressBar')
|
||||
self.gridLayout_3.addWidget(self.ProgressBar, 0, 0, 1, 1)
|
||||
self.layoutWidget = QtGui.QWidget(BibleImportDialog)
|
||||
self.layoutWidget.setGeometry(QtCore.QRect(310, 630, 180, 38))
|
||||
self.layoutWidget.setObjectName(u'layoutWidget')
|
||||
self.horizontalLayout = QtGui.QHBoxLayout(self.layoutWidget)
|
||||
self.horizontalLayout.setMargin(6)
|
||||
self.horizontalLayout.setObjectName(u'horizontalLayout')
|
||||
self.ImportButton = QtGui.QPushButton(self.layoutWidget)
|
||||
self.ImportButton.setObjectName(u'ImportButton')
|
||||
self.horizontalLayout.addWidget(self.ImportButton)
|
||||
self.CancelButton = QtGui.QPushButton(self.layoutWidget)
|
||||
self.CancelButton.setObjectName(u'CancelButton')
|
||||
self.horizontalLayout.addWidget(self.CancelButton)
|
||||
self.tabWidget = QtGui.QTabWidget(BibleImportDialog)
|
||||
self.tabWidget.setGeometry(QtCore.QRect(10, 30, 480, 361))
|
||||
self.tabWidget.setObjectName(u'tabWidget')
|
||||
self.OsisTab = QtGui.QWidget()
|
||||
self.OsisTab.setObjectName(u'OsisTab')
|
||||
self.OSISGroupBox = QtGui.QGroupBox(self.OsisTab)
|
||||
self.OSISGroupBox.setGeometry(QtCore.QRect(10, 10, 460, 141))
|
||||
self.OSISGroupBox.setObjectName(u'OSISGroupBox')
|
||||
self.gridLayout_2 = QtGui.QGridLayout(self.OSISGroupBox)
|
||||
self.gridLayout_2.setObjectName(u'gridLayout_2')
|
||||
self.horizontalLayout_2 = QtGui.QHBoxLayout()
|
||||
self.horizontalLayout_2.setObjectName(u'horizontalLayout_2')
|
||||
self.BibleNameLabel = QtGui.QLabel(self.OSISGroupBox)
|
||||
self.BibleNameLabel.setObjectName(u'BibleNameLabel')
|
||||
self.horizontalLayout_2.addWidget(self.BibleNameLabel)
|
||||
self.BibleNameEdit = QtGui.QLineEdit(self.OSISGroupBox)
|
||||
self.BibleNameEdit.setObjectName(u'BibleNameEdit')
|
||||
self.horizontalLayout_2.addWidget(self.BibleNameEdit)
|
||||
self.gridLayout_2.addLayout(self.horizontalLayout_2, 0, 0, 1, 1)
|
||||
self.horizontalLayout_3 = QtGui.QHBoxLayout()
|
||||
self.horizontalLayout_3.setObjectName(u'horizontalLayout_3')
|
||||
self.LocatioLabel = QtGui.QLabel(self.OSISGroupBox)
|
||||
self.LocatioLabel.setObjectName(u'LocatioLabel')
|
||||
self.horizontalLayout_3.addWidget(self.LocatioLabel)
|
||||
self.OSISLocationEdit = QtGui.QLineEdit(self.OSISGroupBox)
|
||||
self.OSISLocationEdit.setObjectName(u'OSISLocationEdit')
|
||||
self.horizontalLayout_3.addWidget(self.OSISLocationEdit)
|
||||
self.OsisFileButton = QtGui.QPushButton(self.OSISGroupBox)
|
||||
icon1 = build_icon(u':/imports/import_load.png')
|
||||
self.OsisFileButton.setIcon(icon1)
|
||||
self.OsisFileButton.setObjectName(u'OsisFileButton')
|
||||
self.horizontalLayout_3.addWidget(self.OsisFileButton)
|
||||
self.gridLayout_2.addLayout(self.horizontalLayout_3, 1, 0, 1, 1)
|
||||
self.tabWidget.addTab(self.OsisTab, u'')
|
||||
self.CsvTab = QtGui.QWidget()
|
||||
self.CsvTab.setObjectName(u'CsvTab')
|
||||
self.CVSGroupBox = QtGui.QGroupBox(self.CsvTab)
|
||||
self.CVSGroupBox.setGeometry(QtCore.QRect(10, 10, 460, 191))
|
||||
self.CVSGroupBox.setObjectName(u'CVSGroupBox')
|
||||
self.gridLayout = QtGui.QGridLayout(self.CVSGroupBox)
|
||||
self.gridLayout.setMargin(8)
|
||||
self.gridLayout.setSpacing(8)
|
||||
self.gridLayout.setObjectName(u'gridLayout')
|
||||
self.BooksLocationLabel = QtGui.QLabel(self.CVSGroupBox)
|
||||
self.BooksLocationLabel.setObjectName(u'BooksLocationLabel')
|
||||
self.gridLayout.addWidget(self.BooksLocationLabel, 0, 0, 1, 1)
|
||||
self.VerseLocationLabel = QtGui.QLabel(self.CVSGroupBox)
|
||||
self.VerseLocationLabel.setObjectName(u'VerseLocationLabel')
|
||||
self.gridLayout.addWidget(self.VerseLocationLabel, 4, 0, 1, 1)
|
||||
self.VerseLocationEdit = QtGui.QLineEdit(self.CVSGroupBox)
|
||||
self.VerseLocationEdit.setObjectName(u'VerseLocationEdit')
|
||||
self.gridLayout.addWidget(self.VerseLocationEdit, 4, 1, 1, 1)
|
||||
self.BooksLocationEdit = QtGui.QLineEdit(self.CVSGroupBox)
|
||||
self.BooksLocationEdit.setObjectName(u'BooksLocationEdit')
|
||||
self.gridLayout.addWidget(self.BooksLocationEdit, 0, 1, 1, 1)
|
||||
self.BooksFileButton = QtGui.QPushButton(self.CVSGroupBox)
|
||||
self.BooksFileButton.setIcon(icon1)
|
||||
self.BooksFileButton.setObjectName(u'BooksFileButton')
|
||||
self.gridLayout.addWidget(self.BooksFileButton, 0, 2, 1, 1)
|
||||
self.VersesFileButton = QtGui.QPushButton(self.CVSGroupBox)
|
||||
self.VersesFileButton.setIcon(icon1)
|
||||
self.VersesFileButton.setObjectName(u'VersesFileButton')
|
||||
self.gridLayout.addWidget(self.VersesFileButton, 4, 2, 1, 1)
|
||||
self.tabWidget.addTab(self.CsvTab, u'')
|
||||
self.HttpTab = QtGui.QWidget()
|
||||
self.HttpTab.setObjectName(u'HttpTab')
|
||||
self.OptionsGroupBox = QtGui.QGroupBox(self.HttpTab)
|
||||
self.OptionsGroupBox.setGeometry(QtCore.QRect(10, 10, 460, 141))
|
||||
self.OptionsGroupBox.setObjectName(u'OptionsGroupBox')
|
||||
self.verticalLayout = QtGui.QVBoxLayout(self.OptionsGroupBox)
|
||||
self.verticalLayout.setObjectName(u'verticalLayout')
|
||||
self.horizontalLayout_4 = QtGui.QHBoxLayout()
|
||||
self.horizontalLayout_4.setObjectName(u'horizontalLayout_4')
|
||||
self.LocationLabel = QtGui.QLabel(self.OptionsGroupBox)
|
||||
self.LocationLabel.setObjectName(u'LocationLabel')
|
||||
self.horizontalLayout_4.addWidget(self.LocationLabel)
|
||||
self.LocationComboBox = QtGui.QComboBox(self.OptionsGroupBox)
|
||||
self.LocationComboBox.setObjectName(u'LocationComboBox')
|
||||
self.LocationComboBox.addItem(QtCore.QString())
|
||||
self.LocationComboBox.addItem(QtCore.QString())
|
||||
self.horizontalLayout_4.addWidget(self.LocationComboBox)
|
||||
self.verticalLayout.addLayout(self.horizontalLayout_4)
|
||||
self.horizontalLayout_5 = QtGui.QHBoxLayout()
|
||||
self.horizontalLayout_5.setObjectName(u'horizontalLayout_5')
|
||||
self.BibleLabel = QtGui.QLabel(self.OptionsGroupBox)
|
||||
self.BibleLabel.setObjectName(u'BibleLabel')
|
||||
self.horizontalLayout_5.addWidget(self.BibleLabel)
|
||||
self.BibleComboBox = QtGui.QComboBox(self.OptionsGroupBox)
|
||||
self.BibleComboBox.setObjectName(u'BibleComboBox')
|
||||
self.BibleComboBox.addItem(QtCore.QString())
|
||||
self.BibleComboBox.setItemText(0, u'')
|
||||
self.BibleComboBox.setItemText(1, u'')
|
||||
self.BibleComboBox.addItem(QtCore.QString())
|
||||
self.BibleComboBox.addItem(QtCore.QString())
|
||||
self.horizontalLayout_5.addWidget(self.BibleComboBox)
|
||||
self.verticalLayout.addLayout(self.horizontalLayout_5)
|
||||
self.ProxyGroupBox = QtGui.QGroupBox(self.HttpTab)
|
||||
self.ProxyGroupBox.setGeometry(QtCore.QRect(10, 160, 460, 161))
|
||||
self.ProxyGroupBox.setObjectName(u'ProxyGroupBox')
|
||||
self.ProxySettingsLayout = QtGui.QFormLayout(self.ProxyGroupBox)
|
||||
self.ProxySettingsLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow)
|
||||
self.ProxySettingsLayout.setMargin(8)
|
||||
self.ProxySettingsLayout.setSpacing(8)
|
||||
self.ProxySettingsLayout.setObjectName(u'ProxySettingsLayout')
|
||||
self.AddressLabel = QtGui.QLabel(self.ProxyGroupBox)
|
||||
self.AddressLabel.setObjectName(u'AddressLabel')
|
||||
self.ProxySettingsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.AddressLabel)
|
||||
self.AddressEdit = QtGui.QLineEdit(self.ProxyGroupBox)
|
||||
self.AddressEdit.setObjectName(u'AddressEdit')
|
||||
self.ProxySettingsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.AddressEdit)
|
||||
self.UsernameLabel = QtGui.QLabel(self.ProxyGroupBox)
|
||||
self.UsernameLabel.setObjectName(u'UsernameLabel')
|
||||
self.ProxySettingsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.UsernameLabel)
|
||||
self.UsernameEdit = QtGui.QLineEdit(self.ProxyGroupBox)
|
||||
self.UsernameEdit.setObjectName(u'UsernameEdit')
|
||||
self.ProxySettingsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.UsernameEdit)
|
||||
self.PasswordLabel = QtGui.QLabel(self.ProxyGroupBox)
|
||||
self.PasswordLabel.setObjectName(u'PasswordLabel')
|
||||
self.ProxySettingsLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.PasswordLabel)
|
||||
self.PasswordEdit = QtGui.QLineEdit(self.ProxyGroupBox)
|
||||
self.PasswordEdit.setObjectName(u'PasswordEdit')
|
||||
self.ProxySettingsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.PasswordEdit)
|
||||
self.tabWidget.addTab(self.HttpTab, u'')
|
||||
|
||||
self.retranslateUi(BibleImportDialog)
|
||||
self.tabWidget.setCurrentIndex(2)
|
||||
QtCore.QMetaObject.connectSlotsByName(BibleImportDialog)
|
||||
BibleImportDialog.setTabOrder(self.BibleNameEdit, self.OSISLocationEdit)
|
||||
BibleImportDialog.setTabOrder(self.OSISLocationEdit, self.OsisFileButton)
|
||||
BibleImportDialog.setTabOrder(self.OsisFileButton, self.BooksLocationEdit)
|
||||
BibleImportDialog.setTabOrder(self.BooksLocationEdit, self.BooksFileButton)
|
||||
BibleImportDialog.setTabOrder(self.BooksFileButton, self.VerseLocationEdit)
|
||||
BibleImportDialog.setTabOrder(self.VerseLocationEdit, self.VersesFileButton)
|
||||
BibleImportDialog.setTabOrder(self.VersesFileButton, self.LocationComboBox)
|
||||
BibleImportDialog.setTabOrder(self.LocationComboBox, self.BibleComboBox)
|
||||
BibleImportDialog.setTabOrder(self.BibleComboBox, self.AddressEdit)
|
||||
BibleImportDialog.setTabOrder(self.AddressEdit, self.UsernameEdit)
|
||||
BibleImportDialog.setTabOrder(self.UsernameEdit, self.PasswordEdit)
|
||||
BibleImportDialog.setTabOrder(self.PasswordEdit, self.VersionNameEdit)
|
||||
BibleImportDialog.setTabOrder(self.VersionNameEdit, self.CopyrightEdit)
|
||||
BibleImportDialog.setTabOrder(self.CopyrightEdit, self.PermisionEdit)
|
||||
|
||||
def retranslateUi(self, BibleImportDialog):
|
||||
BibleImportDialog.setWindowTitle(self.trUtf8('Bible Registration'))
|
||||
self.LicenceDetailsGroupBox.setTitle(self.trUtf8('Licence Details'))
|
||||
self.VersionNameLabel.setText(self.trUtf8('Version Name:'))
|
||||
self.CopyrightLabel.setText(self.trUtf8('Copyright:'))
|
||||
self.PermisionLabel.setText(self.trUtf8('Permission:'))
|
||||
self.ProgressGroupBox.setTitle(self.trUtf8('Import Progress'))
|
||||
self.ProgressBar.setFormat(self.trUtf8('%p'))
|
||||
self.ImportButton.setText(self.trUtf8('Import'))
|
||||
self.CancelButton.setText(self.trUtf8('Cancel'))
|
||||
self.OSISGroupBox.setTitle(self.trUtf8('OSIS Bible'))
|
||||
self.BibleNameLabel.setText(self.trUtf8('Bible Name:'))
|
||||
self.LocatioLabel.setText(self.trUtf8('File Location:'))
|
||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.OsisTab),
|
||||
self.trUtf8('Osis (Sword) Imports'))
|
||||
self.CVSGroupBox.setTitle(self.trUtf8('CVS Bible'))
|
||||
self.BooksLocationLabel.setText(self.trUtf8('Books Location:'))
|
||||
self.VerseLocationLabel.setText(self.trUtf8('Verse Location:'))
|
||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.CsvTab),
|
||||
self.trUtf8('CSV File Imports'))
|
||||
self.OptionsGroupBox.setTitle(self.trUtf8('Download Options'))
|
||||
self.LocationLabel.setText(self.trUtf8('Location:'))
|
||||
self.LocationComboBox.setItemText(0, self.trUtf8('Crosswalk'))
|
||||
self.LocationComboBox.setItemText(1, self.trUtf8('BibleGateway'))
|
||||
self.BibleLabel.setText(self.trUtf8('Bible:'))
|
||||
self.ProxyGroupBox.setTitle(self.trUtf8('Proxy Settings (Optional)'))
|
||||
self.AddressLabel.setText(self.trUtf8('Proxy Address:'))
|
||||
self.UsernameLabel.setText(self.trUtf8('Username:'))
|
||||
self.PasswordLabel.setText(self.trUtf8('Password:'))
|
||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.HttpTab),
|
||||
self.trUtf8('Web Downloads'))
|
@ -1,355 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2009 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2009 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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 os
|
||||
import os.path
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from bibleimportdialog import Ui_BibleImportDialog
|
||||
from openlp.core.lib import Receiver
|
||||
|
||||
class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
|
||||
global log
|
||||
log = logging.getLogger(u'BibleImportForm')
|
||||
log.info(u'BibleImportForm loaded')
|
||||
"""
|
||||
Class documentation goes here.
|
||||
"""
|
||||
def __init__(self, config, biblemanager, bibleplugin, parent=None):
|
||||
'''
|
||||
Constructor
|
||||
'''
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self.biblemanager = biblemanager
|
||||
self.config = config
|
||||
self.bibleplugin = bibleplugin
|
||||
self.bible_type = None
|
||||
self.barmax = 0
|
||||
self.tabWidget.setCurrentIndex(0)
|
||||
self.cwBibleVersions = {}
|
||||
self.bgBibleVersions = {}
|
||||
self.AddressEdit.setText(self.config.get_config(u'proxy address', u''))
|
||||
self.UsernameEdit.setText(self.config.get_config(u'proxy username',u''))
|
||||
self.PasswordEdit.setText(self.config.get_config(u'proxy password',u''))
|
||||
#Load and store Crosswalk Bibles
|
||||
filepath = os.path.split(os.path.abspath(__file__))[0]
|
||||
filepath = os.path.abspath(os.path.join(filepath, u'..',
|
||||
u'resources', u'crosswalkbooks.csv'))
|
||||
fbibles = None
|
||||
try:
|
||||
fbibles = open(filepath, 'r')
|
||||
for line in fbibles:
|
||||
p = line.split(u',')
|
||||
self.cwBibleVersions[p[0]] = p[1].replace(u'\n', u'')
|
||||
except:
|
||||
log.exception(u'Crosswalk resources missing')
|
||||
finally:
|
||||
if fbibles:
|
||||
fbibles.close()
|
||||
#Load and store BibleGateway Bibles
|
||||
filepath = os.path.split(os.path.abspath(__file__))[0]
|
||||
filepath = os.path.abspath(os.path.join(filepath, u'..',
|
||||
u'resources', u'biblegateway.csv'))
|
||||
try:
|
||||
fbibles = open(filepath, 'r')
|
||||
for line in fbibles:
|
||||
p = line.split(u',')
|
||||
self.bgBibleVersions[p[0]] = p[1].replace(u'\n', u'')
|
||||
except:
|
||||
log.exception(u'Biblegateway resources missing')
|
||||
finally:
|
||||
if fbibles:
|
||||
fbibles.close()
|
||||
self.loadBibleCombo(self.cwBibleVersions)
|
||||
self.cwActive = True
|
||||
|
||||
def loadBibleCombo(self, biblesList):
|
||||
self.BibleComboBox.clear()
|
||||
self.BibleComboBox.addItem(u'')
|
||||
for bible in biblesList:
|
||||
row = self.BibleComboBox.count()
|
||||
self.BibleComboBox.addItem(unicode(self.trUtf8(bible)))
|
||||
self.BibleComboBox.setItemData(row, QtCore.QVariant(bible))
|
||||
|
||||
#Combo Boxes
|
||||
QtCore.QObject.connect(self.LocationComboBox,
|
||||
QtCore.SIGNAL(u'activated(int)'), self.onLocationComboBoxSelected)
|
||||
QtCore.QObject.connect(self.BibleComboBox,
|
||||
QtCore.SIGNAL(u'activated(int)'), self.onBibleComboBoxSelected)
|
||||
|
||||
#Buttons
|
||||
QtCore.QObject.connect(self.ImportButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onImportButtonClicked)
|
||||
QtCore.QObject.connect(self.CancelButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onCancelButtonClicked)
|
||||
QtCore.QObject.connect(self.VersesFileButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onVersesFileButtonClicked)
|
||||
QtCore.QObject.connect(self.BooksFileButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onBooksFileButtonClicked)
|
||||
QtCore.QObject.connect(self.OsisFileButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onOsisFileButtonClicked)
|
||||
|
||||
#Lost Focus
|
||||
QtCore.QObject.connect(self.OSISLocationEdit,
|
||||
QtCore.SIGNAL(u'lostFocus()'), self.onOSISLocationEditLostFocus)
|
||||
QtCore.QObject.connect(self.BooksLocationEdit,
|
||||
QtCore.SIGNAL(u'lostFocus()'),self.onBooksLocationEditLostFocus)
|
||||
QtCore.QObject.connect(self.VerseLocationEdit,
|
||||
QtCore.SIGNAL(u'lostFocus()'), self.onVerseLocationEditLostFocus)
|
||||
QtCore.QObject.connect(self.AddressEdit,
|
||||
QtCore.SIGNAL(u'lostFocus()'), self.onProxyAddressEditLostFocus)
|
||||
QtCore.QObject.connect(self.UsernameEdit,
|
||||
QtCore.SIGNAL(u'lostFocus()'), self.onProxyUsernameEditLostFocus)
|
||||
QtCore.QObject.connect(self.PasswordEdit,
|
||||
QtCore.SIGNAL(u'lostFocus()'), self.onProxyPasswordEditLostFocus)
|
||||
|
||||
|
||||
def onVersesFileButtonClicked(self):
|
||||
filename = QtGui.QFileDialog.getOpenFileName(
|
||||
self, self.trUtf8('Open Bible Verses file'),
|
||||
self.config.get_last_dir(1))
|
||||
if filename:
|
||||
self.VerseLocationEdit.setText(filename)
|
||||
self.config.set_last_dir(filename, 1)
|
||||
self.setCsv()
|
||||
|
||||
def onBooksFileButtonClicked(self):
|
||||
filename = QtGui.QFileDialog.getOpenFileName(
|
||||
self, self.trUtf8('Open Bible Books file'),
|
||||
self.config.get_last_dir(2))
|
||||
if filename:
|
||||
self.BooksLocationEdit.setText(filename)
|
||||
self.config.set_last_dir(filename, 2)
|
||||
self.setCsv()
|
||||
|
||||
def onOsisFileButtonClicked(self):
|
||||
filename = QtGui.QFileDialog.getOpenFileName(
|
||||
self, self.trUtf8('Open OSIS import file'),
|
||||
self.config.get_last_dir(3))
|
||||
if filename:
|
||||
self.OSISLocationEdit.setText(filename)
|
||||
self.config.set_last_dir(filename, 3)
|
||||
self.setOsis()
|
||||
|
||||
def onOSISLocationEditLostFocus(self):
|
||||
if len(self.OSISLocationEdit.displayText() ) > 0:
|
||||
self.setOsis()
|
||||
else:
|
||||
# Was OSIS and is not any more stops lostFocus running mad
|
||||
if self.bible_type == u'OSIS':
|
||||
self.bible_type = None
|
||||
self.resetScreenFieldStates()
|
||||
|
||||
def onBooksLocationEditLostFocus(self):
|
||||
self.checkOsis()
|
||||
|
||||
def onVerseLocationEditLostFocus(self):
|
||||
self.checkOsis()
|
||||
|
||||
def onProxyAddressEditLostFocus(self):
|
||||
self.config.set_config(
|
||||
u'proxy address', unicode(self.AddressEdit.displayText()))
|
||||
|
||||
def onProxyUsernameEditLostFocus(self):
|
||||
self.config.set_config(
|
||||
u'proxy username', unicode(self.UsernameEdit.displayText()))
|
||||
|
||||
def onProxyPasswordEditLostFocus(self):
|
||||
self.config.set_config(
|
||||
u'proxy password', unicode(self.PasswordEdit.displayText()))
|
||||
|
||||
def onLocationComboBoxSelected(self, value):
|
||||
if value == 0:
|
||||
self.loadBibleCombo(self.cwBibleVersions)
|
||||
self.cwActive = True
|
||||
else:
|
||||
self.loadBibleCombo(self.bgBibleVersions)
|
||||
self.cwActive = False
|
||||
self.checkHttp()
|
||||
|
||||
def onBibleComboBoxSelected(self, value):
|
||||
self.checkHttp()
|
||||
self.BibleNameEdit.setText(unicode(self.BibleComboBox.currentText()))
|
||||
self.VersionNameEdit.setText(unicode(self.BibleComboBox.currentText()))
|
||||
|
||||
def onCancelButtonClicked(self):
|
||||
# tell import to stop
|
||||
self.message = self.trUtf8('Bible import stopped')
|
||||
Receiver.send_message(u'stop_import')
|
||||
# tell bibleplugin to reload the bibles
|
||||
Receiver.send_message(u'pre_load_bibles')
|
||||
self.close()
|
||||
|
||||
def onImportButtonClicked(self):
|
||||
message = self.trUtf8('Bible import completed')
|
||||
if self.biblemanager:
|
||||
if not self.bible_type is None and \
|
||||
len(self.BibleNameEdit.displayText()) > 0:
|
||||
self.MessageLabel.setText(self.trUtf8('Import Started'))
|
||||
self.ProgressBar.setMinimum(0)
|
||||
self.setMax(65)
|
||||
self.ProgressBar.setValue(0)
|
||||
self.biblemanager.process_dialog(self)
|
||||
status, msg = self.importBible()
|
||||
if msg:
|
||||
message = msg
|
||||
self.MessageLabel.setText(message)
|
||||
self.ProgressBar.setValue(self.barmax)
|
||||
# tell bibleplugin to reload the bibles
|
||||
Receiver.send_message(u'pre_load_bibles')
|
||||
QtGui.QMessageBox.information(self,
|
||||
self.trUtf8('Information'), self.trUtf8(message))
|
||||
|
||||
def setMax(self, max):
|
||||
log.debug(u'set Max %s', max)
|
||||
self.barmax = max
|
||||
self.ProgressBar.setMaximum(max)
|
||||
|
||||
def incrementProgressBar(self, text):
|
||||
log.debug(u'IncrementBar %s', text)
|
||||
self.MessageLabel.setText(unicode(self.trUtf8('Import processing')) + ' - %s' % text)
|
||||
self.ProgressBar.setValue(self.ProgressBar.value() + 1)
|
||||
|
||||
def importBible(self):
|
||||
log.debug(u'Import Bible %s' % self.bible_type)
|
||||
message = None
|
||||
if self.bible_type == u'OSIS':
|
||||
loaded = self.biblemanager.register_osis_file_bible(
|
||||
unicode(self.BibleNameEdit.displayText()),
|
||||
self.OSISLocationEdit.displayText())
|
||||
elif self.bible_type == u'CSV':
|
||||
loaded = self.biblemanager.register_csv_file_bible(
|
||||
unicode(self.BibleNameEdit.displayText()),
|
||||
self.BooksLocationEdit.displayText(),
|
||||
self.VerseLocationEdit.displayText())
|
||||
else:
|
||||
# set a value as it will not be needed
|
||||
self.setMax(1)
|
||||
if self.cwActive:
|
||||
bible = self.cwBibleVersions[
|
||||
unicode(self.BibleComboBox.currentText())]
|
||||
else:
|
||||
bible = self.bgBibleVersions[
|
||||
unicode(self.BibleComboBox.currentText())]
|
||||
loaded = self.biblemanager.register_http_bible(
|
||||
unicode(self.BibleComboBox.currentText()),
|
||||
unicode(self.LocationComboBox.currentText()),
|
||||
unicode(bible), unicode(self.AddressEdit.displayText()),
|
||||
unicode(self.UsernameEdit .displayText()),
|
||||
unicode(self.PasswordEdit.displayText()))
|
||||
if loaded:
|
||||
self.biblemanager.save_meta_data(
|
||||
unicode(self.BibleNameEdit.displayText()),
|
||||
unicode(self.VersionNameEdit.displayText()),
|
||||
unicode(self.CopyrightEdit.displayText()),
|
||||
unicode(self.PermisionEdit.displayText()))
|
||||
else:
|
||||
message = self.trUtf8('Bible import failed as name is already in use')
|
||||
self.bible_type = None
|
||||
# free the screen state restrictions
|
||||
self.resetScreenFieldStates()
|
||||
# reset all the screen fields
|
||||
self.resetEntryFields()
|
||||
return loaded, message
|
||||
|
||||
def checkOsis(self):
|
||||
if len(self.BooksLocationEdit.displayText()) > 0 or \
|
||||
len(self.VerseLocationEdit.displayText()) > 0:
|
||||
self.setCsv()
|
||||
else:
|
||||
# Was CSV and is not any more stops lostFocus running mad
|
||||
if self.bible_type == u'CSV':
|
||||
self.bible_type = None
|
||||
self.resetScreenFieldStates()
|
||||
|
||||
def checkHttp(self):
|
||||
if self.BibleComboBox.currentIndex() != 0 :
|
||||
# First slot is blank so no bible
|
||||
self.setHttp()
|
||||
else:
|
||||
# Was HTTP and is not any more stops lostFocus running mad
|
||||
if self.bible_type == u'HTTP':
|
||||
self.bible_type = None
|
||||
self.resetScreenFieldStates()
|
||||
|
||||
def blockCsv(self):
|
||||
self.BooksLocationEdit.setReadOnly(True)
|
||||
self.VerseLocationEdit.setReadOnly(True)
|
||||
self.BooksFileButton.setEnabled(False)
|
||||
self.VersesFileButton.setEnabled(False)
|
||||
|
||||
def setCsv(self):
|
||||
self.bible_type = u'CSV'
|
||||
self.BooksLocationEdit.setReadOnly(False)
|
||||
self.VerseLocationEdit.setReadOnly(False)
|
||||
self.BooksFileButton.setEnabled(True)
|
||||
self.VersesFileButton.setEnabled(True)
|
||||
self.blockOsis()
|
||||
self.blockHttp()
|
||||
|
||||
def setOsis(self):
|
||||
self.bible_type = u'OSIS'
|
||||
self.OSISLocationEdit.setReadOnly(False)
|
||||
self.OsisFileButton.setEnabled(True)
|
||||
self.blockCsv()
|
||||
self.blockHttp()
|
||||
|
||||
def blockOsis(self):
|
||||
self.OSISLocationEdit.setReadOnly(True)
|
||||
self.OsisFileButton.setEnabled(False)
|
||||
|
||||
def setHttp(self):
|
||||
self.bible_type = u'HTTP'
|
||||
self.LocationComboBox.setEnabled(True)
|
||||
self.BibleComboBox.setEnabled(True)
|
||||
self.blockCsv()
|
||||
self.blockOsis()
|
||||
|
||||
def blockHttp(self):
|
||||
self.LocationComboBox.setEnabled(False)
|
||||
self.BibleComboBox.setEnabled(False)
|
||||
|
||||
def resetScreenFieldStates(self):
|
||||
# only reset if no bible type set.
|
||||
if self.bible_type is None:
|
||||
self.BooksLocationEdit.setReadOnly(False)
|
||||
self.VerseLocationEdit.setReadOnly(False)
|
||||
self.BooksFileButton.setEnabled(True)
|
||||
self.VersesFileButton.setEnabled(True)
|
||||
self.OSISLocationEdit.setReadOnly(False)
|
||||
self.OsisFileButton.setEnabled(True)
|
||||
self.LocationComboBox.setEnabled(True)
|
||||
self.BibleComboBox.setEnabled(True)
|
||||
|
||||
def resetEntryFields(self):
|
||||
self.BooksLocationEdit.setText(u'')
|
||||
self.VerseLocationEdit.setText(u'')
|
||||
self.OSISLocationEdit.setText(u'')
|
||||
self.BibleNameEdit.setText(u'')
|
||||
self.LocationComboBox.setCurrentIndex(0)
|
||||
self.BibleComboBox.setCurrentIndex(0)
|
@ -60,7 +60,6 @@ class BibleDBImpl(BibleCommon):
|
||||
self._load_testament(u'Apocrypha')
|
||||
|
||||
def add_verse(self, bookid, chap, vse, text):
|
||||
log.debug(u'add_verse %s,%s,%s', bookid, chap, vse)
|
||||
verse = Verse()
|
||||
verse.book_id = bookid
|
||||
verse.chapter = chap
|
||||
@ -70,6 +69,7 @@ class BibleDBImpl(BibleCommon):
|
||||
return verse
|
||||
|
||||
def save_verses(self):
|
||||
log.debug('Saving verses...')
|
||||
self.session.commit()
|
||||
|
||||
def create_chapter(self, bookid, chap, textlist):
|
||||
|
@ -127,7 +127,6 @@ class BibleOSISImpl():
|
||||
chapter = int(match.group(2))
|
||||
verse = int(match.group(3))
|
||||
verse_text = match.group(4)
|
||||
print book, chapter, verse
|
||||
if not db_book or db_book.name != book:
|
||||
if book == u'Matt':
|
||||
testament += 1
|
||||
|
Loading…
Reference in New Issue
Block a user