openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #01214
[Merge] lp:~raoul-snyman/openlp/biblefixes into lp:openlp
Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/biblefixes into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
--
https://code.launchpad.net/~raoul-snyman/openlp/biblefixes/+merge/21756
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/bibles/forms/importwizardform.py'
--- openlp/plugins/bibles/forms/importwizardform.py 2010-03-14 14:36:48 +0000
+++ openlp/plugins/bibles/forms/importwizardform.py 2010-03-19 22:34:19 +0000
@@ -315,23 +315,23 @@
def performImport(self):
bible_type = self.field(u'source_format').toInt()[0]
- success = False
+ importer = None
if bible_type == BibleFormat.OSIS:
# Import an OSIS bible
- success = self.manager.import_bible(BibleFormat.OSIS,
+ importer = self.manager.import_bible(BibleFormat.OSIS,
name=unicode(self.field(u'license_version').toString()),
filename=unicode(self.field(u'osis_location').toString())
)
elif bible_type == BibleFormat.CSV:
# Import a CSV bible
- success = self.manager.import_bible(BibleFormat.CSV,
+ importer = self.manager.import_bible(BibleFormat.CSV,
name=unicode(self.field(u'license_version').toString()),
booksfile=self.field(u'csv_booksfile').toString(),
versefile=self.field(u'csv_versefile').toString()
)
elif bible_type == BibleFormat.OpenSong:
# Import an OpenSong bible
- success = self.manager.import_bible(BibleFormat.OpenSong,
+ importer = self.manager.import_bible(BibleFormat.OpenSong,
name=unicode(self.field(u'license_version').toString()),
filename=self.field(u'opensong_file').toString()
)
@@ -345,7 +345,7 @@
elif download_location == DownloadLocation.BibleGateway:
bible = self.web_bible_list[DownloadLocation.BibleGateway][
unicode(self.BibleComboBox.currentText())]
- success = self.manager.import_bible(BibleFormat.WebDownload,
+ importer = self.manager.import_bible(BibleFormat.WebDownload,
name=unicode(self.field(u'license_version').toString()),
download_source=unicode(DownloadLocation.get_name(download_location)),
download_name=unicode(bible),
@@ -353,6 +353,7 @@
proxy_username=unicode(self.field(u'proxy_username').toString()),
proxy_password=unicode(self.field(u'proxy_password').toString())
)
+ success = importer.do_import()
if success:
self.manager.save_meta_data(
unicode(self.field(u'license_version').toString()),
@@ -365,6 +366,7 @@
else:
self.ImportProgressLabel.setText(
self.trUtf8('Your Bible import failed.'))
+ importer.delete()
def postImport(self):
self.ImportProgressBar.setValue(self.ImportProgressBar.maximum())
=== modified file 'openlp/plugins/bibles/lib/db.py'
--- openlp/plugins/bibles/lib/db.py 2010-03-16 20:43:41 +0000
+++ openlp/plugins/bibles/lib/db.py 2010-03-19 22:34:19 +0000
@@ -77,7 +77,6 @@
self.file = self.clean_filename(self.name)
if u'file' in kwargs:
self.file = kwargs[u'file']
-
self.db_file = os.path.join(kwargs[u'path'], self.file)
log.debug(u'Load bible %s on path %s', self.file, self.db_file)
db_type = self.config.get_config(u'db type', u'sqlite')
@@ -109,6 +108,13 @@
old_filename = re.sub(r'[^\w]+', u'_', old_filename).strip(u'_')
return old_filename + u'.sqlite'
+ def delete(self):
+ try:
+ os.remove(self.db_file)
+ return True
+ except:
+ return False
+
def register(self, wizard):
"""
This method basically just initialialises the database. It is called
=== modified file 'openlp/plugins/bibles/lib/manager.py'
--- openlp/plugins/bibles/lib/manager.py 2010-03-16 21:13:23 +0000
+++ openlp/plugins/bibles/lib/manager.py 2010-03-19 22:34:19 +0000
@@ -165,7 +165,7 @@
importer = class_(self.parent, **kwargs)
name = importer.register(self.import_wizard)
self.db_cache[name] = importer
- return importer.do_import()
+ return importer
def get_bibles(self):
"""
=== modified file 'openlp/plugins/bibles/lib/osis.py'
--- openlp/plugins/bibles/lib/osis.py 2010-03-12 21:55:52 +0000
+++ openlp/plugins/bibles/lib/osis.py 2010-03-19 22:34:19 +0000
@@ -114,12 +114,14 @@
osis = codecs.open(self.filename, u'r', details['encoding'])
last_chapter = 0
testament = 1
+ match_count = 0
db_book = None
for file_record in osis:
if self.stop_import_flag:
break
match = self.verse_regex.search(file_record)
if match:
+ match_count += 1
book = match.group(1)
chapter = int(match.group(2))
verse = int(match.group(3))
@@ -166,6 +168,8 @@
Receiver.send_message(u'process_events')
self.commit()
self.wizard.incrementProgressBar(u'Finishing import...')
+ if match_count == 0:
+ success = False
except:
log.exception(u'Loading bible from OSIS file failed')
success = False
Follow ups