forked from openlp/openlp
(suggestion) added support for multiple slides
This commit is contained in:
parent
08dadb1d50
commit
5a4b91b37c
@ -226,7 +226,6 @@ class OpenLyrics(object):
|
|||||||
Convert the song to OpenLyrics Format.
|
Convert the song to OpenLyrics Format.
|
||||||
"""
|
"""
|
||||||
sxml = SongXML()
|
sxml = SongXML()
|
||||||
verse_list = sxml.get_verses(song.lyrics)
|
|
||||||
song_xml = objectify.fromstring(u'<song/>')
|
song_xml = objectify.fromstring(u'<song/>')
|
||||||
# Append the necessary meta data to the song.
|
# Append the necessary meta data to the song.
|
||||||
song_xml.set(u'xmlns', u'http://openlyrics.info/namespace/2009/song')
|
song_xml.set(u'xmlns', u'http://openlyrics.info/namespace/2009/song')
|
||||||
@ -268,17 +267,26 @@ class OpenLyrics(object):
|
|||||||
themes = etree.SubElement(properties, u'themes')
|
themes = etree.SubElement(properties, u'themes')
|
||||||
for topic in song.topics:
|
for topic in song.topics:
|
||||||
self._add_text_to_element(u'theme', themes, topic.name)
|
self._add_text_to_element(u'theme', themes, topic.name)
|
||||||
|
# Process the song's lyrics.
|
||||||
lyrics = etree.SubElement(song_xml, u'lyrics')
|
lyrics = etree.SubElement(song_xml, u'lyrics')
|
||||||
|
verse_list = sxml.get_verses(song.lyrics)
|
||||||
for verse in verse_list:
|
for verse in verse_list:
|
||||||
verse_tag = u'%s%s' % (
|
verse_tag = verse[0][u'type'][0].lower()
|
||||||
verse[0][u'type'][0].lower(), verse[0][u'label'])
|
verse_number = verse[0][u'label']
|
||||||
element = \
|
# Create a list with all "sub" verses.
|
||||||
self._add_text_to_element(u'verse', lyrics, None, verse_tag)
|
sub_verses = verse[1].split(u'[---]')
|
||||||
if verse[0].has_key(u'lang'):
|
for sub_index, sub_verse in enumerate(sub_verses):
|
||||||
element.set(u'lang', verse[0][u'lang'])
|
verse_def = verse_tag + verse_number
|
||||||
element = self._add_text_to_element(u'lines', element)
|
# We have more than one sub verse, consequently we need "v1a".
|
||||||
for line in unicode(verse[1]).split(u'\n'):
|
if len(sub_verses) > 1:
|
||||||
self._add_text_to_element(u'line', element, line)
|
verse_def += list(u'abcdefghijklmnopqrstuvwxyz')[sub_index]
|
||||||
|
element = \
|
||||||
|
self._add_text_to_element(u'verse', lyrics, None, verse_def)
|
||||||
|
if verse[0].has_key(u'lang'):
|
||||||
|
element.set(u'lang', verse[0][u'lang'])
|
||||||
|
element = self._add_text_to_element(u'lines', element)
|
||||||
|
for line in sub_verse.strip(u'\n').split(u'\n'):
|
||||||
|
self._add_text_to_element(u'line', element, line)
|
||||||
return self._extract_xml(song_xml)
|
return self._extract_xml(song_xml)
|
||||||
|
|
||||||
def xml_to_song(self, xml):
|
def xml_to_song(self, xml):
|
||||||
@ -446,6 +454,7 @@ class OpenLyrics(object):
|
|||||||
The song object.
|
The song object.
|
||||||
"""
|
"""
|
||||||
sxml = SongXML()
|
sxml = SongXML()
|
||||||
|
verses = {}
|
||||||
for verse in lyrics.verse:
|
for verse in lyrics.verse:
|
||||||
text = u''
|
text = u''
|
||||||
for lines in verse.lines:
|
for lines in verse.lines:
|
||||||
@ -465,7 +474,13 @@ class OpenLyrics(object):
|
|||||||
lang = None
|
lang = None
|
||||||
if self._get(verse, u'lang'):
|
if self._get(verse, u'lang'):
|
||||||
lang = self._get(verse, u'lang')
|
lang = self._get(verse, u'lang')
|
||||||
sxml.add_verse_to_lyrics(verse_tag, verse_number, text, lang)
|
if verses.has_key((verse_tag, verse_number, lang)):
|
||||||
|
verses[(verse_tag, verse_number, lang)] += u'\n[---]\n' + text
|
||||||
|
else:
|
||||||
|
verses[(verse_tag, verse_number, lang)] = text
|
||||||
|
for verse in verses:
|
||||||
|
sxml.add_verse_to_lyrics(
|
||||||
|
verse[0], verse[1], verses[verse], verse[2])
|
||||||
song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
|
song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
|
||||||
# Process verse order
|
# Process verse order
|
||||||
if hasattr(properties, u'verseOrder'):
|
if hasattr(properties, u'verseOrder'):
|
||||||
|
Loading…
Reference in New Issue
Block a user