forked from openlp/openlp
Bible fixes
This commit is contained in:
parent
54f36da76f
commit
f5229ffaa4
@ -51,15 +51,15 @@ class CSVBible(BibleDB):
|
|||||||
if u'versesfile' not in kwargs:
|
if u'versesfile' not in kwargs:
|
||||||
raise KeyError(u'You have to supply a file to import verses from.')
|
raise KeyError(u'You have to supply a file to import verses from.')
|
||||||
self.versesfile = kwargs[u'versesfile']
|
self.versesfile = kwargs[u'versesfile']
|
||||||
#QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
# QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
|
QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
|
||||||
|
|
||||||
def stop_import(self):
|
def stop_import(self):
|
||||||
"""
|
"""
|
||||||
Stops the import of the Bible.
|
Stops the import of the Bible.
|
||||||
"""
|
"""
|
||||||
log.debug('Stopping import!')
|
log.debug('Stopping import!')
|
||||||
self.stop_import = True
|
self.stop_import_flag = True
|
||||||
|
|
||||||
def do_import(self):
|
def do_import(self):
|
||||||
#Populate the Tables
|
#Populate the Tables
|
||||||
@ -72,7 +72,7 @@ class CSVBible(BibleDB):
|
|||||||
books_reader = csv.reader(books_file, dialect)
|
books_reader = csv.reader(books_file, dialect)
|
||||||
for line in books_reader:
|
for line in books_reader:
|
||||||
# cancel pressed
|
# cancel pressed
|
||||||
if self.stop_import:
|
if self.stop_import_flag:
|
||||||
break
|
break
|
||||||
details = chardet.detect(line[1])
|
details = chardet.detect(line[1])
|
||||||
self.create_book(unicode(line[1], details['encoding']),
|
self.create_book(unicode(line[1], details['encoding']),
|
||||||
@ -94,7 +94,7 @@ class CSVBible(BibleDB):
|
|||||||
verse_file.seek(0)
|
verse_file.seek(0)
|
||||||
verse_reader = csv.reader(verse_file, dialect)
|
verse_reader = csv.reader(verse_file, dialect)
|
||||||
for line in verse_reader:
|
for line in verse_reader:
|
||||||
if self.stop_import: # cancel pressed
|
if self.stop_import_flag: # cancel pressed
|
||||||
break
|
break
|
||||||
details = chardet.detect(line[3])
|
details = chardet.detect(line[3])
|
||||||
if book_ptr != line[0]:
|
if book_ptr != line[0]:
|
||||||
@ -113,7 +113,7 @@ class CSVBible(BibleDB):
|
|||||||
finally:
|
finally:
|
||||||
if verse_file:
|
if verse_file:
|
||||||
verse_file.close()
|
verse_file.close()
|
||||||
if self.stop_import:
|
if self.stop_import_flag:
|
||||||
self.wizard.incrementProgressBar(u'Import canceled!')
|
self.wizard.incrementProgressBar(u'Import canceled!')
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
@ -67,7 +67,7 @@ class BibleDB(QtCore.QObject):
|
|||||||
raise KeyError(u'Missing keyword argument "name".')
|
raise KeyError(u'Missing keyword argument "name".')
|
||||||
if u'config' not in kwargs:
|
if u'config' not in kwargs:
|
||||||
raise KeyError(u'Missing keyword argument "config".')
|
raise KeyError(u'Missing keyword argument "config".')
|
||||||
self.stop_import = False
|
self.stop_import_flag = False
|
||||||
self.name = kwargs[u'name']
|
self.name = kwargs[u'name']
|
||||||
self.config = kwargs[u'config']
|
self.config = kwargs[u'config']
|
||||||
self.db_file = os.path.join(kwargs[u'path'],
|
self.db_file = os.path.join(kwargs[u'path'],
|
||||||
|
@ -52,15 +52,15 @@ class OpenSongBible(BibleDB):
|
|||||||
if 'filename' not in kwargs:
|
if 'filename' not in kwargs:
|
||||||
raise KeyError(u'You have to supply a file name to import from.')
|
raise KeyError(u'You have to supply a file name to import from.')
|
||||||
self.filename = kwargs['filename']
|
self.filename = kwargs['filename']
|
||||||
#QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
# QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
|
QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
|
||||||
|
|
||||||
def stop_import(self):
|
def stop_import(self):
|
||||||
"""
|
"""
|
||||||
Stops the import of the Bible.
|
Stops the import of the Bible.
|
||||||
"""
|
"""
|
||||||
log.debug('Stopping import!')
|
log.debug('Stopping import!')
|
||||||
self.stop_import = True
|
self.stop_import_flag = True
|
||||||
|
|
||||||
def do_import(self):
|
def do_import(self):
|
||||||
"""
|
"""
|
||||||
@ -79,15 +79,15 @@ class OpenSongBible(BibleDB):
|
|||||||
opensong = objectify.parse(file)
|
opensong = objectify.parse(file)
|
||||||
bible = opensong.getroot()
|
bible = opensong.getroot()
|
||||||
for book in bible.b:
|
for book in bible.b:
|
||||||
if self.stop_import:
|
if self.stop_import_flag:
|
||||||
break
|
break
|
||||||
db_book = self.create_book(unicode(book.attrib[u'n']),
|
db_book = self.create_book(unicode(book.attrib[u'n']),
|
||||||
unicode(book.attrib[u'n'][:4]))
|
unicode(book.attrib[u'n'][:4]))
|
||||||
for chapter in book.c:
|
for chapter in book.c:
|
||||||
if self.stop_import:
|
if self.stop_import_flag:
|
||||||
break
|
break
|
||||||
for verse in chapter.v:
|
for verse in chapter.v:
|
||||||
if self.stop_import:
|
if self.stop_import_flag:
|
||||||
break
|
break
|
||||||
self.create_verse(
|
self.create_verse(
|
||||||
db_book.id,
|
db_book.id,
|
||||||
|
@ -81,15 +81,15 @@ class OSISBible(BibleDB):
|
|||||||
finally:
|
finally:
|
||||||
if fbibles:
|
if fbibles:
|
||||||
fbibles.close()
|
fbibles.close()
|
||||||
#QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
# QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
|
QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
|
||||||
|
|
||||||
def stop_import(self):
|
def stop_import(self):
|
||||||
"""
|
"""
|
||||||
Stops the import of the Bible.
|
Stops the import of the Bible.
|
||||||
"""
|
"""
|
||||||
log.debug('Stopping import!')
|
log.debug('Stopping import!')
|
||||||
self.stop_import = True
|
self.stop_import_flag = True
|
||||||
|
|
||||||
def do_import(self):
|
def do_import(self):
|
||||||
"""
|
"""
|
||||||
@ -114,7 +114,7 @@ class OSISBible(BibleDB):
|
|||||||
testament = 1
|
testament = 1
|
||||||
db_book = None
|
db_book = None
|
||||||
for file_record in osis:
|
for file_record in osis:
|
||||||
if self.stop_import:
|
if self.stop_import_flag:
|
||||||
break
|
break
|
||||||
match = self.verse_regex.search(file_record)
|
match = self.verse_regex.search(file_record)
|
||||||
if match:
|
if match:
|
||||||
@ -126,7 +126,7 @@ class OSISBible(BibleDB):
|
|||||||
log.debug('New book: "%s"', self.books[book][0])
|
log.debug('New book: "%s"', self.books[book][0])
|
||||||
if book == u'Matt':
|
if book == u'Matt':
|
||||||
testament += 1
|
testament += 1
|
||||||
db_book = self.bibledb.create_book(
|
db_book = self.create_book(
|
||||||
unicode(self.books[book][0]),
|
unicode(self.books[book][0]),
|
||||||
unicode(self.books[book][1]),
|
unicode(self.books[book][1]),
|
||||||
testament)
|
testament)
|
||||||
@ -137,7 +137,8 @@ class OSISBible(BibleDB):
|
|||||||
self.wizard.ImportProgressBar.setMaximum(260)
|
self.wizard.ImportProgressBar.setMaximum(260)
|
||||||
if last_chapter != chapter:
|
if last_chapter != chapter:
|
||||||
if last_chapter != 0:
|
if last_chapter != 0:
|
||||||
self.bibledb.save_verses()
|
pass
|
||||||
|
#self.save_verses()
|
||||||
self.wizard.incrementProgressBar(
|
self.wizard.incrementProgressBar(
|
||||||
u'Importing %s %s...' % \
|
u'Importing %s %s...' % \
|
||||||
(self.books[match.group(1)][0], chapter))
|
(self.books[match.group(1)][0], chapter))
|
||||||
@ -170,9 +171,8 @@ class OSISBible(BibleDB):
|
|||||||
finally:
|
finally:
|
||||||
if osis:
|
if osis:
|
||||||
osis.close()
|
osis.close()
|
||||||
if self.stop_import:
|
if self.stop_import_flag:
|
||||||
self.wizard.incrementProgressBar(u'Import canceled!')
|
self.wizard.incrementProgressBar(u'Import canceled!')
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return success
|
return success
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user