forked from openlp/openlp
refurbished, added self._success = False to exceptions
This commit is contained in:
parent
0c38bccd45
commit
1c1e66bba8
@ -98,7 +98,8 @@ class EasiSlidesImport(SongImport):
|
|||||||
try:
|
try:
|
||||||
self.title = unicode(song.Title1).strip()
|
self.title = unicode(song.Title1).strip()
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.exception(u'Title1 unicode decode error')
|
log.exception(u'Unicode decode error while decoding Title1')
|
||||||
|
self._success = False
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
log.exception(u'no Title1')
|
log.exception(u'no Title1')
|
||||||
self._success = False
|
self._success = False
|
||||||
@ -107,7 +108,8 @@ class EasiSlidesImport(SongImport):
|
|||||||
try:
|
try:
|
||||||
self.alternate_title = unicode(song.Title2).strip()
|
self.alternate_title = unicode(song.Title2).strip()
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.exception(u'Title2 unicode decode error')
|
log.exception(u'Unicode decode error while decoding Title2')
|
||||||
|
self._success = False
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -117,7 +119,8 @@ class EasiSlidesImport(SongImport):
|
|||||||
if number != 0:
|
if number != 0:
|
||||||
self.song_number = number
|
self.song_number = number
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.exception(u'SongNumber unicode decode error')
|
log.exception(u'Unicode decode error while decoding SongNumber')
|
||||||
|
self._success = False
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -129,7 +132,8 @@ class EasiSlidesImport(SongImport):
|
|||||||
if len(author) > 0:
|
if len(author) > 0:
|
||||||
self.authors.append(author)
|
self.authors.append(author)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.exception(u'Writer unicode decode error')
|
log.exception(u'Unicode decode error while decoding Writer')
|
||||||
|
self._success = False
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -138,19 +142,22 @@ class EasiSlidesImport(SongImport):
|
|||||||
try:
|
try:
|
||||||
copyright.append(unicode(song.Copyright).strip())
|
copyright.append(unicode(song.Copyright).strip())
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.exception(u'Copyright unicode decode error')
|
log.exception(u'Unicode decode error while decoding Copyright')
|
||||||
|
self._success = False
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
copyright.append(unicode(song.LicenceAdmin1).strip())
|
copyright.append(unicode(song.LicenceAdmin1).strip())
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.exception(u'LicenceAdmin1 unicode decode error')
|
log.exception(u'Unicode decode error while decoding LicenceAdmin1')
|
||||||
|
self._success = False
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
copyright.append(unicode(song.LicenceAdmin2).strip())
|
copyright.append(unicode(song.LicenceAdmin2).strip())
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.exception(u'LicenceAdmin2 unicode decode error')
|
log.exception(u'Unicode decode error while decoding LicenceAdmin2')
|
||||||
|
self._success = False
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
self.add_copyright(u' '.join(copyright))
|
self.add_copyright(u' '.join(copyright))
|
||||||
@ -159,7 +166,8 @@ class EasiSlidesImport(SongImport):
|
|||||||
try:
|
try:
|
||||||
self.song_book_name = unicode(song.BookReference).strip()
|
self.song_book_name = unicode(song.BookReference).strip()
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.exception(u'BookReference unicode decode error')
|
log.exception(u'Unicode decode error while decoding BookReference')
|
||||||
|
self._success = False
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -167,7 +175,8 @@ class EasiSlidesImport(SongImport):
|
|||||||
try:
|
try:
|
||||||
lyrics = unicode(song.Contents).strip()
|
lyrics = unicode(song.Contents).strip()
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.exception(u'Contents unicode decode error')
|
log.exception(u'Unicode decode error while decoding Contents')
|
||||||
|
self._success = False
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
log.exception(u'no Contents')
|
log.exception(u'no Contents')
|
||||||
self._success = False
|
self._success = False
|
||||||
@ -207,12 +216,12 @@ class EasiSlidesImport(SongImport):
|
|||||||
regionlines[regionlines.keys()[0]] > 1)
|
regionlines[regionlines.keys()[0]] > 1)
|
||||||
|
|
||||||
MarkTypes = {
|
MarkTypes = {
|
||||||
u'chorus': u'C',
|
u'CHORUS': u'C',
|
||||||
u'verse': u'V',
|
u'VERSE': u'V',
|
||||||
u'intro': u'I',
|
u'INTRO': u'I',
|
||||||
u'ending': u'E',
|
u'ENDING': u'E',
|
||||||
u'bridge': u'B',
|
u'BRIDGE': u'B',
|
||||||
u'prechorus': u'P'}
|
u'PRECHORUS': u'P'}
|
||||||
|
|
||||||
verses = {}
|
verses = {}
|
||||||
# list as [region, versetype, versenum, instance]
|
# list as [region, versetype, versenum, instance]
|
||||||
@ -221,9 +230,9 @@ class EasiSlidesImport(SongImport):
|
|||||||
reg = defaultregion
|
reg = defaultregion
|
||||||
verses[reg] = {}
|
verses[reg] = {}
|
||||||
# instance differentiates occurrences of same verse tag
|
# instance differentiates occurrences of same verse tag
|
||||||
inst = 1
|
|
||||||
vt = u'V'
|
vt = u'V'
|
||||||
vn = u'1'
|
vn = u'1'
|
||||||
|
inst = 1
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
@ -237,47 +246,39 @@ class EasiSlidesImport(SongImport):
|
|||||||
else:
|
else:
|
||||||
# separators are not used, so empty line starts a new verse
|
# separators are not used, so empty line starts a new verse
|
||||||
vt = u'V'
|
vt = u'V'
|
||||||
|
|
||||||
if verses[reg].has_key(vt):
|
if verses[reg].has_key(vt):
|
||||||
vn = len(verses[reg][vt].keys())+1
|
vn = len(verses[reg][vt].keys())+1
|
||||||
else:
|
else:
|
||||||
vn = u'1'
|
vn = u'1'
|
||||||
|
|
||||||
inst = 1
|
inst = 1
|
||||||
continue
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif line[0:7] == u'[region':
|
elif line[0:7] == u'[region':
|
||||||
reg = self._extractRegion(line)
|
reg = self._extractRegion(line)
|
||||||
if not verses.has_key(reg):
|
if not verses.has_key(reg):
|
||||||
verses[reg] = {}
|
verses[reg] = {}
|
||||||
|
if not regionsInVerses:
|
||||||
|
vt = u'V'
|
||||||
|
vn = u'1'
|
||||||
|
inst = 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif line[0] == u'[':
|
elif line[0] == u'[':
|
||||||
# this is a normal section marker
|
# this is a normal section marker
|
||||||
# drop the square brackets
|
marker = line[1:line.find(u']')].upper()
|
||||||
right_bracket = line.find(u']')
|
vn = u'1'
|
||||||
marker = line[1:right_bracket].upper()
|
|
||||||
# have we got any digits?
|
# have we got any digits?
|
||||||
# If so, versenumber is everything from the digits to the end
|
# If so, versenumber is everything from the digits to the end
|
||||||
match = re.match(u'(.*)(\d+.*)', marker)
|
match = re.match(u'(.*)(\d+.*)', marker)
|
||||||
if match is not None:
|
if match:
|
||||||
vt = match.group(1).strip()
|
marker = match.group(1).strip()
|
||||||
vn = match.group(2)
|
vn = match.group(2)
|
||||||
if MarkTypes.has_key(vt.lower()):
|
if len(marker) == 0:
|
||||||
vt = MarkTypes[vt.lower()]
|
vt = u'V'
|
||||||
else:
|
elif MarkTypes.has_key(marker):
|
||||||
vt = u'O'
|
vt = MarkTypes[marker]
|
||||||
else:
|
else:
|
||||||
if MarkTypes.has_key(marker.lower()):
|
vt = u'O'
|
||||||
vt = MarkTypes[marker.lower()]
|
|
||||||
else:
|
|
||||||
vt = u'O'
|
|
||||||
vn = u'1'
|
|
||||||
|
|
||||||
if regionsInVerses:
|
if regionsInVerses:
|
||||||
region = defaultregion
|
region = defaultregion
|
||||||
|
|
||||||
inst = 1
|
inst = 1
|
||||||
if self._listHas(verses, [reg, vt, vn, inst]):
|
if self._listHas(verses, [reg, vt, vn, inst]):
|
||||||
inst = len(verses[reg][vt][vn])+1
|
inst = len(verses[reg][vt][vn])+1
|
||||||
@ -286,8 +287,6 @@ class EasiSlidesImport(SongImport):
|
|||||||
if not [reg, vt, vn, inst] in our_verse_order:
|
if not [reg, vt, vn, inst] in our_verse_order:
|
||||||
our_verse_order.append([reg, vt, vn, inst])
|
our_verse_order.append([reg, vt, vn, inst])
|
||||||
|
|
||||||
# We have versetype/number data, if it was there, now
|
|
||||||
# we parse text
|
|
||||||
if not verses[reg].has_key(vt):
|
if not verses[reg].has_key(vt):
|
||||||
verses[reg][vt] = {}
|
verses[reg][vt] = {}
|
||||||
if not verses[reg][vt].has_key(vn):
|
if not verses[reg][vt].has_key(vn):
|
||||||
@ -303,19 +302,12 @@ class EasiSlidesImport(SongImport):
|
|||||||
|
|
||||||
# we use our_verse_order to ensure, we insert lyrics in the same order
|
# we use our_verse_order to ensure, we insert lyrics in the same order
|
||||||
# as these appeared originally in the file
|
# as these appeared originally in the file
|
||||||
|
for [reg, vt, vn, inst] in our_verse_order:
|
||||||
for tag in our_verse_order:
|
if self._listHas(verses, [reg, vt, vn, inst]):
|
||||||
reg = tag[0]
|
versetag = u'%s%s' % (vt, vn)
|
||||||
vt = tag[1]
|
versetags.append(versetag)
|
||||||
vn = tag[2]
|
lines = u'\n'.join(verses[reg][vt][vn][inst])
|
||||||
inst = tag[3]
|
self.verses.append([versetag, lines])
|
||||||
|
|
||||||
if not self._listHas(verses, [reg, vt, vn, inst]):
|
|
||||||
continue
|
|
||||||
versetag = u'%s%s' % (vt, vn)
|
|
||||||
versetags.append(versetag)
|
|
||||||
lines = u'\n'.join(verses[reg][vt][vn][inst])
|
|
||||||
self.verses.append([versetag, lines])
|
|
||||||
|
|
||||||
SeqTypes = {
|
SeqTypes = {
|
||||||
u'p': u'P1',
|
u'p': u'P1',
|
||||||
@ -332,20 +324,20 @@ class EasiSlidesImport(SongImport):
|
|||||||
if len(tag) == 0:
|
if len(tag) == 0:
|
||||||
continue
|
continue
|
||||||
elif tag[0].isdigit():
|
elif tag[0].isdigit():
|
||||||
# it's a verse if it has no prefix, but has a number
|
|
||||||
tag = u'V' + tag
|
tag = u'V' + tag
|
||||||
elif SeqTypes.has_key(tag.lower()):
|
elif SeqTypes.has_key(tag.lower()):
|
||||||
tag = SeqTypes[tag.lower()]
|
tag = SeqTypes[tag.lower()]
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not tag in versetags:
|
if tag in versetags:
|
||||||
|
self.verse_order_list.append(tag)
|
||||||
|
else:
|
||||||
log.info(u'Got order item %s, which is not in versetags,'
|
log.info(u'Got order item %s, which is not in versetags,'
|
||||||
u'dropping item from presentation order', tag)
|
u'dropping item from presentation order', tag)
|
||||||
else:
|
|
||||||
self.verse_order_list.append(tag)
|
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.exception(u'Sequence unicode decode error')
|
log.exception(u'Unicode decode error while decoding Sequence')
|
||||||
|
self._success = False
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user