forked from openlp/openlp
EasyWorship importer: some work to create more reasonable verse numbers if EW tags are missing or without numbers
This commit is contained in:
parent
4bf45ad2de
commit
3c0c9c5b78
@ -267,18 +267,18 @@ class EasyWorshipSongImport(SongImport):
|
||||
self.add_author(author_name.strip())
|
||||
if words:
|
||||
# Format the lyrics
|
||||
words = strip_rtf(words, self.encoding) # TODO: convert rtf instead of stripping?
|
||||
p = re.compile(r'\n *?\n[\n ]*') # at least two newlines, with zero or more space characters between them
|
||||
verse_type = VerseType.Tags[VerseType.Verse] # TODO!!!: use previous verse type....
|
||||
words = strip_rtf(words, self.encoding) # TODO: convert rtf to display tags?
|
||||
# regex: at least two newlines, with zero or more space characters between them
|
||||
p = re.compile(r'\n *?\n[\n ]*')
|
||||
verse_type = VerseType.Tags[VerseType.Verse]
|
||||
for verse in p.split(words):
|
||||
#for verse in words.split(u'\n\n'):
|
||||
# ew tags: verse, chorus, pre-chorus, bridge, tag, intro, ending, slide
|
||||
verse = verse.strip()
|
||||
if len(verse) == 0:
|
||||
continue
|
||||
verse_split = verse.split(u'\n', 1)
|
||||
first_line_is_tag = False
|
||||
for type in VerseType.Names+['tag', 'slide']: # doesnt cover tag, slide
|
||||
# ew tags: verse, chorus, pre-chorus, bridge, tag, intro, ending, slide
|
||||
for type in VerseType.Names+['tag', 'slide']:
|
||||
type = type.lower()
|
||||
ew_tag = verse_split[0].strip().lower()
|
||||
if ew_tag.startswith(type):
|
||||
@ -286,20 +286,24 @@ class EasyWorshipSongImport(SongImport):
|
||||
if type == 'tag' or type == 'slide':
|
||||
verse_type = VerseType.Tags[VerseType.Other]
|
||||
first_line_is_tag = True
|
||||
number_found = False
|
||||
if len(ew_tag) > len(type): # tag is followed by number and/or note
|
||||
p = re.compile(r'[0-9]+')
|
||||
m = re.search(p, ew_tag)
|
||||
if m:
|
||||
number = m.group()
|
||||
verse_type +=number
|
||||
number_found = True
|
||||
|
||||
p = re.compile(r'\(.*?\)')
|
||||
m = re.search(p, ew_tag)
|
||||
if m:
|
||||
self.comments += ew_tag+'\n'
|
||||
if not number_found:
|
||||
verse_type += '1'
|
||||
break
|
||||
self.add_verse(
|
||||
verse_split[-1].strip() if first_line_is_tag else verse, # TODO: hacky: -1
|
||||
verse_split[-1].strip() if first_line_is_tag else verse,
|
||||
verse_type)
|
||||
if len(self.comments) > 5:
|
||||
self.comments += unicode(translate('SongsPlugin.EasyWorshipSongImport',
|
||||
|
Loading…
Reference in New Issue
Block a user