changed 'switch' name

This commit is contained in:
Andreas Preikschat 2011-08-26 17:15:17 +02:00
parent 953ff87ff5
commit 407b342f45
2 changed files with 19 additions and 18 deletions

View File

@ -515,7 +515,7 @@ class SongMediaItem(MediaManagerItem):
self.onSearchTextButtonClick() self.onSearchTextButtonClick()
else: else:
# Make sure we temporary import formatting tags. # Make sure we temporary import formatting tags.
self.openLyrics.xml_to_song(item.xml_version, False) self.openLyrics.xml_to_song(item.xml_version, True)
# Update service with correct song id. # Update service with correct song id.
if editId: if editId:
Receiver.send_message(u'service_item_update', Receiver.send_message(u'service_item_update',

View File

@ -322,7 +322,7 @@ class OpenLyrics(object):
self._add_text_to_element(u'line', lines_element, line) self._add_text_to_element(u'line', lines_element, line)
return self._extract_xml(song_xml) return self._extract_xml(song_xml)
def xml_to_song(self, xml, save_to_db=True): def xml_to_song(self, xml, only_process_format_tags=False):
""" """
Create and save a song from OpenLyrics format xml to the database. Since Create and save a song from OpenLyrics format xml to the database. Since
we also export XML from external sources (e. g. OpenLyrics import), we we also export XML from external sources (e. g. OpenLyrics import), we
@ -331,9 +331,9 @@ class OpenLyrics(object):
``xml`` ``xml``
The XML to parse (unicode). The XML to parse (unicode).
``save_to_db`` ``only_process_format_tags``
Switch to prevent storing songs to the database. Defaults to Switch to skip processing the whole song and to prevent storing the
``True``. songs to the database. Defaults to ``False``.
""" """
# No xml get out of here. # No xml get out of here.
if not xml: if not xml:
@ -346,21 +346,22 @@ class OpenLyrics(object):
else: else:
return None return None
song = Song() song = Song()
# Values will be set when cleaning the song. if not only_process_format_tags:
song.search_lyrics = u'' # Values will be set when cleaning the song.
song.verse_order = u'' song.search_lyrics = u''
song.search_title = u'' song.verse_order = u''
self._process_copyright(properties, song) song.search_title = u''
self._process_cclinumber(properties, song) self._process_copyright(properties, song)
self._process_titles(properties, song) self._process_cclinumber(properties, song)
self._process_titles(properties, song)
# The verse order is processed with the lyrics! # The verse order is processed with the lyrics!
self._process_lyrics(properties, song_xml, song) self._process_lyrics(properties, song_xml, song)
self._process_comments(properties, song) if not only_process_format_tags:
self._process_authors(properties, song) self._process_comments(properties, song)
self._process_songbooks(properties, song) self._process_authors(properties, song)
self._process_topics(properties, song) self._process_songbooks(properties, song)
clean_song(self.manager, song) self._process_topics(properties, song)
if save_to_db: clean_song(self.manager, song)
self.manager.save_object(song) self.manager.save_object(song)
return song.id return song.id