only try to import a database when it is a v1 database, clean ups

This commit is contained in:
Andreas Preikschat 2011-04-15 16:10:31 +02:00
parent 342a5d8e84
commit 237cabfeff
3 changed files with 58 additions and 57 deletions

View File

@ -459,10 +459,7 @@ class SongImportForm(OpenLPWizard):
""" """
Return a list of file from the listbox Return a list of file from the listbox
""" """
files = [] return [unicode(listbox.item(i).text()) for i in range(listbox.count())]
for row in range(0, listbox.count()):
files.append(unicode(listbox.item(row).text()))
return files
def removeSelectedItems(self, listbox): def removeSelectedItems(self, listbox):
""" """

View File

@ -61,10 +61,12 @@ class OpenLP1SongImport(SongImport):
""" """
Run the import for an openlp.org 1.x song database. Run the import for an openlp.org 1.x song database.
""" """
# Connect to the database if not self.import_source.endswith(u'.olp'):
return False
encoding = self.get_encoding() encoding = self.get_encoding()
if not encoding: if not encoding:
return False return False
# Connect to the database
connection = sqlite.connect(self.import_source, mode=0444, connection = sqlite.connect(self.import_source, mode=0444,
encoding=(encoding, 'replace')) encoding=(encoding, 'replace'))
cursor = connection.cursor() cursor = connection.cursor()

View File

@ -78,11 +78,13 @@ class SongBeamerImport(SongImport):
""" """
Receive a single file or a list of files to import. Receive a single file or a list of files to import.
""" """
if isinstance(self.import_source, list): self.import_wizard.progressBar.setMaximum(len(self.import_source))
self.import_wizard.progressBar.setMaximum( if not isinstance(self.import_source, list):
len(self.import_source)) return False
for file in self.import_source: for file in self.import_source:
# TODO: check that it is a valid SongBeamer file # TODO: check that it is a valid SongBeamer file
if self.stop_import_flag:
return False
self.set_defaults() self.set_defaults()
self.current_verse = u'' self.current_verse = u''
self.current_verse_type = VerseType.Tags[VerseType.Verse] self.current_verse_type = VerseType.Tags[VerseType.Verse]