openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #16047
[Merge] lp:~phill-ridout/openlp/issue-507 into lp:openlp
phill has proposed merging lp:~phill-ridout/openlp/issue-507 into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/issue-507/+merge/110682
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.
--
https://code.launchpad.net/~phill-ridout/openlp/issue-507/+merge/110682
Your team OpenLP Core is requested to review the proposed merge of lp:~phill-ridout/openlp/issue-507 into lp:openlp.
=== modified file 'openlp/plugins/bibles/lib/opensong.py'
--- openlp/plugins/bibles/lib/opensong.py 2012-04-04 07:26:51 +0000
+++ openlp/plugins/bibles/lib/opensong.py 2012-06-17 14:02:20 +0000
@@ -26,7 +26,7 @@
###############################################################################
import logging
-from lxml import objectify
+from lxml import objectify, etree
from openlp.core.lib import Receiver, translate
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
@@ -46,6 +46,17 @@
BibleDB.__init__(self, parent, **kwargs)
self.filename = kwargs['filename']
+ def get_text(self, element):
+ 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):
"""
Loads a Bible from file.
@@ -89,7 +100,7 @@
db_book.id,
int(chapter.attrib[u'n'].split()[-1]),
int(verse.attrib[u'n']),
- unicode(verse.text))
+ unicode(self.get_text(verse)))
self.wizard.incrementProgressBar(unicode(translate(
'BiblesPlugin.Opensong', 'Importing %s %s...',
'Importing <book name> <chapter>...')) %
Follow ups