do not delete temporary tags when resetting the list; preparations

This commit is contained in:
Andreas Preikschat 2011-08-26 17:06:22 +02:00
parent 627b9429aa
commit 953ff87ff5
3 changed files with 14 additions and 3 deletions

View File

@ -49,6 +49,8 @@ class FormattingTags(object):
""" """
Resets the html_expands list. Resets the html_expands list.
""" """
temporary_tags = [tag for tag in FormattingTags.html_expands
if tag[u'temporary']]
FormattingTags.html_expands = [] FormattingTags.html_expands = []
base_tags = [] base_tags = []
# Append the base tags. # Append the base tags.
@ -131,6 +133,7 @@ class FormattingTags(object):
u'start tag': u'{br}', u'start html': u'<br>', u'end tag': u'', u'start tag': u'{br}', u'start html': u'<br>', u'end tag': u'',
u'end html': u'', u'protected': True, u'temporary': False}) u'end html': u'', u'protected': True, u'temporary': False})
FormattingTags.add_html_tags(base_tags) FormattingTags.add_html_tags(base_tags)
FormattingTags.add_html_tags(temporary_tags)
@staticmethod @staticmethod
def add_html_tags(tags): def add_html_tags(tags):

View File

@ -513,6 +513,9 @@ class SongMediaItem(MediaManagerItem):
if add_song and self.addSongFromService: if add_song and self.addSongFromService:
editId = self.openLyrics.xml_to_song(item.xml_version) editId = self.openLyrics.xml_to_song(item.xml_version)
self.onSearchTextButtonClick() self.onSearchTextButtonClick()
else:
# Make sure we temporary import formatting tags.
self.openLyrics.xml_to_song(item.xml_version, False)
# 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): def xml_to_song(self, xml, save_to_db=True):
""" """
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
@ -330,6 +330,10 @@ class OpenLyrics(object):
``xml`` ``xml``
The XML to parse (unicode). The XML to parse (unicode).
``save_to_db``
Switch to prevent storing songs to the database. Defaults to
``True``.
""" """
# No xml get out of here. # No xml get out of here.
if not xml: if not xml:
@ -356,6 +360,7 @@ class OpenLyrics(object):
self._process_songbooks(properties, song) self._process_songbooks(properties, song)
self._process_topics(properties, song) self._process_topics(properties, song)
clean_song(self.manager, song) clean_song(self.manager, song)
if save_to_db:
self.manager.save_object(song) self.manager.save_object(song)
return song.id return song.id