Better handling of progress bar. Attempt to get 'other' type verses into database

This commit is contained in:
Martin Thompson 2010-09-12 21:31:23 +01:00
parent c25b0aa8ff
commit 062a88e2f2
3 changed files with 18 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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'