forked from openlp/openlp
Clean up
changed create_book in cscbible, openlp1, opensong and osis
This commit is contained in:
parent
1c59fd656f
commit
7a15251ffc
@ -53,7 +53,7 @@ class Ui_BibleImportRequest(object):
|
||||
font.setBold(True)
|
||||
self.headlineLabel.setFont(font)
|
||||
self.headlineLabel.setObjectName("HeadlineLabel")
|
||||
self.verticalLayout.addWidget(self.HeadlineLabel)
|
||||
self.verticalLayout.addWidget(self.headlineLabel)
|
||||
self.infoLabel = QtGui.QLabel(self.widget)
|
||||
self.infoLabel.setObjectName("InfoLabel")
|
||||
self.verticalLayout.addWidget(self.infoLabel)
|
||||
|
@ -70,7 +70,7 @@ import chardet
|
||||
import csv
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.plugins.bibles.lib.db import BibleDB, Testament
|
||||
from openlp.plugins.bibles.lib.db import BibleDB, Testament, BiblesResourcesDB
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -86,6 +86,7 @@ class CSVBible(BibleDB):
|
||||
"""
|
||||
log.info(self.__class__.__name__)
|
||||
BibleDB.__init__(self, parent, **kwargs)
|
||||
self.parent = parent
|
||||
try:
|
||||
self.testamentsfile = kwargs[u'testamentsfile']
|
||||
except KeyError:
|
||||
@ -135,7 +136,10 @@ class CSVBible(BibleDB):
|
||||
self.wizard.progressBar.setMinimum(0)
|
||||
self.wizard.progressBar.setMaximum(66)
|
||||
success = True
|
||||
#TODO: include create_meta language
|
||||
language = self.parent.mediaItem.importRequest(u'language')
|
||||
language = BiblesResourcesDB.get_language(language)
|
||||
language_id = language[u'id']
|
||||
self.create_meta(u'language_id', language_id)
|
||||
books_file = None
|
||||
book_list = {}
|
||||
# Populate the Tables
|
||||
@ -149,10 +153,11 @@ class CSVBible(BibleDB):
|
||||
self.wizard.incrementProgressBar(unicode(
|
||||
translate('BibleDB.Wizard', 'Importing books... %s')) %
|
||||
unicode(line[2], details['encoding']))
|
||||
#TODO: change create_book to the new database model
|
||||
#(name, bk_ref_id, testament)
|
||||
book_ref_id = self.parent.manager.get_book_ref_id_by_name(
|
||||
unicode(line[2], details['encoding']), language_id)
|
||||
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
|
||||
self.create_book(unicode(line[2], details['encoding']),
|
||||
unicode(line[3], details['encoding']), int(line[1]))
|
||||
book_ref_id, book_details[u'testament_id'])
|
||||
book_list[int(line[0])] = unicode(line[2], details['encoding'])
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
except (IOError, IndexError):
|
||||
|
@ -290,7 +290,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
def importRequest(self, case, name=None):
|
||||
self.import_request = BibleImportRequest(self)
|
||||
if self.import_request.exec_(case, name):
|
||||
return unicode(self.import_request.RequestComboBox.currentText())
|
||||
return unicode(self.import_request.requestComboBox.currentText())
|
||||
|
||||
def loadBibles(self):
|
||||
log.debug(u'Loading Bibles')
|
||||
|
@ -29,7 +29,7 @@ import sqlite
|
||||
|
||||
from openlp.core.lib import Receiver
|
||||
from openlp.core.ui.wizard import WizardStrings
|
||||
from openlp.plugins.bibles.lib.db import BibleDB
|
||||
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -43,6 +43,7 @@ class OpenLP1Bible(BibleDB):
|
||||
"""
|
||||
log.debug(self.__class__.__name__)
|
||||
BibleDB.__init__(self, parent, **kwargs)
|
||||
self.parent = parent
|
||||
self.filename = kwargs[u'filename']
|
||||
|
||||
def do_import(self):
|
||||
@ -56,7 +57,11 @@ class OpenLP1Bible(BibleDB):
|
||||
cursor = connection.cursor()
|
||||
except:
|
||||
return False
|
||||
#TODO: include create_meta language
|
||||
#Create the bible language
|
||||
language = self.parent.mediaItem.importRequest(u'language')
|
||||
language = BiblesResourcesDB.get_language(language)
|
||||
language_id = language[u'id']
|
||||
self.create_meta(u'language_id', language_id)
|
||||
# Create all books.
|
||||
cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
|
||||
books = cursor.fetchall()
|
||||
@ -69,9 +74,10 @@ class OpenLP1Bible(BibleDB):
|
||||
testament_id = int(book[1])
|
||||
name = unicode(book[2], u'cp1252')
|
||||
abbreviation = unicode(book[3], u'cp1252')
|
||||
#TODO: change create_book to the new database model
|
||||
#(name, bk_ref_id, testament)
|
||||
self.create_book(name, abbreviation, testament_id)
|
||||
book_ref_id = self.parent.manager.get_book_ref_id_by_name(name,
|
||||
language_id)
|
||||
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
|
||||
self.create_book(name, book_ref_id, book_details[u'testament_id'])
|
||||
# Update the progess bar.
|
||||
self.wizard.incrementProgressBar(WizardStrings.ImportingType % name)
|
||||
# Import the verses for this book.
|
||||
|
@ -28,7 +28,7 @@ import logging
|
||||
from lxml import objectify
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.plugins.bibles.lib.db import BibleDB
|
||||
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -43,6 +43,7 @@ class OpenSongBible(BibleDB):
|
||||
"""
|
||||
log.debug(self.__class__.__name__)
|
||||
BibleDB.__init__(self, parent, **kwargs)
|
||||
self.parent = parent
|
||||
self.filename = kwargs['filename']
|
||||
|
||||
def do_import(self):
|
||||
@ -61,14 +62,18 @@ class OpenSongBible(BibleDB):
|
||||
file = open(self.filename, u'r')
|
||||
opensong = objectify.parse(file)
|
||||
bible = opensong.getroot()
|
||||
#TODO: include create_meta language
|
||||
language = self.parent.mediaItem.importRequest(u'language')
|
||||
language = BiblesResourcesDB.get_language(language)
|
||||
language_id = language[u'id']
|
||||
self.create_meta(u'language_id', language_id)
|
||||
for book in bible.b:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
#TODO: change create_book to the new database model
|
||||
#(name, bk_ref_id, testament)
|
||||
db_book = self.create_book(unicode(book.attrib[u'n']),
|
||||
unicode(book.attrib[u'n'][:4]))
|
||||
book_ref_id = self.parent.manager.get_book_ref_id_by_name(
|
||||
unicode(book.attrib[u'n']), language_id)
|
||||
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
|
||||
db_book = self.create_book(unicode(book.attrib[u'n']),
|
||||
book_ref_id, book_details[u'testament_id'])
|
||||
for chapter in book.c:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
|
@ -33,7 +33,7 @@ import re
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.utils import AppLocation
|
||||
from openlp.plugins.bibles.lib.db import BibleDB
|
||||
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -46,6 +46,7 @@ class OSISBible(BibleDB):
|
||||
def __init__(self, parent, **kwargs):
|
||||
log.debug(self.__class__.__name__)
|
||||
BibleDB.__init__(self, parent, **kwargs)
|
||||
self.parent = parent
|
||||
self.filename = kwargs[u'filename']
|
||||
fbibles = None
|
||||
self.books = {}
|
||||
@ -104,7 +105,11 @@ class OSISBible(BibleDB):
|
||||
finally:
|
||||
if detect_file:
|
||||
detect_file.close()
|
||||
#TODO: include create_meta language with try - except scheme
|
||||
# Set meta language_id
|
||||
language = self.parent.mediaItem.importRequest(u'language')
|
||||
language = BiblesResourcesDB.get_language(language)
|
||||
language_id = language[u'id']
|
||||
self.create_meta(u'language_id', language_id)
|
||||
try:
|
||||
osis = codecs.open(self.filename, u'r', details['encoding'])
|
||||
for file_record in osis:
|
||||
@ -123,10 +128,13 @@ class OSISBible(BibleDB):
|
||||
testament += 1
|
||||
#TODO: change create_book to the new database model
|
||||
#(name, bk_ref_id, testament)
|
||||
book_ref_id = self.parent.manager.get_book_ref_id_by_name(
|
||||
unicode(self.books[book][0]), language_id)
|
||||
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
|
||||
db_book = self.create_book(
|
||||
unicode(self.books[book][0]),
|
||||
unicode(self.books[book][1]),
|
||||
testament)
|
||||
book_ref_id,
|
||||
book_details[u'testament_id'])
|
||||
if last_chapter == 0:
|
||||
if book == u'Gen':
|
||||
self.wizard.progressBar.setMaximum(1188)
|
||||
|
137
resources/forms/bibleimportrequestdialog.ui
Normal file
137
resources/forms/bibleimportrequestdialog.ui
Normal file
@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BibleImportRequest</class>
|
||||
<widget class="QDialog" name="BibleImportRequest">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>175</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>15</y>
|
||||
<width>381</width>
|
||||
<height>151</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="HeadlineLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Choose Book:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="InfoLabel">
|
||||
<property name="text">
|
||||
<string>The following books cannot be clearly attributed.
|
||||
Please choose the book it is.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="RequestLabel">
|
||||
<property name="text">
|
||||
<string>Book:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="RequestComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="BibleImportRequestButtonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>BibleImportRequestButtonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>BibleImportRequest</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>BibleImportRequestButtonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>BibleImportRequest</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user