← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol/openlp/bug-795027 into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol/openlp/bug-795027 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #795027 in OpenLP: "Cannot import zipped OpenSong songs"
  https://bugs.launchpad.net/openlp/+bug/795027

For more details, see:
https://code.launchpad.net/~googol/openlp/bug-795027/+merge/68122

Hello,

I removed the ZIP support for the OpenSong importer. This is due to a bug in it (which nobody wanted to fix). Furthermore, none of the other importers has the ability to import the zipped files. See bug #795027.
-- 
https://code.launchpad.net/~googol/openlp/bug-795027/+merge/68122
Your team OpenLP Core is requested to review the proposed merge of lp:~googol/openlp/bug-795027 into lp:openlp.
=== modified file 'openlp/plugins/songs/lib/opensongimport.py'
--- openlp/plugins/songs/lib/opensongimport.py	2011-06-12 16:02:52 +0000
+++ openlp/plugins/songs/lib/opensongimport.py	2011-07-15 18:22:24 +0000
@@ -28,7 +28,6 @@
 import logging
 import os
 import re
-from zipfile import ZipFile
 
 from lxml import objectify
 from lxml.etree import Error, LxmlError
@@ -110,48 +109,13 @@
         SongImport.__init__(self, manager, **kwargs)
 
     def do_import(self):
-        """
-        Import either each of the files in self.import_source - each element of
-        which can be either a single opensong file, or a zipfile containing
-        multiple opensong files.
-        """
-        numfiles = 0
-        for filename in self.import_source:
-            ext = os.path.splitext(filename)[1]
-            if ext.lower() == u'.zip':
-                z = ZipFile(filename, u'r')
-                numfiles += len(z.infolist())
-                z.close()
-            else:
-                numfiles += 1
-        log.debug(u'Total number of files: %d', numfiles)
-        self.import_wizard.progressBar.setMaximum(numfiles)
+        self.import_wizard.progressBar.setMaximum(len(self.import_source))
         for filename in self.import_source:
             if self.stop_import_flag:
                 return
-            ext = os.path.splitext(filename)[1]
-            if ext.lower() == u'.zip':
-                log.debug(u'Zipfile found %s', filename)
-                z = ZipFile(filename, u'r')
-                for song in z.infolist():
-                    if self.stop_import_flag:
-                        z.close()
-                        return
-                    parts = os.path.split(song.filename)
-                    if parts[-1] == u'':
-                        # No final part => directory
-                        continue
-                    log.info(u'Zip importing %s', parts[-1])
-                    song_file = z.open(song)
-                    self.do_import_file(song_file)
-                    song_file.close()
-                z.close()
-            else:
-                # not a zipfile
-                log.info(u'Direct import %s', filename)
-                song_file = open(filename)
-                self.do_import_file(song_file)
-                song_file.close()
+            song_file = open(filename)
+            self.do_import_file(song_file)
+            song_file.close()
 
     def do_import_file(self, file):
         """


Follow ups