forked from openlp/openlp
Fixed bug #1074727 "OpenSong Bibles cause OpenLP to crash due to missing attriburte"
Counts the chapter and verse numbers and uses these when no number is in the attribute.
This commit is contained in:
parent
56d44cc1f5
commit
53b729af9e
@ -98,31 +98,42 @@ class OpenSongBible(BibleDB):
|
|||||||
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
|
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
|
||||||
db_book = self.create_book(unicode(book.attrib[u'n']),
|
db_book = self.create_book(unicode(book.attrib[u'n']),
|
||||||
book_ref_id, book_details[u'testament_id'])
|
book_ref_id, book_details[u'testament_id'])
|
||||||
|
chapter_number = 0
|
||||||
for chapter in book.c:
|
for chapter in book.c:
|
||||||
if self.stop_import_flag:
|
if self.stop_import_flag:
|
||||||
break
|
break
|
||||||
|
number = chapter.attrib[u'n']
|
||||||
|
if number:
|
||||||
|
chapter_number = int(number.split()[-1])
|
||||||
|
else:
|
||||||
|
chapter_number += 1
|
||||||
|
verse_number = 0
|
||||||
for verse in chapter.v:
|
for verse in chapter.v:
|
||||||
if self.stop_import_flag:
|
if self.stop_import_flag:
|
||||||
break
|
break
|
||||||
verse_number = 0
|
number = verse.attrib[u'n']
|
||||||
try:
|
if number:
|
||||||
verse_number = int(verse.attrib[u'n'])
|
try:
|
||||||
except ValueError:
|
number = int(number)
|
||||||
verse_parts = verse.attrib[u'n'].split(u'-')
|
except ValueError:
|
||||||
if len(verse_parts) > 1:
|
verse_parts = number.split(u'-')
|
||||||
verse_number = int(verse_parts[0])
|
if len(verse_parts) > 1:
|
||||||
except TypeError:
|
number = int(verse_parts[0])
|
||||||
log.warn(u'Illegal verse number: %s',
|
except TypeError:
|
||||||
unicode(verse.attrib[u'n']))
|
log.warn(u'Illegal verse number: %s',
|
||||||
|
unicode(verse.attrib[u'n']))
|
||||||
|
verse_number = number
|
||||||
|
else:
|
||||||
|
verse_number += 1
|
||||||
self.create_verse(
|
self.create_verse(
|
||||||
db_book.id,
|
db_book.id,
|
||||||
int(chapter.attrib[u'n'].split()[-1]),
|
chapter_number,
|
||||||
verse_number,
|
verse_number,
|
||||||
unicode(self.get_text(verse)))
|
unicode(self.get_text(verse)))
|
||||||
self.wizard.incrementProgressBar(unicode(translate(
|
self.wizard.incrementProgressBar(unicode(translate(
|
||||||
'BiblesPlugin.Opensong', 'Importing %s %s...',
|
'BiblesPlugin.Opensong', 'Importing %s %s...',
|
||||||
'Importing <book name> <chapter>...')) %
|
'Importing <book name> <chapter>...')) %
|
||||||
(db_book.name, int(chapter.attrib[u'n'].split()[-1])))
|
(db_book.name, chapter_number))
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
Receiver.send_message(u'openlp_process_events')
|
||||||
except etree.XMLSyntaxError as inst:
|
except etree.XMLSyntaxError as inst:
|
||||||
|
Loading…
Reference in New Issue
Block a user