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