forked from openlp/openlp
new function get_language in BibleDB which ask for the language a bible is and return a language_id
This commit is contained in:
parent
9de33cf194
commit
fbce21baaa
@ -139,14 +139,11 @@ class CSVBible(BibleDB):
|
|||||||
self.wizard.progressBar.setMinimum(0)
|
self.wizard.progressBar.setMinimum(0)
|
||||||
self.wizard.progressBar.setMaximum(66)
|
self.wizard.progressBar.setMaximum(66)
|
||||||
success = True
|
success = True
|
||||||
language = self.parent.manager.import_wizard.languageDialog()
|
language_id = self.get_language()
|
||||||
if not language:
|
if not language_id:
|
||||||
log.exception(u'Importing books from %s " '\
|
log.exception(u'Importing books from %s " '\
|
||||||
'failed' % self.booksfile)
|
'failed' % self.filename)
|
||||||
return False
|
return False
|
||||||
language = BiblesResourcesDB.get_language(language)
|
|
||||||
language_id = language[u'id']
|
|
||||||
self.create_meta(u'language_id', language_id)
|
|
||||||
books_file = None
|
books_file = None
|
||||||
book_list = {}
|
book_list = {}
|
||||||
# Populate the Tables
|
# Populate the Tables
|
||||||
|
@ -489,6 +489,22 @@ class BibleDB(QtCore.QObject, Manager):
|
|||||||
else:
|
else:
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
def get_language(self):
|
||||||
|
"""
|
||||||
|
Return the language of a bible.
|
||||||
|
|
||||||
|
``book``
|
||||||
|
The language the bible is.
|
||||||
|
"""
|
||||||
|
log.debug(u'BibleDB.get_language()')
|
||||||
|
language = self.bible_plugin.manager.import_wizard.languageDialog()
|
||||||
|
if not language:
|
||||||
|
return False
|
||||||
|
language = BiblesResourcesDB.get_language(language)
|
||||||
|
language_id = language[u'id']
|
||||||
|
self.create_meta(u'language_id', language_id)
|
||||||
|
return language_id
|
||||||
|
|
||||||
def dump_bible(self):
|
def dump_bible(self):
|
||||||
"""
|
"""
|
||||||
Utility debugging method to dump the contents of a bible.
|
Utility debugging method to dump the contents of a bible.
|
||||||
|
@ -413,16 +413,13 @@ class HTTPBible(BibleDB):
|
|||||||
self.download_source.lower())
|
self.download_source.lower())
|
||||||
if bible[u'language_id']:
|
if bible[u'language_id']:
|
||||||
language_id = bible[u'language_id']
|
language_id = bible[u'language_id']
|
||||||
|
self.create_meta(u'language_id', language_id)
|
||||||
else:
|
else:
|
||||||
language = self.parent.manager.import_wizard.languageDialog()
|
language_id = self.get_language()
|
||||||
if not language:
|
if not language_id:
|
||||||
log.exception(u'Importing books from %s - download name: "%s" '\
|
log.exception(u'Importing books from %s " '\
|
||||||
'failed' % (self.download_source, self.download_name))
|
'failed' % self.filename)
|
||||||
return False
|
return False
|
||||||
language = BiblesResourcesDB.get_language(language)
|
|
||||||
language_id = language[u'id']
|
|
||||||
# Store the language_id.
|
|
||||||
self.create_meta(u'language_id', language_id)
|
|
||||||
for book in books:
|
for book in books:
|
||||||
self.wizard.incrementProgressBar(unicode(translate(
|
self.wizard.incrementProgressBar(unicode(translate(
|
||||||
'BiblesPlugin.HTTPBible', 'Importing %s...',
|
'BiblesPlugin.HTTPBible', 'Importing %s...',
|
||||||
|
@ -349,9 +349,7 @@ class BibleManager(object):
|
|||||||
book, language_id)
|
book, language_id)
|
||||||
else:
|
else:
|
||||||
book_ref = self.import_wizard.bookNameDialog(book)
|
book_ref = self.import_wizard.bookNameDialog(book)
|
||||||
log.debug(book_ref)
|
|
||||||
book_temp = BiblesResourcesDB.get_book(book_ref)
|
book_temp = BiblesResourcesDB.get_book(book_ref)
|
||||||
log.debug(book_temp)
|
|
||||||
if book_temp:
|
if book_temp:
|
||||||
book_id = book_temp[u'id']
|
book_id = book_temp[u'id']
|
||||||
else:
|
else:
|
||||||
|
@ -58,14 +58,11 @@ class OpenLP1Bible(BibleDB):
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
#Create the bible language
|
#Create the bible language
|
||||||
language = self.parent.manager.import_wizard.languageDialog()
|
language_id = self.get_language()
|
||||||
if not language:
|
if not language_id:
|
||||||
log.exception(u'Importing books from %s " '\
|
log.exception(u'Importing books from %s " '\
|
||||||
'failed' % self.filename)
|
'failed' % self.filename)
|
||||||
return False
|
return False
|
||||||
language = BiblesResourcesDB.get_language(language)
|
|
||||||
language_id = language[u'id']
|
|
||||||
self.create_meta(u'language_id', language_id)
|
|
||||||
# Create all books.
|
# Create all books.
|
||||||
cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
|
cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
|
||||||
books = cursor.fetchall()
|
books = cursor.fetchall()
|
||||||
|
@ -62,14 +62,11 @@ class OpenSongBible(BibleDB):
|
|||||||
file = open(self.filename, u'r')
|
file = open(self.filename, u'r')
|
||||||
opensong = objectify.parse(file)
|
opensong = objectify.parse(file)
|
||||||
bible = opensong.getroot()
|
bible = opensong.getroot()
|
||||||
language = self.parent.manager.import_wizard.languageDialog()
|
language_id = self.get_language()
|
||||||
if not language:
|
if not language_id:
|
||||||
log.exception(u'Importing books from %s " '\
|
log.exception(u'Importing books from %s " '\
|
||||||
'failed' % self.filename)
|
'failed' % self.filename)
|
||||||
return False
|
return False
|
||||||
language = BiblesResourcesDB.get_language(language)
|
|
||||||
language_id = language[u'id']
|
|
||||||
self.create_meta(u'language_id', language_id)
|
|
||||||
for book in bible.b:
|
for book in bible.b:
|
||||||
if self.stop_import_flag:
|
if self.stop_import_flag:
|
||||||
break
|
break
|
||||||
|
@ -107,14 +107,11 @@ class OSISBible(BibleDB):
|
|||||||
if detect_file:
|
if detect_file:
|
||||||
detect_file.close()
|
detect_file.close()
|
||||||
# Set meta language_id
|
# Set meta language_id
|
||||||
language = self.parent.manager.import_wizard.languageDialog()
|
language_id = self.get_language()
|
||||||
if not language:
|
if not language_id:
|
||||||
log.exception(u'Importing books from %s " '\
|
log.exception(u'Importing books from %s " '\
|
||||||
'failed' % self.filename)
|
'failed' % self.filename)
|
||||||
return False
|
return False
|
||||||
language = BiblesResourcesDB.get_language(language)
|
|
||||||
language_id = language[u'id']
|
|
||||||
self.create_meta(u'language_id', language_id)
|
|
||||||
try:
|
try:
|
||||||
osis = codecs.open(self.filename, u'r', details['encoding'])
|
osis = codecs.open(self.filename, u'r', details['encoding'])
|
||||||
for file_record in osis:
|
for file_record in osis:
|
||||||
|
Loading…
Reference in New Issue
Block a user