Ignore case when matching verse tags during SongBeamerImport

This commit is contained in:
Simon Hanna 2016-01-10 01:22:31 +01:00
parent 70e1f3926b
commit 9525453679
1 changed files with 27 additions and 27 deletions

View File

@ -36,28 +36,28 @@ log = logging.getLogger(__name__)
class SongBeamerTypes(object): class SongBeamerTypes(object):
MarkTypes = { MarkTypes = {
'Refrain': VerseType.tags[VerseType.Chorus], 'refrain': VerseType.tags[VerseType.Chorus],
'Chorus': VerseType.tags[VerseType.Chorus], 'chorus': VerseType.tags[VerseType.Chorus],
'Vers': VerseType.tags[VerseType.Verse], 'vers': VerseType.tags[VerseType.Verse],
'Verse': VerseType.tags[VerseType.Verse], 'verse': VerseType.tags[VerseType.Verse],
'Strophe': VerseType.tags[VerseType.Verse], 'strophe': VerseType.tags[VerseType.Verse],
'Intro': VerseType.tags[VerseType.Intro], 'intro': VerseType.tags[VerseType.Intro],
'Coda': VerseType.tags[VerseType.Ending], 'coda': VerseType.tags[VerseType.Ending],
'Ending': VerseType.tags[VerseType.Ending], 'ending': VerseType.tags[VerseType.Ending],
'Bridge': VerseType.tags[VerseType.Bridge], 'bridge': VerseType.tags[VerseType.Bridge],
'Interlude': VerseType.tags[VerseType.Bridge], 'interlude': VerseType.tags[VerseType.Bridge],
'Zwischenspiel': VerseType.tags[VerseType.Bridge], 'zwischenspiel': VerseType.tags[VerseType.Bridge],
'Pre-Chorus': VerseType.tags[VerseType.PreChorus], 'pre-chorus': VerseType.tags[VerseType.PreChorus],
'Pre-Refrain': VerseType.tags[VerseType.PreChorus], 'pre-refrain': VerseType.tags[VerseType.PreChorus],
'Misc': VerseType.tags[VerseType.Other], 'misc': VerseType.tags[VerseType.Other],
'Pre-Bridge': VerseType.tags[VerseType.Other], 'pre-bridge': VerseType.tags[VerseType.Other],
'Pre-Coda': VerseType.tags[VerseType.Other], 'pre-coda': VerseType.tags[VerseType.Other],
'Part': VerseType.tags[VerseType.Other], 'part': VerseType.tags[VerseType.Other],
'Teil': VerseType.tags[VerseType.Other], 'teil': VerseType.tags[VerseType.Other],
'Unbekannt': VerseType.tags[VerseType.Other], 'unbekannt': VerseType.tags[VerseType.Other],
'Unknown': VerseType.tags[VerseType.Other], 'unknown': VerseType.tags[VerseType.Other],
'Unbenannt': VerseType.tags[VerseType.Other], 'unbenannt': VerseType.tags[VerseType.Other],
'$$M=': VerseType.tags[VerseType.Other] '$$m=': VerseType.tags[VerseType.Other]
} }
@ -267,20 +267,20 @@ class SongBeamerImport(SongImport):
def check_verse_marks(self, line): def check_verse_marks(self, line):
""" """
Check and add the verse's MarkType. Returns ``True`` if the given linE contains a correct verse mark otherwise Check and add the verse's MarkType. Returns ``True`` if the given line contains a correct verse mark otherwise
``False``. ``False``.
:param line: The line to check for marks (unicode). :param line: The line to check for marks (unicode).
""" """
marks = line.split(' ') marks = line.split(' ')
if len(marks) <= 2 and marks[0] in SongBeamerTypes.MarkTypes: if len(marks) <= 2 and marks[0].lower() in SongBeamerTypes.MarkTypes:
self.current_verse_type = SongBeamerTypes.MarkTypes[marks[0]] self.current_verse_type = SongBeamerTypes.MarkTypes[marks[0].lower()]
if len(marks) == 2: if len(marks) == 2:
# If we have a digit, we append it to current_verse_type. # If we have a digit, we append it to current_verse_type.
if marks[1].isdigit(): if marks[1].isdigit():
self.current_verse_type += marks[1] self.current_verse_type += marks[1]
return True return True
elif marks[0].startswith('$$M='): # this verse-mark cannot be numbered elif marks[0].lower().startswith('$$m='): # this verse-mark cannot be numbered
self.current_verse_type = SongBeamerTypes.MarkTypes['$$M='] self.current_verse_type = SongBeamerTypes.MarkTypes['$$m=']
return True return True
return False return False