forked from openlp/openlp
clean ups
This commit is contained in:
parent
16fa78bbe3
commit
757933c448
|
@ -740,9 +740,7 @@ class SongImportForm(OpenLPWizard):
|
|||
importer = self.plugin.importSongs(SongFormat.FoilPresenter,
|
||||
filenames=self.getListOfFiles(self.foilPresenterFileListWidget)
|
||||
)
|
||||
test = importer.do_import()
|
||||
if isinstance(test, bool):
|
||||
raise received_boolean
|
||||
importer.do_import()
|
||||
if importer.stop_import_flag:
|
||||
self.progressLabel.setText(translate('SongsPlugin.SongImportForm',
|
||||
'Song import has been cancelled.'))
|
||||
|
|
|
@ -143,12 +143,12 @@ class EasyWorshipSongImport(SongImport):
|
|||
# Open the DB and MB files if they exist
|
||||
import_source_mb = self.import_source.replace('.DB', '.MB')
|
||||
if not os.path.isfile(self.import_source):
|
||||
return False
|
||||
return
|
||||
if not os.path.isfile(import_source_mb):
|
||||
return False
|
||||
return
|
||||
db_size = os.path.getsize(self.import_source)
|
||||
if db_size < 0x800:
|
||||
return False
|
||||
return
|
||||
db_file = open(self.import_source, 'rb')
|
||||
self.memo_file = open(import_source_mb, 'rb')
|
||||
# Don't accept files that are clearly not paradox files
|
||||
|
@ -157,7 +157,7 @@ class EasyWorshipSongImport(SongImport):
|
|||
if header_size != 0x800 or block_size < 1 or block_size > 4:
|
||||
db_file.close()
|
||||
self.memo_file.close()
|
||||
return False
|
||||
return
|
||||
# Take a stab at how text is encoded
|
||||
self.encoding = u'cp1252'
|
||||
db_file.seek(106)
|
||||
|
@ -184,7 +184,7 @@ class EasyWorshipSongImport(SongImport):
|
|||
self.encoding = u'cp874'
|
||||
self.encoding = retrieve_windows_encoding(self.encoding)
|
||||
if not self.encoding:
|
||||
return False
|
||||
return
|
||||
# There does not appear to be a _reliable_ way of getting the number
|
||||
# of songs/records, so let's use file blocks for measuring progress.
|
||||
total_blocks = (db_size - header_size) / (block_size * 1024)
|
||||
|
@ -242,7 +242,7 @@ class EasyWorshipSongImport(SongImport):
|
|||
if copy:
|
||||
self.copyright += u', '
|
||||
self.copyright += \
|
||||
unicode(translate('SongsPlugin.ImportWizardForm',
|
||||
unicode(translate('SongsPlugin.EasyWorshipSongImport',
|
||||
'Administered by %s')) % admin
|
||||
if ccli:
|
||||
self.ccli_number = ccli
|
||||
|
@ -269,7 +269,7 @@ class EasyWorshipSongImport(SongImport):
|
|||
self.memo_file.close()
|
||||
|
||||
def find_field(self, field_name):
|
||||
return [i for i, x in enumerate(self.field_descs) \
|
||||
return [i for i, x in enumerate(self.field_descs)
|
||||
if x.name == field_name][0]
|
||||
|
||||
def set_record_struct(self, field_descs):
|
||||
|
|
|
@ -64,16 +64,14 @@ class OpenLP1SongImport(SongImport):
|
|||
"""
|
||||
if not self.import_source.endswith(u'.olp'):
|
||||
self.log_error(self.import_source,
|
||||
translate('SongsPlugin.OpenLP1SongImport', 'The file you '
|
||||
'were trying to import is not a valid openlp.org 1.x song '
|
||||
'database.'))
|
||||
translate('SongsPlugin.OpenLP1SongImport',
|
||||
'Not a valid openlp.org 1.x song database.'))
|
||||
return
|
||||
encoding = self.get_encoding()
|
||||
if not encoding:
|
||||
self.log_error(self.import_source,
|
||||
translate('SongsPlugin.OpenLP1SongImport', 'The file you '
|
||||
'were trying to import is not a valid openlp.org 1.x song '
|
||||
'database.'))
|
||||
translate('SongsPlugin.OpenLP1SongImport',
|
||||
'Not a valid openlp.org 1.x song database.'))
|
||||
return
|
||||
# Connect to the database
|
||||
connection = sqlite.connect(self.import_source, mode=0444,
|
||||
|
|
|
@ -102,8 +102,8 @@ class OpenLPSongImport(SongImport):
|
|||
"""
|
||||
if not self.import_source.endswith(u'.sqlite'):
|
||||
self.log_error(self.import_source,
|
||||
translate('SongsPlugin.OpenLPSongImport', 'The file you were '
|
||||
'trying to import is not a valid OpenLP 2.0 song database.'))
|
||||
translate('SongsPlugin.OpenLPSongImport',
|
||||
'Not a valid OpenLP 2.0 song database.'))
|
||||
return
|
||||
engine = create_engine(self.import_source)
|
||||
source_meta = MetaData()
|
||||
|
|
|
@ -255,7 +255,7 @@ class OpenSongImport(SongImport):
|
|||
lines = u'\n'.join(verses[verse_tag][verse_num][inst])
|
||||
self.add_verse(lines, verse_def)
|
||||
# figure out the presentation order, if present
|
||||
if u'presentation' in fields and root.presentation != u'':
|
||||
if u'presentation' in fields and root.presentation:
|
||||
order = unicode(root.presentation)
|
||||
# We make all the tags in the lyrics lower case, so match that here
|
||||
# and then split into a list on the whitespace
|
||||
|
@ -266,7 +266,7 @@ class OpenSongImport(SongImport):
|
|||
verse_tag = match.group(1)
|
||||
verse_num = match.group(2)
|
||||
if not len(verse_tag):
|
||||
verse_tag = u'v'
|
||||
verse_tag = VerseType.Tags[VerseType.Verse]
|
||||
else:
|
||||
# Assume it's no.1 if there are no digits
|
||||
verse_tag = verse_def
|
||||
|
|
|
@ -73,11 +73,6 @@ class SongBeamerImport(SongImport):
|
|||
Initialise the Song Beamer importer.
|
||||
"""
|
||||
SongImport.__init__(self, manager, **kwargs)
|
||||
self.log_error(u'/home/andreas/1.sng', u'aaaa')
|
||||
self.log_error(u'/home/andreas/4.sng', u'asdfsdfsadfds')
|
||||
self.log_error(u'/home/andreas/3.sng', u'asdf3q4')
|
||||
self.log_error(u'/home/andreas/2.sng', u'sadfasdf')
|
||||
self.log_error(u'/home/andreas/ä.sng', u'kqwjw32w3')
|
||||
|
||||
def do_import(self):
|
||||
"""
|
||||
|
@ -238,11 +233,12 @@ class SongBeamerImport(SongImport):
|
|||
pass
|
||||
elif tag_val[0] == u'#Rights':
|
||||
song_book_pub = tag_val[1]
|
||||
elif tag_val[0] == u'#Songbook':
|
||||
book_num = tag_val[1].split(' / ')
|
||||
self.song_book_name = book_num[0]
|
||||
if len(book_num) == book_num[1]:
|
||||
self.song_number = u''
|
||||
elif tag_val[0] == u'#Songbook' or tag_val[0] == u'#SongBook':
|
||||
book_data = tag_val[1].split(u'/')
|
||||
self.song_book_name = book_data[0].strip()
|
||||
if len(book_data) == 2:
|
||||
number = book_data[1].strip()
|
||||
self.song_number = number if number.isdigit() else u''
|
||||
elif tag_val[0] == u'#Speed':
|
||||
pass
|
||||
elif tag_val[0] == u'Tempo':
|
||||
|
|
|
@ -101,7 +101,6 @@ class SongShowPlusImport(SongImport):
|
|||
return
|
||||
self.import_wizard.progressBar.setMaximum(len(self.import_source))
|
||||
for file in self.import_source:
|
||||
author = u''
|
||||
self.sspVerseOrderList = []
|
||||
otherCount = 0
|
||||
otherList = {}
|
||||
|
|
|
@ -134,7 +134,7 @@ class WowImport(SongImport):
|
|||
songData.seek(3, os.SEEK_CUR)
|
||||
# Blocks are seperated by 2 bytes, skip them, but not if
|
||||
# this is the last block!
|
||||
if (block + 1) < no_of_blocks:
|
||||
if block + 1 < no_of_blocks:
|
||||
songData.seek(2, os.SEEK_CUR)
|
||||
self.add_verse(block_text, block_type)
|
||||
# Now to extract the author
|
||||
|
|
Loading…
Reference in New Issue