forked from openlp/openlp
Reworked to return None rather than using exceptions as per Raoul's request
This commit is contained in:
parent
635b207fb0
commit
59c6e00bf1
|
@ -584,7 +584,7 @@ def strip_rtf(text, default_encoding=None):
|
||||||
if encoding:
|
if encoding:
|
||||||
out.append(chr(charcode).decode(encoding))
|
out.append(chr(charcode).decode(encoding))
|
||||||
else:
|
else:
|
||||||
raise Exception(u'user_canceled')
|
return None
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
failed = True
|
failed = True
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -180,13 +180,10 @@ class EasyWorshipSongImport(SongImport):
|
||||||
self.addAuthor(author_name.strip())
|
self.addAuthor(author_name.strip())
|
||||||
if words:
|
if words:
|
||||||
# Format the lyrics
|
# Format the lyrics
|
||||||
try:
|
words = strip_rtf(words, self.encoding)
|
||||||
words, self.encoding = strip_rtf(words, self.encoding)
|
if words is None:
|
||||||
except Exception as info:
|
return
|
||||||
if unicode(info) == u'user_canceled':
|
words, self.encoding = words
|
||||||
return
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
verse_type = VerseType.Tags[VerseType.Verse]
|
verse_type = VerseType.Tags[VerseType.Verse]
|
||||||
for verse in SLIDE_BREAK_REGEX.split(words):
|
for verse in SLIDE_BREAK_REGEX.split(words):
|
||||||
verse = verse.strip()
|
verse = verse.strip()
|
||||||
|
|
|
@ -109,14 +109,11 @@ class SongProImport(SongImport):
|
||||||
self.finish()
|
self.finish()
|
||||||
return
|
return
|
||||||
if u'rtf1' in text:
|
if u'rtf1' in text:
|
||||||
try:
|
text = strip_rtf(text, self.encoding)
|
||||||
text, self.encoding = strip_rtf(text, self.encoding)
|
if text is None:
|
||||||
text = text.rstrip()
|
return
|
||||||
except Exception as info:
|
text, self.encoding = text
|
||||||
if unicode(info) == u'user_canceled':
|
text = text.rstrip()
|
||||||
return
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
if not text:
|
if not text:
|
||||||
return
|
return
|
||||||
if tag == u'A':
|
if tag == u'A':
|
||||||
|
|
|
@ -150,14 +150,11 @@ class SundayPlusImport(SongImport):
|
||||||
verse_type = HOTKEY_TO_VERSE_TYPE[value]
|
verse_type = HOTKEY_TO_VERSE_TYPE[value]
|
||||||
if name == 'rtf':
|
if name == 'rtf':
|
||||||
value = self.unescape(value)
|
value = self.unescape(value)
|
||||||
try:
|
verse = strip_rtf(value, self.encoding)
|
||||||
verse, self.encoding = strip_rtf(value, self.encoding)
|
if verse is None:
|
||||||
lines = verse.strip().split('\n')
|
return
|
||||||
except Exception as info:
|
verse, self.encoding = verse
|
||||||
if unicode(info) == u'user_canceled':
|
lines = verse.strip().split('\n')
|
||||||
return
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
# If any line inside any verse contains CCLI or
|
# If any line inside any verse contains CCLI or
|
||||||
# only Public Domain, we treat this as special data:
|
# only Public Domain, we treat this as special data:
|
||||||
# we remove that line and add data to specific field.
|
# we remove that line and add data to specific field.
|
||||||
|
|
Loading…
Reference in New Issue