Fixes unwanted text imported from some SongSelect files. SongSelect only has a few verse types available for verses and adds extra ones by setting the verse type to 'misc' and then including the actual type on the next line. In the case of a 'misc' type or unknown type, the next line is checked for a valid verse type. The fix has been made for both .txt and .usr file types.

bzr-revno: 1136
This commit is contained in:
Derek Scotney 2010-12-08 20:17:51 +00:00 committed by Tim Bentley
commit 3719143f99

View File

@ -170,6 +170,7 @@ class CCLIFileImport(SongImport):
song_words = line[6:].strip()
#Unhandled usr keywords:Type,Version,Admin,Themes,Keys
#Process Fields and words sections
check_first_verse_line = False
field_list = song_fields.split(u'/t')
words_list = song_words.split(u'/t')
for counter in range(0, len(field_list)):
@ -181,10 +182,25 @@ class CCLIFileImport(SongImport):
verse_type = u'B'
else: #Other
verse_type = u'O'
check_first_verse_line = True
verse_text = unicode(words_list[counter])
verse_text = verse_text.replace("/n", "\n")
verse_lines = verse_text.split(u'\n', 1)
if check_first_verse_line:
if verse_lines[0].startswith(u'(PRE-CHORUS'):
verse_type = u'P'
log.debug(u'USR verse PRE-CHORUS: %s', verse_lines[0] )
verse_text = verse_lines[1]
elif verse_lines[0].startswith(u'(BRIDGE'):
verse_type = u'B'
log.debug(u'USR verse BRIDGE')
verse_text = verse_lines[1]
elif verse_lines[0].startswith(u'('):
verse_type = u'O'
verse_text = verse_lines[1]
if len(verse_text) > 0:
self.add_verse(verse_text, verse_type)
check_first_verse_line = False
#Handle multiple authors
author_list = song_author.split(u'/')
if len(author_list) < 2:
@ -233,6 +249,7 @@ class CCLIFileImport(SongImport):
log.debug(u'TXT file text: %s', textList)
self.set_defaults()
line_number = 0
check_first_verse_line = False
verse_text = u''
song_comments = u''
song_copyright = u''
@ -270,16 +287,32 @@ class CCLIFileImport(SongImport):
elif verse_desc_parts[0].startswith(u'Br'):
verse_type = u'B'
else:
#we need to analyse the next line for
#verse type, so set flag
verse_type = u'O'
check_first_verse_line = True
verse_number = verse_desc_parts[1]
else:
verse_type = u'O'
verse_number = 1
verse_start = True
else:
# We have verse content or the start of the
# last part. Add l so as to keep the CRLF
verse_text = verse_text + line
#check first line for verse type
if check_first_verse_line:
if line.startswith(u'(PRE-CHORUS'):
verse_type = u'P'
elif line.startswith(u'(BRIDGE'):
verse_type = u'B'
# Handle all other misc types
elif line.startswith(u'('):
verse_type = u'O'
else:
verse_text = verse_text + line
check_first_verse_line = False
else:
# We have verse content or the start of the
# last part. Add l so as to keep the CRLF
verse_text = verse_text + line
else:
#line_number=2, copyright
if line_number == 2: