Bible fixes

This commit is contained in:
Tim Bentley 2010-02-06 15:33:23 +00:00
parent 54f36da76f
commit f5229ffaa4
4 changed files with 21 additions and 21 deletions

View File

@ -51,15 +51,15 @@ class CSVBible(BibleDB):
if u'versesfile' not in kwargs:
raise KeyError(u'You have to supply a file to import verses from.')
self.versesfile = kwargs[u'versesfile']
#QtCore.QObject.connect(Receiver.get_receiver(),
# QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
def stop_import(self):
"""
Stops the import of the Bible.
"""
log.debug('Stopping import!')
self.stop_import = True
self.stop_import_flag = True
def do_import(self):
#Populate the Tables
@ -72,7 +72,7 @@ class CSVBible(BibleDB):
books_reader = csv.reader(books_file, dialect)
for line in books_reader:
# cancel pressed
if self.stop_import:
if self.stop_import_flag:
break
details = chardet.detect(line[1])
self.create_book(unicode(line[1], details['encoding']),
@ -94,7 +94,7 @@ class CSVBible(BibleDB):
verse_file.seek(0)
verse_reader = csv.reader(verse_file, dialect)
for line in verse_reader:
if self.stop_import: # cancel pressed
if self.stop_import_flag: # cancel pressed
break
details = chardet.detect(line[3])
if book_ptr != line[0]:
@ -113,7 +113,7 @@ class CSVBible(BibleDB):
finally:
if verse_file:
verse_file.close()
if self.stop_import:
if self.stop_import_flag:
self.wizard.incrementProgressBar(u'Import canceled!')
return False
else:

View File

@ -67,7 +67,7 @@ class BibleDB(QtCore.QObject):
raise KeyError(u'Missing keyword argument "name".')
if u'config' not in kwargs:
raise KeyError(u'Missing keyword argument "config".')
self.stop_import = False
self.stop_import_flag = False
self.name = kwargs[u'name']
self.config = kwargs[u'config']
self.db_file = os.path.join(kwargs[u'path'],

View File

@ -52,15 +52,15 @@ class OpenSongBible(BibleDB):
if 'filename' not in kwargs:
raise KeyError(u'You have to supply a file name to import from.')
self.filename = kwargs['filename']
#QtCore.QObject.connect(Receiver.get_receiver(),
# QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
def stop_import(self):
"""
Stops the import of the Bible.
"""
log.debug('Stopping import!')
self.stop_import = True
self.stop_import_flag = True
def do_import(self):
"""
@ -79,15 +79,15 @@ class OpenSongBible(BibleDB):
opensong = objectify.parse(file)
bible = opensong.getroot()
for book in bible.b:
if self.stop_import:
if self.stop_import_flag:
break
db_book = self.create_book(unicode(book.attrib[u'n']),
unicode(book.attrib[u'n'][:4]))
for chapter in book.c:
if self.stop_import:
if self.stop_import_flag:
break
for verse in chapter.v:
if self.stop_import:
if self.stop_import_flag:
break
self.create_verse(
db_book.id,

View File

@ -81,15 +81,15 @@ class OSISBible(BibleDB):
finally:
if fbibles:
fbibles.close()
#QtCore.QObject.connect(Receiver.get_receiver(),
# QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
def stop_import(self):
"""
Stops the import of the Bible.
"""
log.debug('Stopping import!')
self.stop_import = True
self.stop_import_flag = True
def do_import(self):
"""
@ -114,7 +114,7 @@ class OSISBible(BibleDB):
testament = 1
db_book = None
for file_record in osis:
if self.stop_import:
if self.stop_import_flag:
break
match = self.verse_regex.search(file_record)
if match:
@ -126,7 +126,7 @@ class OSISBible(BibleDB):
log.debug('New book: "%s"', self.books[book][0])
if book == u'Matt':
testament += 1
db_book = self.bibledb.create_book(
db_book = self.create_book(
unicode(self.books[book][0]),
unicode(self.books[book][1]),
testament)
@ -137,7 +137,8 @@ class OSISBible(BibleDB):
self.wizard.ImportProgressBar.setMaximum(260)
if last_chapter != chapter:
if last_chapter != 0:
self.bibledb.save_verses()
pass
#self.save_verses()
self.wizard.incrementProgressBar(
u'Importing %s %s...' % \
(self.books[match.group(1)][0], chapter))
@ -170,9 +171,8 @@ class OSISBible(BibleDB):
finally:
if osis:
osis.close()
if self.stop_import:
if self.stop_import_flag:
self.wizard.incrementProgressBar(u'Import canceled!')
return False
else:
return success