forked from openlp/openlp
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:
commit
3719143f99
@ -170,6 +170,7 @@ class CCLIFileImport(SongImport):
|
|||||||
song_words = line[6:].strip()
|
song_words = line[6:].strip()
|
||||||
#Unhandled usr keywords:Type,Version,Admin,Themes,Keys
|
#Unhandled usr keywords:Type,Version,Admin,Themes,Keys
|
||||||
#Process Fields and words sections
|
#Process Fields and words sections
|
||||||
|
check_first_verse_line = False
|
||||||
field_list = song_fields.split(u'/t')
|
field_list = song_fields.split(u'/t')
|
||||||
words_list = song_words.split(u'/t')
|
words_list = song_words.split(u'/t')
|
||||||
for counter in range(0, len(field_list)):
|
for counter in range(0, len(field_list)):
|
||||||
@ -181,10 +182,25 @@ class CCLIFileImport(SongImport):
|
|||||||
verse_type = u'B'
|
verse_type = u'B'
|
||||||
else: #Other
|
else: #Other
|
||||||
verse_type = u'O'
|
verse_type = u'O'
|
||||||
|
check_first_verse_line = True
|
||||||
verse_text = unicode(words_list[counter])
|
verse_text = unicode(words_list[counter])
|
||||||
verse_text = verse_text.replace("/n", "\n")
|
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:
|
if len(verse_text) > 0:
|
||||||
self.add_verse(verse_text, verse_type)
|
self.add_verse(verse_text, verse_type)
|
||||||
|
check_first_verse_line = False
|
||||||
#Handle multiple authors
|
#Handle multiple authors
|
||||||
author_list = song_author.split(u'/')
|
author_list = song_author.split(u'/')
|
||||||
if len(author_list) < 2:
|
if len(author_list) < 2:
|
||||||
@ -233,6 +249,7 @@ class CCLIFileImport(SongImport):
|
|||||||
log.debug(u'TXT file text: %s', textList)
|
log.debug(u'TXT file text: %s', textList)
|
||||||
self.set_defaults()
|
self.set_defaults()
|
||||||
line_number = 0
|
line_number = 0
|
||||||
|
check_first_verse_line = False
|
||||||
verse_text = u''
|
verse_text = u''
|
||||||
song_comments = u''
|
song_comments = u''
|
||||||
song_copyright = u''
|
song_copyright = u''
|
||||||
@ -270,12 +287,28 @@ class CCLIFileImport(SongImport):
|
|||||||
elif verse_desc_parts[0].startswith(u'Br'):
|
elif verse_desc_parts[0].startswith(u'Br'):
|
||||||
verse_type = u'B'
|
verse_type = u'B'
|
||||||
else:
|
else:
|
||||||
|
#we need to analyse the next line for
|
||||||
|
#verse type, so set flag
|
||||||
verse_type = u'O'
|
verse_type = u'O'
|
||||||
|
check_first_verse_line = True
|
||||||
verse_number = verse_desc_parts[1]
|
verse_number = verse_desc_parts[1]
|
||||||
else:
|
else:
|
||||||
verse_type = u'O'
|
verse_type = u'O'
|
||||||
verse_number = 1
|
verse_number = 1
|
||||||
verse_start = True
|
verse_start = True
|
||||||
|
else:
|
||||||
|
#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:
|
else:
|
||||||
# We have verse content or the start of the
|
# We have verse content or the start of the
|
||||||
# last part. Add l so as to keep the CRLF
|
# last part. Add l so as to keep the CRLF
|
||||||
|
Loading…
Reference in New Issue
Block a user