forked from openlp/openlp
OpenSong fixes bug 759586
This commit is contained in:
parent
504a471491
commit
5bc0c27970
@ -32,6 +32,7 @@ from lxml.etree import Error, LxmlError
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from openlp.core.ui.wizard import WizardStrings
|
from openlp.core.ui.wizard import WizardStrings
|
||||||
|
from openlp.plugins.songs.lib import VerseType
|
||||||
from openlp.plugins.songs.lib.songimport import SongImport
|
from openlp.plugins.songs.lib.songimport import SongImport
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -209,7 +210,10 @@ class OpenSongImport(SongImport):
|
|||||||
verse_num = u'1'
|
verse_num = u'1'
|
||||||
# for the case where song has several sections with same marker
|
# for the case where song has several sections with same marker
|
||||||
inst = 1
|
inst = 1
|
||||||
lyrics = unicode(root.lyrics)
|
if u'lyrics' in fields:
|
||||||
|
lyrics = unicode(root.lyrics)
|
||||||
|
else:
|
||||||
|
lyrics = u''
|
||||||
for this_line in lyrics.split(u'\n'):
|
for this_line in lyrics.split(u'\n'):
|
||||||
# remove comments
|
# remove comments
|
||||||
semicolon = this_line.find(u';')
|
semicolon = this_line.find(u';')
|
||||||
@ -230,7 +234,7 @@ class OpenSongImport(SongImport):
|
|||||||
# have we got any digits?
|
# have we got any digits?
|
||||||
# If so, verse number is everything from the digits
|
# If so, verse number is everything from the digits
|
||||||
# to the end (even if there are some alpha chars on the end)
|
# to the end (even if there are some alpha chars on the end)
|
||||||
match = re.match(u'(.*)(\d+.*)', content)
|
match = re.match(u'([A-Za-z]*)(\d+.*)', content)
|
||||||
if match is not None:
|
if match is not None:
|
||||||
verse_tag = match.group(1)
|
verse_tag = match.group(1)
|
||||||
verse_num = match.group(2)
|
verse_num = match.group(2)
|
||||||
@ -239,12 +243,13 @@ class OpenSongImport(SongImport):
|
|||||||
# the verse tag
|
# the verse tag
|
||||||
verse_tag = content
|
verse_tag = content
|
||||||
verse_num = u'1'
|
verse_num = u'1'
|
||||||
|
verse_index = VerseType.from_loose_input(verse_tag)
|
||||||
|
verse_tag = VerseType.Tags[verse_index]
|
||||||
inst = 1
|
inst = 1
|
||||||
if [verse_tag, verse_num, inst] in our_verse_order \
|
if [verse_tag, verse_num, inst] in our_verse_order \
|
||||||
and verses.has_key(verse_tag) \
|
and verses.has_key(verse_tag) \
|
||||||
and verses[verse_tag].has_key(verse_num):
|
and verses[verse_tag].has_key(verse_num):
|
||||||
inst = len(verses[verse_tag][verse_num])+1
|
inst = len(verses[verse_tag][verse_num])+1
|
||||||
our_verse_order.append([verse_tag, verse_num, inst])
|
|
||||||
continue
|
continue
|
||||||
# number at start of line.. it's verse number
|
# number at start of line.. it's verse number
|
||||||
if this_line[0].isdigit():
|
if this_line[0].isdigit():
|
||||||
@ -257,6 +262,7 @@ class OpenSongImport(SongImport):
|
|||||||
verses[verse_tag][verse_num] = {}
|
verses[verse_tag][verse_num] = {}
|
||||||
if not verses[verse_tag][verse_num].has_key(inst):
|
if not verses[verse_tag][verse_num].has_key(inst):
|
||||||
verses[verse_tag][verse_num][inst] = []
|
verses[verse_tag][verse_num][inst] = []
|
||||||
|
our_verse_order.append([verse_tag, verse_num, inst])
|
||||||
# Tidy text and remove the ____s from extended words
|
# Tidy text and remove the ____s from extended words
|
||||||
this_line = self.tidy_text(this_line)
|
this_line = self.tidy_text(this_line)
|
||||||
this_line = this_line.replace(u'_', u'')
|
this_line = this_line.replace(u'_', u'')
|
||||||
@ -268,6 +274,8 @@ class OpenSongImport(SongImport):
|
|||||||
verse_def = u'%s%s' % (verse_tag, verse_num)
|
verse_def = u'%s%s' % (verse_tag, verse_num)
|
||||||
lines = u'\n'.join(verses[verse_tag][verse_num][inst])
|
lines = u'\n'.join(verses[verse_tag][verse_num][inst])
|
||||||
self.add_verse(lines, verse_def)
|
self.add_verse(lines, verse_def)
|
||||||
|
if not self.verses:
|
||||||
|
self.add_verse('')
|
||||||
# figure out the presentation order, if present
|
# figure out the presentation order, if present
|
||||||
if u'presentation' in fields and root.presentation != u'':
|
if u'presentation' in fields and root.presentation != u'':
|
||||||
order = unicode(root.presentation)
|
order = unicode(root.presentation)
|
||||||
|
Loading…
Reference in New Issue
Block a user