forked from openlp/openlp
Fixes bug1095699 by rasing an error when the user cancels the codepage selection dialog.
This commit is contained in:
parent
8840df2fb2
commit
635b207fb0
@ -581,7 +581,10 @@ def strip_rtf(text, default_encoding=None):
|
|||||||
try:
|
try:
|
||||||
encoding, default_encoding = get_encoding(font,
|
encoding, default_encoding = get_encoding(font,
|
||||||
font_table, default_encoding, failed=failed)
|
font_table, default_encoding, failed=failed)
|
||||||
out.append(chr(charcode).decode(encoding))
|
if encoding:
|
||||||
|
out.append(chr(charcode).decode(encoding))
|
||||||
|
else:
|
||||||
|
raise Exception(u'user_canceled')
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
failed = True
|
failed = True
|
||||||
else:
|
else:
|
||||||
|
@ -180,7 +180,13 @@ class EasyWorshipSongImport(SongImport):
|
|||||||
self.addAuthor(author_name.strip())
|
self.addAuthor(author_name.strip())
|
||||||
if words:
|
if words:
|
||||||
# Format the lyrics
|
# Format the lyrics
|
||||||
words, self.encoding = strip_rtf(words, self.encoding)
|
try:
|
||||||
|
words, self.encoding = strip_rtf(words, self.encoding)
|
||||||
|
except Exception as info:
|
||||||
|
if unicode(info) == u'user_canceled':
|
||||||
|
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,8 +109,14 @@ class SongProImport(SongImport):
|
|||||||
self.finish()
|
self.finish()
|
||||||
return
|
return
|
||||||
if u'rtf1' in text:
|
if u'rtf1' in text:
|
||||||
text, self.encoding = strip_rtf(text, self.encoding)
|
try:
|
||||||
text = text.rstrip()
|
text, self.encoding = strip_rtf(text, self.encoding)
|
||||||
|
text = text.rstrip()
|
||||||
|
except Exception as info:
|
||||||
|
if unicode(info) == u'user_canceled':
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
raise
|
||||||
if not text:
|
if not text:
|
||||||
return
|
return
|
||||||
if tag == u'A':
|
if tag == u'A':
|
||||||
|
@ -150,8 +150,14 @@ 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)
|
||||||
verse, self.encoding = strip_rtf(value, self.encoding)
|
try:
|
||||||
lines = verse.strip().split('\n')
|
verse, self.encoding = strip_rtf(value, self.encoding)
|
||||||
|
lines = verse.strip().split('\n')
|
||||||
|
except Exception as info:
|
||||||
|
if unicode(info) == u'user_canceled':
|
||||||
|
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
Block a user