forked from openlp/openlp
Improved PowerSong import wizard validation
This commit is contained in:
parent
3483231a32
commit
31debbe238
@ -28,6 +28,7 @@
|
|||||||
The song import functions for OpenLP.
|
The song import functions for OpenLP.
|
||||||
"""
|
"""
|
||||||
import codecs
|
import codecs
|
||||||
|
import fnmatch
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -399,7 +400,8 @@ class SongImportForm(OpenLPWizard):
|
|||||||
return False
|
return False
|
||||||
elif source_format == SongFormat.PowerSong:
|
elif source_format == SongFormat.PowerSong:
|
||||||
if self.powerSongFilenameEdit.text().isEmpty() or \
|
if self.powerSongFilenameEdit.text().isEmpty() or \
|
||||||
not os.path.isdir(self.powerSongFilenameEdit.text()):
|
not self.isPowerSongFolder(
|
||||||
|
self.powerSongFilenameEdit.text()):
|
||||||
critical_error_message_box(UiStrings().NFdSs,
|
critical_error_message_box(UiStrings().NFdSs,
|
||||||
WizardStrings.YouSpecifyFolder % WizardStrings.PS)
|
WizardStrings.YouSpecifyFolder % WizardStrings.PS)
|
||||||
self.powerSongBrowseButton.setFocus()
|
self.powerSongBrowseButton.setFocus()
|
||||||
@ -482,6 +484,16 @@ class SongImportForm(OpenLPWizard):
|
|||||||
elif self.currentPage() == self.progressPage:
|
elif self.currentPage() == self.progressPage:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def isPowerSongFolder(self, dir):
|
||||||
|
"""
|
||||||
|
Checks if a folder is a PowerSong 1.0 folder
|
||||||
|
"""
|
||||||
|
if os.path.isdir(dir):
|
||||||
|
for file in os.listdir(dir):
|
||||||
|
if fnmatch.fnmatch(file, u'*.song'):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def getFiles(self, title, listbox, filters=u''):
|
def getFiles(self, title, listbox, filters=u''):
|
||||||
"""
|
"""
|
||||||
Opens a QFileDialog and writes the filenames to the given listbox.
|
Opens a QFileDialog and writes the filenames to the given listbox.
|
||||||
|
Loading…
Reference in New Issue
Block a user