Fix bug #744515, OSIS import fails to import certain words in ESV (at least)

bzr-revno: 1495
Fixes: https://launchpad.net/bugs/744515
This commit is contained in:
Raoul Snyman 2011-04-28 14:43:13 +02:00 committed by Andreas Preikschat
commit d7d51c614a

View File

@ -37,6 +37,9 @@ from openlp.plugins.bibles.lib.db import BibleDB
log = logging.getLogger(__name__)
def replacement(match):
return match.group(2).upper()
class OSISBible(BibleDB):
"""
`OSIS <http://www.bibletechnologies.net/>`_ Bible format importer class.
@ -60,6 +63,7 @@ class OSISBible(BibleDB):
self.lg_regex = re.compile(r'<lg(.*?)>')
self.l_regex = re.compile(r'<l (.*?)>')
self.w_regex = re.compile(r'<w (.*?)>')
self.q_regex = re.compile(r'<q(.*?)>')
self.q1_regex = re.compile(r'<q(.*?)level="1"(.*?)>')
self.q2_regex = re.compile(r'<q(.*?)level="2"(.*?)>')
self.trans_regex = re.compile(r'<transChange(.*?)>(.*?)</transChange>')
@ -106,6 +110,7 @@ class OSISBible(BibleDB):
detect_file.close()
try:
osis = codecs.open(self.filename, u'r', details['encoding'])
repl = replacement
for file_record in osis:
if self.stop_import_flag:
break
@ -152,8 +157,9 @@ class OSISBible(BibleDB):
verse_text = self.w_regex.sub(u'', verse_text)
verse_text = self.q1_regex.sub(u'"', verse_text)
verse_text = self.q2_regex.sub(u'\'', verse_text)
verse_text = self.q_regex.sub(u'', verse_text)
verse_text = self.divine_name_regex.sub(repl, verse_text)
verse_text = self.trans_regex.sub(u'', verse_text)
verse_text = self.divine_name_regex.sub(u'', verse_text)
verse_text = verse_text.replace(u'</lb>', u'')\
.replace(u'</l>', u'').replace(u'<lg>', u'')\
.replace(u'</lg>', u'').replace(u'</q>', u'')\