diff --git a/openlp/plugins/songs/lib/opensongimport.py b/openlp/plugins/songs/lib/opensongimport.py index baaec12e7..6748d5a8a 100644 --- a/openlp/plugins/songs/lib/opensongimport.py +++ b/openlp/plugins/songs/lib/opensongimport.py @@ -119,7 +119,16 @@ class OpenSongImport(SongImport): import will not be committed to the database (useful for test scripts). """ success = False - self.import_wizard.importProgressBar.setMaximum(len(self.filenames)) + numfiles = 0 + for filename in self.filenames: + ext = os.path.splitext(filename)[1] + if ext.lower() == u'.zip': + z = ZipFile(filename, u'r') + numfiles += len(z.infolist()) + else: + numfiles += 1 + log.debug("Total number of files: %d", numfiles) + self.import_wizard.importProgressBar.setMaximum(numfiles) for filename in self.filenames: if self.stop_import_flag: break diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 5a4033280..e049740cc 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -258,6 +258,7 @@ class SongImport(QtCore.QObject): + '@' + self.alternate_title song.song_number = self.song_number song.search_lyrics = u'' + verses_changed_to_other = [] sxml = SongXMLBuilder() for (versetag, versetext) in self.verses: if versetag[0] == u'C': @@ -273,10 +274,16 @@ class SongImport(QtCore.QObject): elif versetag[0] == u'E': versetype = VerseType.to_string(VerseType.Ending) else: + verses_changed_to_other.append(versetag) versetype = VerseType.to_string(VerseType.Other) + print "Versetype", versetype sxml.add_verse_to_lyrics(versetype, versetag[1:], versetext) song.search_lyrics += u' ' + self.remove_punctuation(versetext) + print verses_changed_to_other song.lyrics = unicode(sxml.extract_xml(), u'utf-8') + for tag in verses_changed_to_other: + pass + # xxx sort out the "other" verses song.verse_order = u' '.join(self.verse_order_list) song.copyright = self.copyright song.comments = self.comments diff --git a/openlp/plugins/songs/lib/test/test_opensongimport.py b/openlp/plugins/songs/lib/test/test_opensongimport.py index b503c65c5..8bede1bbf 100644 --- a/openlp/plugins/songs/lib/test/test_opensongimport.py +++ b/openlp/plugins/songs/lib/test/test_opensongimport.py @@ -48,7 +48,7 @@ def test(): manager = Manager(u'songs', init_schema) o = OpenSongImport(manager, filenames=[u'test.opensong']) o.import_wizard = wizard_stub() - o.commit = False + o.commit = True o.do_import() o.print_song() assert o.copyright == u'2010 Martin Thompson'