From e2124942ccc42bb482330283e11c4cf424d096f7 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 11 Jan 2011 17:49:53 +0100 Subject: [PATCH 1/2] clean ups --- openlp/plugins/songs/lib/mediaitem.py | 2 +- openlp/plugins/songs/lib/openlyricsimport.py | 2 +- openlp/plugins/songs/lib/xml.py | 17 +++++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 5d6544346..858d7bbf2 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -448,7 +448,7 @@ class SongMediaItem(MediaManagerItem): if self.addSongFromService: editId = self.openLyrics.xml_to_song(item.xml_version) # Update service with correct song id. - if editId != 0: + if editId is not None: Receiver.send_message(u'service_item_update', u'%s:%s' % (editId, item._uuid)) diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index f11ba7642..c4610dfc0 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -70,7 +70,7 @@ class OpenLyricsImport(SongImport): parser = etree.XMLParser(remove_blank_text=True) file = etree.parse(file_path, parser) xml = unicode(etree.tostring(file)) - if self.openLyrics.xml_to_song(xml) == 0: + if self.openLyrics.xml_to_song(xml) is None: log.debug(u'File could not be imported: %s' % file_path) # Importing this song failed! For now we stop import. return False diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 588ff923c..cbe313212 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -143,10 +143,11 @@ class SongXML(object): class OpenLyrics(object): """ - This class represents the converter for OpenLyrics XML to/from a song. + This class represents the converter for OpenLyrics XML (version 0.7) + to/from a song. As OpenLyrics has a rich set of different features, we cannot support them - all. The following features are supported by the :class:`OpenLyricsParser`:: + all. The following features are supported by the :class:`OpenLyrics`:: ** OpenLP does not support the attribute *type* and *lang*. @@ -203,7 +204,7 @@ class OpenLyrics(object): def __init__(self, manager): self.manager = manager - def song_to_xml(self, song, pretty_print=False): + def song_to_xml(self, song): """ Convert the song to OpenLyrics Format. """ @@ -253,7 +254,7 @@ class OpenLyrics(object): element = self._add_text_to_element(u'lines', element) for line in unicode(verse[1]).split(u'\n'): self._add_text_to_element(u'line', element, line) - return self._extract_xml(song_xml, pretty_print) + return self._extract_xml(song_xml) def xml_to_song(self, xml): """ @@ -266,7 +267,7 @@ class OpenLyrics(object): """ # No xml get out of here. if not xml: - return 0 + return None song = Song() if xml[:5] == u' Date: Wed, 12 Jan 2011 17:45:32 +0100 Subject: [PATCH 2/2] fix for merge --- openlp/plugins/songs/lib/mediaitem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 858d7bbf2..93e40f58a 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -448,7 +448,7 @@ class SongMediaItem(MediaManagerItem): if self.addSongFromService: editId = self.openLyrics.xml_to_song(item.xml_version) # Update service with correct song id. - if editId is not None: + if editId: Receiver.send_message(u'service_item_update', u'%s:%s' % (editId, item._uuid))