forked from openlp/openlp
A fix for issue 507. http://support.openlp.org/issues/507
The opensong database file contained verses containing sub-elements such as <i> tags. lxml considders the text of an element up until the first sub element. bzr-revno: 2001
This commit is contained in:
commit
b39e23d224
@ -46,6 +46,22 @@ class OpenSongBible(BibleDB):
|
|||||||
BibleDB.__init__(self, parent, **kwargs)
|
BibleDB.__init__(self, parent, **kwargs)
|
||||||
self.filename = kwargs['filename']
|
self.filename = kwargs['filename']
|
||||||
|
|
||||||
|
def get_text(self, element):
|
||||||
|
"""
|
||||||
|
Recursively get all text in an objectify element and its child elements.
|
||||||
|
|
||||||
|
``element``
|
||||||
|
An objectify element to get the text from
|
||||||
|
"""
|
||||||
|
verse_text = u''
|
||||||
|
if element.text:
|
||||||
|
verse_text = element.text
|
||||||
|
for sub_element in element.iterchildren():
|
||||||
|
verse_text += self.get_text(sub_element)
|
||||||
|
if element.tail:
|
||||||
|
verse_text += element.tail
|
||||||
|
return verse_text
|
||||||
|
|
||||||
def do_import(self, bible_name=None):
|
def do_import(self, bible_name=None):
|
||||||
"""
|
"""
|
||||||
Loads a Bible from file.
|
Loads a Bible from file.
|
||||||
@ -89,7 +105,7 @@ class OpenSongBible(BibleDB):
|
|||||||
db_book.id,
|
db_book.id,
|
||||||
int(chapter.attrib[u'n'].split()[-1]),
|
int(chapter.attrib[u'n'].split()[-1]),
|
||||||
int(verse.attrib[u'n']),
|
int(verse.attrib[u'n']),
|
||||||
unicode(verse.text))
|
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>...')) %
|
||||||
|
Loading…
Reference in New Issue
Block a user