forked from openlp/openlp
removed zip support for OpenSong importer
Fixes: https://launchpad.net/bugs/795027
This commit is contained in:
parent
822db59c4f
commit
bc5d2cce46
@ -28,7 +28,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from zipfile import ZipFile
|
|
||||||
|
|
||||||
from lxml import objectify
|
from lxml import objectify
|
||||||
from lxml.etree import Error, LxmlError
|
from lxml.etree import Error, LxmlError
|
||||||
@ -110,48 +109,13 @@ class OpenSongImport(SongImport):
|
|||||||
SongImport.__init__(self, manager, **kwargs)
|
SongImport.__init__(self, manager, **kwargs)
|
||||||
|
|
||||||
def do_import(self):
|
def do_import(self):
|
||||||
"""
|
self.import_wizard.progressBar.setMaximum(len(self.import_source))
|
||||||
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)
|
|
||||||
for filename in self.import_source:
|
for filename in self.import_source:
|
||||||
if self.stop_import_flag:
|
if self.stop_import_flag:
|
||||||
return
|
return
|
||||||
ext = os.path.splitext(filename)[1]
|
song_file = open(filename)
|
||||||
if ext.lower() == u'.zip':
|
self.do_import_file(song_file)
|
||||||
log.debug(u'Zipfile found %s', filename)
|
song_file.close()
|
||||||
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()
|
|
||||||
|
|
||||||
def do_import_file(self, file):
|
def do_import_file(self, file):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user