← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/OpenLyrics into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/OpenLyrics into lp:openlp.

Requested reviews:
  Tim Bentley (trb143)
  Jon Tibble (meths)

For more details, see:
https://code.launchpad.net/~googol-hush/openlp/OpenLyrics/+merge/46010

Hello!

Clean up from last merge:
- removed not needed pretty_print argument
- doc fix
- return None instead of 0
-- 
https://code.launchpad.net/~googol-hush/openlp/OpenLyrics/+merge/46010
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2011-01-10 10:21:39 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2011-01-12 17:01:19 +0000
@@ -448,7 +448,7 @@
                 if self.addSongFromService:
                     editId = self.openLyrics.xml_to_song(item.xml_version)
             # Update service with correct song id.
-            if editId != 0:
+            if editId:
                 Receiver.send_message(u'service_item_update',
                     u'%s:%s' % (editId, item._uuid))
 

=== modified file 'openlp/plugins/songs/lib/openlyricsimport.py'
--- openlp/plugins/songs/lib/openlyricsimport.py	2011-01-09 16:52:31 +0000
+++ openlp/plugins/songs/lib/openlyricsimport.py	2011-01-12 17:01:19 +0000
@@ -70,7 +70,7 @@
             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

=== modified file 'openlp/plugins/songs/lib/xml.py'
--- openlp/plugins/songs/lib/xml.py	2011-01-09 19:18:08 +0000
+++ openlp/plugins/songs/lib/xml.py	2011-01-12 17:01:19 +0000
@@ -143,10 +143,11 @@
 
 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`::
 
     *<authors>*
         OpenLP does not support the attribute *type* and *lang*.
@@ -203,7 +204,7 @@
     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 @@
             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 @@
         """
         # No xml get out of here.
         if not xml:
-            return 0
+            return None
         song = Song()
         if xml[:5] == u'<?xml':
             xml = xml[38:]
@@ -296,12 +297,12 @@
         parent.append(element)
         return element
 
-    def _extract_xml(self, xml, pretty_print):
+    def _extract_xml(self, xml):
         """
         Extract our newly created XML song.
         """
         return etree.tostring(xml, encoding=u'UTF-8',
-            xml_declaration=True, pretty_print=pretty_print)
+            xml_declaration=True)
 
     def _get(self, element, attribute):
         """
@@ -495,7 +496,7 @@
                             song.song_number = self._get(songbook, u'entry')
                     except AttributeError:
                         pass
-                    # We does only support one song book, so take the first one.
+                    # We only support one song book, so take the first one.
                     break
         except AttributeError:
             pass


Follow ups