forked from openlp/openlp
Lots of changes here, I think.
- Pluggable import system - The enumeration class provides the correct importer class - Reworked Bible verse parsing, using regular expressions - Reworked verse query method to accept multiple verse ranges - Renamed lots of methods, which is probably gonna break lots of stuff
This commit is contained in:
parent
34ab7ea901
commit
0374233db6
@ -169,6 +169,15 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
|||||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
||||||
self.CopyrightEdit.setFocus()
|
self.CopyrightEdit.setFocus()
|
||||||
return False
|
return False
|
||||||
|
elif self.biblemanager.exists(
|
||||||
|
self.field(u'license_version').toString()):
|
||||||
|
QtGui.QMessageBox.critical(self,
|
||||||
|
self.trUtf8('Bible Exists'),
|
||||||
|
self.trUtf8('This Bible already exists! Please import '
|
||||||
|
'a different Bible or first delete the existing one.'),
|
||||||
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
||||||
|
self.VersionNameEdit.setFocus()
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
if self.currentId() == 3:
|
if self.currentId() == 3:
|
||||||
# Progress page
|
# Progress page
|
||||||
@ -317,22 +326,22 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
|||||||
success = False
|
success = False
|
||||||
if bible_type == BibleFormat.OSIS:
|
if bible_type == BibleFormat.OSIS:
|
||||||
# Import an OSIS bible
|
# Import an OSIS bible
|
||||||
success = self.biblemanager.register_osis_file_bible(
|
success = self.biblemanager.import_bible(BibleFormat.OSIS,
|
||||||
unicode(self.field(u'license_version').toString()),
|
name=unicode(self.field(u'license_version').toString()),
|
||||||
unicode(self.field(u'osis_location').toString())
|
filename=unicode(self.field(u'osis_location').toString())
|
||||||
)
|
)
|
||||||
elif bible_type == BibleFormat.CSV:
|
elif bible_type == BibleFormat.CSV:
|
||||||
# Import a CSV bible
|
# Import a CSV bible
|
||||||
success = self.biblemanager.register_csv_file_bible(
|
success = self.biblemanager.import_bible(BibleFormat.CSV,
|
||||||
unicode(self.field(u'license_version').toString()),
|
name=unicode(self.field(u'license_version').toString()),
|
||||||
self.field(u'csv_booksfile').toString(),
|
booksfile=self.field(u'csv_booksfile').toString(),
|
||||||
self.field(u'csv_versefile').toString()
|
versefile=self.field(u'csv_versefile').toString()
|
||||||
)
|
)
|
||||||
elif bible_type == BibleFormat.OpenSong:
|
elif bible_type == BibleFormat.OpenSong:
|
||||||
# Import an OpenSong bible
|
# Import an OpenSong bible
|
||||||
success = self.biblemanager.register_opensong_bible(
|
success = self.biblemanager.import_bible(BibleFormat.OpenSong,
|
||||||
unicode(self.field(u'license_version').toString()),
|
name=unicode(self.field(u'license_version').toString()),
|
||||||
self.field(u'opensong_file').toString()
|
filename=self.field(u'opensong_file').toString()
|
||||||
)
|
)
|
||||||
elif bible_type == BibleFormat.WebDownload:
|
elif bible_type == BibleFormat.WebDownload:
|
||||||
# Import a bible from the web
|
# Import a bible from the web
|
||||||
@ -344,13 +353,13 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
|||||||
elif download_location == DownloadLocation.BibleGateway:
|
elif download_location == DownloadLocation.BibleGateway:
|
||||||
bible = self.web_bible_list[DownloadLocation.BibleGateway][
|
bible = self.web_bible_list[DownloadLocation.BibleGateway][
|
||||||
unicode(self.BibleComboBox.currentText())]
|
unicode(self.BibleComboBox.currentText())]
|
||||||
success = self.biblemanager.register_http_bible(
|
success = self.biblemanager.import_bible(BibleFormat.WebDownload,
|
||||||
unicode(self.field(u'license_version').toString()),
|
name=unicode(self.field(u'license_version').toString()),
|
||||||
unicode(DownloadLocation.get_name(download_location)),
|
download_source=unicode(DownloadLocation.get_name(download_location)),
|
||||||
unicode(bible),
|
download_name=unicode(bible),
|
||||||
unicode(self.field(u'proxy_server').toString()),
|
proxy_server=unicode(self.field(u'proxy_server').toString()),
|
||||||
unicode(self.field(u'proxy_username').toString()),
|
proxy_username=unicode(self.field(u'proxy_username').toString()),
|
||||||
unicode(self.field(u'proxy_password').toString())
|
proxy_password=unicode(self.field(u'proxy_password').toString())
|
||||||
)
|
)
|
||||||
if success:
|
if success:
|
||||||
self.biblemanager.save_meta_data(
|
self.biblemanager.save_meta_data(
|
||||||
@ -359,6 +368,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
|||||||
unicode(self.field(u'license_copyright').toString()),
|
unicode(self.field(u'license_copyright').toString()),
|
||||||
unicode(self.field(u'license_permission').toString())
|
unicode(self.field(u'license_permission').toString())
|
||||||
)
|
)
|
||||||
|
self.biblemanager.reload_bibles()
|
||||||
self.ImportProgressLabel.setText(self.trUtf8('Finished import.'))
|
self.ImportProgressLabel.setText(self.trUtf8('Finished import.'))
|
||||||
else:
|
else:
|
||||||
self.ImportProgressLabel.setText(
|
self.ImportProgressLabel.setText(
|
||||||
|
@ -26,6 +26,63 @@
|
|||||||
import urllib2
|
import urllib2
|
||||||
import chardet
|
import chardet
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
|
|
||||||
|
only_verses = re.compile(r'([a-zA-Z0-9 ]+)[ ]+([0-9]+)[ ]*[:|v|V][ ]*([0-9]+)'
|
||||||
|
r'(?:[ ]*-[ ]*([0-9]+|end))?(?:[ ]*,[ ]*([0-9]+)(?:[ ]*-[ ]*([0-9]+|end))?)?',
|
||||||
|
re.UNICODE)
|
||||||
|
chapter_range = re.compile(r'([a-zA-Z0-9 ]+)[ ]+([0-9]+)[ ]*[:|v|V][ ]*'
|
||||||
|
r'([0-9]+)[ ]*-[ ]*([0-9]+)[ ]*[:|v|V][ ]*([0-9]+)',
|
||||||
|
re.UNICODE)
|
||||||
|
|
||||||
|
def parse_reference(reference):
|
||||||
|
"""
|
||||||
|
This is the über-awesome function that takes a person's typed in string
|
||||||
|
and converts it to a reference list, a list of references to be queried
|
||||||
|
from the Bible database files.
|
||||||
|
|
||||||
|
The reference list is a list of tuples, with each tuple structured like
|
||||||
|
this::
|
||||||
|
|
||||||
|
(book, chapter, start_verse, end_verse)
|
||||||
|
"""
|
||||||
|
reference = reference.strip()
|
||||||
|
reference_list = []
|
||||||
|
# We start with the most "complicated" match first, so that they are found
|
||||||
|
# first, and we don't have any "false positives".
|
||||||
|
match = chapter_range.match(reference)
|
||||||
|
if match:
|
||||||
|
reference_list.extend([
|
||||||
|
(match.group(1), match.group(2), match.group(3), -1),
|
||||||
|
(match.group(1), match.group(4), 1, match.group(5))
|
||||||
|
])
|
||||||
|
else:
|
||||||
|
match = only_verses.match(reference)
|
||||||
|
if match:
|
||||||
|
book = match.group(1)
|
||||||
|
chapter = match.group(2)
|
||||||
|
verse = match.group(3)
|
||||||
|
if match.group(4) is None:
|
||||||
|
reference_list.append((book, chapter, verse, verse))
|
||||||
|
elif match.group(5) is None:
|
||||||
|
end_verse = match.group(4)
|
||||||
|
if end_verse == u'end':
|
||||||
|
end_verse = -1
|
||||||
|
reference_list.append((book, chapter, verse, end_verse))
|
||||||
|
elif match.group(6) is None:
|
||||||
|
reference_list.extend([
|
||||||
|
(book, chapter, verse, match.group(4)),
|
||||||
|
(book, chapter, match.group(5), match.group(5))
|
||||||
|
])
|
||||||
|
else:
|
||||||
|
end_verse = match.group(6)
|
||||||
|
if end_verse == u'end':
|
||||||
|
end_verse = -1
|
||||||
|
reference_list.extend([
|
||||||
|
(book, chapter, verse, match.group(4)),
|
||||||
|
(book, chapter, match.group(5), end_verse)
|
||||||
|
])
|
||||||
|
return reference_list
|
||||||
|
|
||||||
class SearchResults:
|
class SearchResults:
|
||||||
"""
|
"""
|
||||||
@ -81,14 +138,6 @@ class BibleCommon(object):
|
|||||||
log = logging.getLogger(u'BibleCommon')
|
log = logging.getLogger(u'BibleCommon')
|
||||||
log.info(u'BibleCommon')
|
log.info(u'BibleCommon')
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
"""
|
|
||||||
An empty constructor... not sure why I'm here.
|
|
||||||
"""
|
|
||||||
self.loadbible = True
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
|
||||||
QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
|
|
||||||
|
|
||||||
def _get_web_text(self, urlstring, proxyurl):
|
def _get_web_text(self, urlstring, proxyurl):
|
||||||
"""
|
"""
|
||||||
Get the HTML from the web page.
|
Get the HTML from the web page.
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
import logging
|
import logging
|
||||||
import chardet
|
import chardet
|
||||||
|
|
||||||
from openlp.plugins.bibles.lib.db import BibleDB
|
|
||||||
from openlp.core.lib import Receiver
|
from openlp.core.lib import Receiver
|
||||||
|
from db import BibleDB
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -44,20 +44,22 @@ class CSVBible(BibleDB):
|
|||||||
"""
|
"""
|
||||||
log.info(__name__)
|
log.info(__name__)
|
||||||
BibleDB.__init__(self, **kwargs)
|
BibleDB.__init__(self, **kwargs)
|
||||||
|
if u'booksfile' not in kwargs:
|
||||||
|
raise KeyError(u'You have to supply a file to import books from.')
|
||||||
|
self.booksfile = kwargs[u'booksfile']
|
||||||
|
if u'versesfile' not in kwargs:
|
||||||
|
raise KeyError(u'You have to supply a file to import verses from.')
|
||||||
|
self.versesfile = kwargs[u'versesfile']
|
||||||
|
|
||||||
def stop_import(self):
|
def do_import(self):
|
||||||
self.loadbible = False
|
|
||||||
|
|
||||||
def load_data(self, booksfile, versesfile, dialogobject):
|
|
||||||
#Populate the Tables
|
#Populate the Tables
|
||||||
success = True
|
success = True
|
||||||
fbooks = None
|
fbooks = None
|
||||||
try:
|
try:
|
||||||
fbooks = open(booksfile, 'r')
|
fbooks = open(self.booksfile, 'r')
|
||||||
count = 0
|
|
||||||
for line in fbooks:
|
for line in fbooks:
|
||||||
# cancel pressed
|
# cancel pressed
|
||||||
if not self.loadbible:
|
if self.stop_import:
|
||||||
break
|
break
|
||||||
details = chardet.detect(line)
|
details = chardet.detect(line)
|
||||||
line = unicode(line, details['encoding'])
|
line = unicode(line, details['encoding'])
|
||||||
@ -65,12 +67,8 @@ class CSVBible(BibleDB):
|
|||||||
p1 = p[1].replace(u'"', u'')
|
p1 = p[1].replace(u'"', u'')
|
||||||
p2 = p[2].replace(u'"', u'')
|
p2 = p[2].replace(u'"', u'')
|
||||||
p3 = p[3].replace(u'"', u'')
|
p3 = p[3].replace(u'"', u'')
|
||||||
self.bibledb.create_book(p2, p3, int(p1))
|
self.create_book(p2, p3, int(p1))
|
||||||
count += 1
|
|
||||||
#Flush the screen events
|
|
||||||
if count % 3 == 0:
|
|
||||||
Receiver.send_message(u'process_events')
|
Receiver.send_message(u'process_events')
|
||||||
count = 0
|
|
||||||
except:
|
except:
|
||||||
log.exception(u'Loading books from file failed')
|
log.exception(u'Loading books from file failed')
|
||||||
success = False
|
success = False
|
||||||
@ -82,10 +80,9 @@ class CSVBible(BibleDB):
|
|||||||
fverse = None
|
fverse = None
|
||||||
try:
|
try:
|
||||||
fverse = open(versesfile, 'r')
|
fverse = open(versesfile, 'r')
|
||||||
count = 0
|
|
||||||
book_ptr = None
|
book_ptr = None
|
||||||
for line in fverse:
|
for line in fverse:
|
||||||
if not self.loadbible: # cancel pressed
|
if self.stop_import: # cancel pressed
|
||||||
break
|
break
|
||||||
details = chardet.detect(line)
|
details = chardet.detect(line)
|
||||||
line = unicode(line, details['encoding'])
|
line = unicode(line, details['encoding'])
|
||||||
@ -94,28 +91,23 @@ class CSVBible(BibleDB):
|
|||||||
p0 = p[0].replace(u'"', u'')
|
p0 = p[0].replace(u'"', u'')
|
||||||
p3 = p[3].replace(u'"', u'')
|
p3 = p[3].replace(u'"', u'')
|
||||||
if book_ptr is not p0:
|
if book_ptr is not p0:
|
||||||
book = self.bibledb.get_bible_book(p0)
|
book = self.get_book(p0)
|
||||||
book_ptr = book.name
|
book_ptr = book.name
|
||||||
# increament the progress bar
|
# increament the progress bar
|
||||||
dialogobject.incrementProgressBar(u'Importing %s %s' % \
|
self.wizard.incrementProgressBar(
|
||||||
book.name)
|
u'Importing %s %s' % book.name)
|
||||||
self.bibledb.add_verse(book.id, p[1], p[2], p3)
|
self.commit()
|
||||||
count += 1
|
self.add_verse(book.id, p[1], p[2], p3)
|
||||||
#Every x verses repaint the screen
|
|
||||||
if count % 3 == 0:
|
|
||||||
Receiver.send_message(u'process_events')
|
Receiver.send_message(u'process_events')
|
||||||
count = 0
|
self.commit()
|
||||||
self.bibledb.save_verses()
|
|
||||||
except:
|
except:
|
||||||
log.exception(u'Loading verses from file failed')
|
log.exception(u'Loading verses from file failed')
|
||||||
success = False
|
success = False
|
||||||
finally:
|
finally:
|
||||||
if fverse:
|
if fverse:
|
||||||
fverse.close()
|
fverse.close()
|
||||||
if not self.loadbible:
|
if self.stop_import:
|
||||||
dialogobject.incrementProgressBar(u'Import canceled!')
|
self.wizard.incrementProgressBar(u'Import canceled!')
|
||||||
dialogobject.ImportProgressBar.setValue(
|
|
||||||
dialogobject.ImportProgressBar.maximum())
|
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return success
|
return success
|
||||||
|
@ -26,12 +26,15 @@
|
|||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from common import BibleCommon
|
from sqlalchemy import or_
|
||||||
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
from openlp.core.lib import Receiver
|
||||||
from models import *
|
from models import *
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class BibleDB(BibleCommon):
|
class BibleDB():
|
||||||
"""
|
"""
|
||||||
This class represents a database-bound Bible. It is used as a base class
|
This class represents a database-bound Bible. It is used as a base class
|
||||||
for all the custom importers, so that the can implement their own import
|
for all the custom importers, so that the can implement their own import
|
||||||
@ -40,22 +43,39 @@ class BibleDB(BibleCommon):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
"""
|
||||||
|
The constructor loads up the database and creates and initialises the
|
||||||
|
tables if the database doesn't exist.
|
||||||
|
|
||||||
|
**Required keyword arguments:**
|
||||||
|
|
||||||
|
``path``
|
||||||
|
The path to the bible database file.
|
||||||
|
|
||||||
|
``name``
|
||||||
|
The name of the database. This is also used as the file name for
|
||||||
|
SQLite databases.
|
||||||
|
|
||||||
|
``config``
|
||||||
|
The configuration object, passed in from the plugin.
|
||||||
|
"""
|
||||||
log.info(u'BibleDBimpl loaded')
|
log.info(u'BibleDBimpl loaded')
|
||||||
if u'biblepath' not in kwargs:
|
if u'path' not in kwargs:
|
||||||
raise KeyError(u'Missing keyword argument "path".')
|
raise KeyError(u'Missing keyword argument "path".')
|
||||||
if u'biblename' not in kwargs:
|
if u'name' not in kwargs:
|
||||||
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".')
|
||||||
# Connect to database
|
self.stop_import = False
|
||||||
|
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'],
|
||||||
u'%s.sqlite' % kwargs[u'biblename'])
|
u'%s.sqlite' % kwargs[u'name'])
|
||||||
log.debug(u'Load bible %s on path %s', biblename, self.biblefile)
|
log.debug(u'Load bible %s on path %s', kwargs[u'name'], self.db_file)
|
||||||
db_type = self.config.get_config(u'db type', u'sqlite')
|
db_type = self.config.get_config(u'db type', u'sqlite')
|
||||||
db_url = u''
|
db_url = u''
|
||||||
if db_type == u'sqlite':
|
if db_type == u'sqlite':
|
||||||
db_url = u'sqlite:///' + self.biblefile
|
db_url = u'sqlite:///' + self.db_file
|
||||||
else:
|
else:
|
||||||
db_url = u'%s://%s:%s@%s/%s' % \
|
db_url = u'%s://%s:%s@%s/%s' % \
|
||||||
(db_type, self.config.get_config(u'db username'),
|
(db_type, self.config.get_config(u'db username'),
|
||||||
@ -65,134 +85,200 @@ class BibleDB(BibleCommon):
|
|||||||
self.metadata, self.session = init_models(db_url)
|
self.metadata, self.session = init_models(db_url)
|
||||||
self.metadata.create_all(checkfirst=True)
|
self.metadata.create_all(checkfirst=True)
|
||||||
|
|
||||||
|
def register(self):
|
||||||
|
"""
|
||||||
|
This method basically just initialialises the database. It is called
|
||||||
|
from the Bible Manager when a Bible is imported. Descendant classes
|
||||||
|
may want to override this method to supply their own custom
|
||||||
|
initialisation as well.
|
||||||
|
"""
|
||||||
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
|
QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
|
||||||
|
self.create_tables()
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
def stop_import(self):
|
||||||
|
"""
|
||||||
|
Stops the import of the Bible.
|
||||||
|
"""
|
||||||
|
log.debug('Stopping import!')
|
||||||
|
self.stop_import = True
|
||||||
|
|
||||||
|
def commit(self):
|
||||||
|
log.debug('Committing...')
|
||||||
|
self.session.commit()
|
||||||
|
|
||||||
def create_tables(self):
|
def create_tables(self):
|
||||||
log.debug(u'createTables')
|
log.debug(u'createTables')
|
||||||
self.save_meta(u'dbversion', u'2')
|
self.save_meta(u'dbversion', u'2')
|
||||||
self._load_testament(u'Old Testament')
|
self.create_testament(u'Old Testament')
|
||||||
self._load_testament(u'New Testament')
|
self.create_testament(u'New Testament')
|
||||||
self._load_testament(u'Apocrypha')
|
self.create_testament(u'Apocrypha')
|
||||||
|
|
||||||
def add_verse(self, bookid, chap, vse, text):
|
def create_testament(self, testament):
|
||||||
verse = Verse()
|
log.debug(u'%s: %s', __name__, testament)
|
||||||
verse.book_id = bookid
|
self.session.add(Testament.populate(name=testament))
|
||||||
verse.chapter = chap
|
self.commit()
|
||||||
verse.verse = vse
|
|
||||||
verse.text = text
|
def create_book(self, name, abbrev, testament=1):
|
||||||
|
log.debug(u'create_book %s,%s', bookname, bookabbrev)
|
||||||
|
book = Book.populate(name=name, abbreviation=abbrev,
|
||||||
|
testament_id=testament)
|
||||||
|
self.session.add(book)
|
||||||
|
self.commit()
|
||||||
|
return book
|
||||||
|
|
||||||
|
def create_chapter(self, book_id, chapter, textlist):
|
||||||
|
log.debug(u'create_chapter %s,%s', bookid, chap)
|
||||||
|
#text list has book and chapter as first two elements of the array
|
||||||
|
for verse_number, verse_text in textlist.iteritems():
|
||||||
|
verse = Verse.populate(
|
||||||
|
book_id = book_id,
|
||||||
|
chapter = chap,
|
||||||
|
verse = verse_number,
|
||||||
|
text = verse_text
|
||||||
|
)
|
||||||
|
self.session.add(verse)
|
||||||
|
self.commit()
|
||||||
|
|
||||||
|
def create_verse(self, book_id, chapter, verse, text):
|
||||||
|
verse = Verse.populate(
|
||||||
|
book_id=book_id,
|
||||||
|
chapter=chapter,
|
||||||
|
verse=verse,
|
||||||
|
text=text
|
||||||
|
)
|
||||||
self.session.add(verse)
|
self.session.add(verse)
|
||||||
return verse
|
return verse
|
||||||
|
|
||||||
def save_verses(self):
|
def create_meta(self, key, value):
|
||||||
log.debug('Saving verses...')
|
|
||||||
self.session.commit()
|
|
||||||
|
|
||||||
def create_chapter(self, bookid, chap, textlist):
|
|
||||||
log.debug(u'create_chapter %s,%s', bookid, chap)
|
|
||||||
#text list has book and chapter as first to elements of the array
|
|
||||||
for verse_number, verse_text in textlist.iteritems():
|
|
||||||
verse = Verse()
|
|
||||||
verse.book_id = bookid
|
|
||||||
verse.chapter = chap
|
|
||||||
verse.verse = verse_number
|
|
||||||
verse.text = verse_text
|
|
||||||
self.session.add(verse)
|
|
||||||
self.session.commit()
|
|
||||||
|
|
||||||
def create_book(self, bookname, bookabbrev, testament=1):
|
|
||||||
log.debug(u'create_book %s,%s', bookname, bookabbrev)
|
|
||||||
book = Book()
|
|
||||||
book.testament_id = testament
|
|
||||||
book.name = bookname
|
|
||||||
book.abbreviation = bookabbrev
|
|
||||||
self.session.add(book)
|
|
||||||
self.session.commit()
|
|
||||||
return book
|
|
||||||
|
|
||||||
def save_meta(self, key, value):
|
|
||||||
log.debug(u'save_meta %s/%s', key, value)
|
log.debug(u'save_meta %s/%s', key, value)
|
||||||
bmeta = BibleMeta()
|
self.session.add(BibleMeta.populate(key=key, value=value))
|
||||||
bmeta.key = key
|
self.commit()
|
||||||
bmeta.value = value
|
|
||||||
self.session.add(bmeta)
|
|
||||||
self.session.commit()
|
|
||||||
|
|
||||||
def get_meta(self, metakey):
|
def get_books(self):
|
||||||
log.debug(u'get meta %s', metakey)
|
log.debug(__name__)
|
||||||
return self.session.query(BibleMeta).filter_by(key=metakey).first()
|
return self.session.query(Book).order_by(Book.id).all()
|
||||||
|
|
||||||
|
def get_book(self, book):
|
||||||
|
log.debug(u'%s: %s', __name__, book)
|
||||||
|
db_book = self.session.query(Book)\
|
||||||
|
.filter_by(Book.name.like(book + u'%'))\
|
||||||
|
.first()
|
||||||
|
if db_book is None:
|
||||||
|
db_book = self.session.query(Book)\
|
||||||
|
.filter(Book.abbreviation.like(book + u'%'))\
|
||||||
|
.first()
|
||||||
|
return db_book
|
||||||
|
|
||||||
|
def get_chapter(self, id, chapter):
|
||||||
|
log.debug(u'%s: %s, %s', __name__, id, chapter)
|
||||||
|
return self.session.query(Verse)\
|
||||||
|
.filter_by(chapter=chapter)\
|
||||||
|
.filter_by(book_id=id)\
|
||||||
|
.first()
|
||||||
|
|
||||||
|
def get_verses(self, reference_list):
|
||||||
|
"""
|
||||||
|
This is probably the most used function. It retrieves the list of
|
||||||
|
verses based on the user's query.
|
||||||
|
|
||||||
|
``reference_list``
|
||||||
|
This is the list of references the media manager item wants. It is
|
||||||
|
a list of tuples, with the following format::
|
||||||
|
|
||||||
|
(book, chapter, start_verse, end_verse)
|
||||||
|
|
||||||
|
Therefore, when you are looking for multiple items, simply break
|
||||||
|
them up into references like this, bundle them into a list. This
|
||||||
|
function then runs through the list, and returns an amalgamated
|
||||||
|
list of ``Verse`` objects. For example::
|
||||||
|
|
||||||
|
[(u'Genesis', 1, 1, 1), (u'Genesis', 2, 2, 3)]
|
||||||
|
"""
|
||||||
|
log.debug(u'%s: %s', __name__, reference_list)
|
||||||
|
verse_list = []
|
||||||
|
for book, chapter, start_verse, end_verse in reference_list:
|
||||||
|
db_book = self.get_book(book)
|
||||||
|
if end_verse == -1:
|
||||||
|
end_verse = self.get_chapter_count(book)
|
||||||
|
if db_book:
|
||||||
|
book = book.name
|
||||||
|
log.debug(u'Book name corrected to "%s"' % book)
|
||||||
|
verses = self.session.query(Verse)\
|
||||||
|
.filter_by(book_id=book.id)\
|
||||||
|
.filter_by(chapter=chapter)\
|
||||||
|
.filter(Verse.verse >= start_verse)\
|
||||||
|
.filter(Verse.verse <= end_verse)\
|
||||||
|
.order_by(Verse.verse)\
|
||||||
|
.all()
|
||||||
|
verse_list.extend(verses)
|
||||||
|
return verse_list
|
||||||
|
|
||||||
|
def verse_search(self, text):
|
||||||
|
"""
|
||||||
|
Search for verses containing text ``text``.
|
||||||
|
|
||||||
|
``text``
|
||||||
|
The text to search for. If the text contains commas, it will be
|
||||||
|
split apart and OR'd on the list of values. If the text just
|
||||||
|
contains spaces, it will split apart and AND'd on the list of
|
||||||
|
values.
|
||||||
|
"""
|
||||||
|
log.debug(u'%s: %s', __name__, text)
|
||||||
|
verses = self.session.query(Verse)
|
||||||
|
if text.find(u',') > -1:
|
||||||
|
or_clause = []
|
||||||
|
keywords = [u'%%%s%%' % keyword.strip() for keyword in text.split(u',')]
|
||||||
|
for keyword in keywords:
|
||||||
|
or_clause.append(Verse.text.like(keyword))
|
||||||
|
verses = verses.filter(or_(*or_clause))
|
||||||
|
else:
|
||||||
|
keywords = [u'%%%s%%' % keyword.strip() for keyword in text.split(u' ')]
|
||||||
|
for keyword in keywords:
|
||||||
|
verses = verses.filter(Verse.text.like(keyword))
|
||||||
|
verses = verses.all()
|
||||||
|
return verses
|
||||||
|
|
||||||
|
def get_chapter_count(self, book):
|
||||||
|
log.debug(u'%s: %s', __name__, book)
|
||||||
|
count = self.session.query(Verse.chapter).join(Book)\
|
||||||
|
.filter(Book.name==book)\
|
||||||
|
.distinct().count()
|
||||||
|
#verse = self.session.query(Verse).join(Book).filter(
|
||||||
|
# Book.name == bookname).order_by(Verse.chapter.desc()).first()
|
||||||
|
if not count:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
return count
|
||||||
|
|
||||||
|
def get_verse_count(self, book, chapter):
|
||||||
|
log.debug(u'%s: %s, %s', __name__, book, chapter)
|
||||||
|
count = self.session.query(Verse).join(Book)\
|
||||||
|
.filter(Book.name==book)\
|
||||||
|
.filter(Verse.chapter==chapter)\
|
||||||
|
.count()
|
||||||
|
#verse = self.session.query(Verse).join(Book).filter(
|
||||||
|
# Book.name == bookname).filter(
|
||||||
|
# Verse.chapter == chapter).order_by(Verse.verse.desc()).first()
|
||||||
|
if not count:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
return count
|
||||||
|
|
||||||
|
def get_meta(self, key):
|
||||||
|
log.debug(u'get meta %s', key)
|
||||||
|
return self.session.query(BibleMeta).get(key)
|
||||||
|
|
||||||
def delete_meta(self, metakey):
|
def delete_meta(self, metakey):
|
||||||
biblemeta = self.get_meta(metakey)
|
biblemeta = self.get_meta(metakey)
|
||||||
try:
|
try:
|
||||||
self.session.delete(biblemeta)
|
self.session.delete(biblemeta)
|
||||||
self.session.commit()
|
self.commit()
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _load_testament(self, testament):
|
|
||||||
log.debug(u'load_testaments %s', testament)
|
|
||||||
test = ONTestament()
|
|
||||||
test.name = testament
|
|
||||||
self.session.add(test)
|
|
||||||
self.session.commit()
|
|
||||||
|
|
||||||
def get_bible_books(self):
|
|
||||||
log.debug(u'get_bible_books')
|
|
||||||
return self.session.query(Book).order_by(Book.id).all()
|
|
||||||
|
|
||||||
def get_max_bible_book_verses(self, bookname, chapter):
|
|
||||||
log.debug(u'get_max_bible_book_verses %s, %s', bookname, chapter)
|
|
||||||
verse = self.session.query(Verse).join(Book).filter(
|
|
||||||
Book.name == bookname).filter(
|
|
||||||
Verse.chapter == chapter).order_by(Verse.verse.desc()).first()
|
|
||||||
if verse == None:
|
|
||||||
return 0
|
|
||||||
else:
|
|
||||||
return verse.verse
|
|
||||||
|
|
||||||
def get_max_bible_book_chapter(self, bookname):
|
|
||||||
log.debug(u'get_max_bible_book_chapter %s', bookname)
|
|
||||||
verse = self.session.query(Verse).join(Book).filter(
|
|
||||||
Book.name == bookname).order_by(Verse.chapter.desc()).first()
|
|
||||||
if verse == None:
|
|
||||||
return 0
|
|
||||||
else:
|
|
||||||
return verse.chapter
|
|
||||||
|
|
||||||
def get_bible_book(self, bookname):
|
|
||||||
log.debug(u'get_bible_book %s', bookname)
|
|
||||||
book = self.session.query(Book).filter(
|
|
||||||
Book.name.like(bookname + u'%')).first()
|
|
||||||
if book is None:
|
|
||||||
book = self.session.query(Book).filter(
|
|
||||||
Book.abbreviation.like(bookname + u'%')).first()
|
|
||||||
return book
|
|
||||||
|
|
||||||
def get_bible_chapter(self, id, chapter):
|
|
||||||
log.debug(u'get_bible_chapter %s, %s', id, chapter)
|
|
||||||
return self.session.query(Verse).filter_by(chapter=chapter).filter_by(
|
|
||||||
book_id=id).first()
|
|
||||||
|
|
||||||
def get_bible_text(self, bookname, chapter, sverse, everse):
|
|
||||||
log.debug(u'get_bible_text %s, %s, %s, %s', bookname, chapter, sverse,
|
|
||||||
everse)
|
|
||||||
#Look up book name or abbreviation
|
|
||||||
book = self.get_bible_book(bookname)
|
|
||||||
if book:
|
|
||||||
bookname = book.name
|
|
||||||
log.debug(u'bookname corrected to %s' % bookname)
|
|
||||||
verses = self.session.query(Verse).join(Book).filter(
|
|
||||||
Book.name == bookname).filter(Verse.chapter == chapter).filter(
|
|
||||||
Verse.verse>=sverse).filter(Verse.verse<=everse).order_by(
|
|
||||||
Verse.verse).all()
|
|
||||||
return verses
|
|
||||||
|
|
||||||
def get_verses_from_text(self, versetext):
|
|
||||||
log.debug(u'get_verses_from_text %s',versetext)
|
|
||||||
versetext = u'%%%s%%' % versetext
|
|
||||||
verses = self.session.query(Verse).filter(
|
|
||||||
Verse.text.like(versetext)).all()
|
|
||||||
return verses
|
|
||||||
|
|
||||||
def dump_bible(self):
|
def dump_bible(self):
|
||||||
log.debug( u'.........Dumping Bible Database')
|
log.debug( u'.........Dumping Bible Database')
|
||||||
log.debug( '...............................Books ')
|
log.debug( '...............................Books ')
|
||||||
@ -201,3 +287,4 @@ class BibleDB(BibleCommon):
|
|||||||
log.debug( u'...............................Verses ')
|
log.debug( u'...............................Verses ')
|
||||||
verses = self.session.query(Verse).all()
|
verses = self.session.query(Verse).all()
|
||||||
log.debug(verses)
|
log.debug(verses)
|
||||||
|
|
||||||
|
@ -26,17 +26,18 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from common import BibleCommon, SearchResults
|
from common import BibleCommon, SearchResults
|
||||||
|
from db import BibleDB
|
||||||
|
|
||||||
class BGExtract(BibleCommon):
|
class BGExtract(BibleCommon):
|
||||||
global log
|
global log
|
||||||
log = logging.getLogger(u'BibleHTTPMgr(BG_extract)')
|
log = logging.getLogger(u'BibleHTTPMgr(BG_extract)')
|
||||||
log.info(u'BG_extract loaded')
|
log.info(u'BG_extract loaded')
|
||||||
|
|
||||||
def __init__(self, proxyurl= None):
|
def __init__(self, proxyurl=None):
|
||||||
log.debug(u'init %s', proxyurl)
|
log.debug(u'init %s', proxyurl)
|
||||||
self.proxyurl = proxyurl
|
self.proxyurl = proxyurl
|
||||||
|
|
||||||
def get_bible_chapter(self, version, bookname, chapter) :
|
def get_chapter(self, version, bookname, chapter) :
|
||||||
"""
|
"""
|
||||||
Access and decode bibles via the BibleGateway website
|
Access and decode bibles via the BibleGateway website
|
||||||
|
|
||||||
@ -49,12 +50,10 @@ class BGExtract(BibleCommon):
|
|||||||
``chapter``
|
``chapter``
|
||||||
Chapter number
|
Chapter number
|
||||||
"""
|
"""
|
||||||
log.debug(u'get_bible_chapter %s,%s,%s',
|
log.debug(u'get_bible_chapter %s, %s, %s', version, bookname, chapter)
|
||||||
version, bookname, chapter)
|
urlstring = u'http://www.biblegateway.com/passage/?search=%s+%d' \
|
||||||
urlstring = \
|
u'&version=%s' % (bookname, chapter, version)
|
||||||
u'http://www.biblegateway.com/passage/?search=%s+%d&version=%s' % \
|
log.debug(u'BibleGateway url = %s' % urlstring)
|
||||||
(bookname, chapter, version)
|
|
||||||
log.debug(u'BibleGateway urm = %s' % urlstring)
|
|
||||||
xml_string = self._get_web_text(urlstring, self.proxyurl)
|
xml_string = self._get_web_text(urlstring, self.proxyurl)
|
||||||
verseSearch = u'<sup class=\"versenum'
|
verseSearch = u'<sup class=\"versenum'
|
||||||
verseFootnote = u'<sup class=\'footnote'
|
verseFootnote = u'<sup class=\'footnote'
|
||||||
@ -171,11 +170,12 @@ class CWExtract(BibleCommon):
|
|||||||
bible[verse] = self._clean_text(verseText)
|
bible[verse] = self._clean_text(verseText)
|
||||||
return SearchResults(book_title, book_chapter, bible)
|
return SearchResults(book_title, book_chapter, bible)
|
||||||
|
|
||||||
class HTTPBible(object):
|
class HTTPBible(BibleDB):
|
||||||
global log
|
global log
|
||||||
log = logging.getLogger(u'BibleHTTPMgr')
|
log = logging.getLogger(u'BibleHTTPMgr')
|
||||||
log.info(u'BibleHTTP manager loaded')
|
log.info(u'BibleHTTP manager loaded')
|
||||||
def __init__(self):
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
Finds all the bibles defined for the system
|
Finds all the bibles defined for the system
|
||||||
Creates an Interface Object for each bible containing connection
|
Creates an Interface Object for each bible containing connection
|
||||||
@ -185,44 +185,51 @@ class HTTPBible(object):
|
|||||||
|
|
||||||
Init confirms the bible exists and stores the database path.
|
Init confirms the bible exists and stores the database path.
|
||||||
"""
|
"""
|
||||||
self.biblesource = u''
|
if u'download_source' not in kwargs:
|
||||||
self.proxyurl = None
|
raise KeyError(u'Missing keyword argument "download_source"')
|
||||||
self.bibleid = None
|
if u'download_name' not in kwargs:
|
||||||
|
raise KeyError(u'Missing keyword argument "download_name"')
|
||||||
|
self.download_source = kwargs[u'download_source']
|
||||||
|
self.download_name = kwargs[u'download_name']
|
||||||
|
if u'proxy_server' in kwargs:
|
||||||
|
self.proxy_server = kwargs[u'proxy_server']
|
||||||
|
else:
|
||||||
|
self.proxy_server = None
|
||||||
|
if u'proxy_username' in kwargs:
|
||||||
|
self.proxy_username = kwargs[u'proxy_username']
|
||||||
|
else:
|
||||||
|
self.proxy_username = None
|
||||||
|
if u'proxy_password' in kwargs:
|
||||||
|
self.proxy_password = kwargs[u'proxy_password']
|
||||||
|
else:
|
||||||
|
self.proxy_password = None
|
||||||
|
|
||||||
def set_proxy(self, proxyurl):
|
def register(self):
|
||||||
"""
|
name = BibleDB.register(self)
|
||||||
Set the Proxy Url
|
self.create_meta(u'download source', self.download_source)
|
||||||
"""
|
self.create_meta(u'download name', self.download_name)
|
||||||
log.debug(u'set_proxy %s', proxyurl)
|
if self.proxy_server:
|
||||||
self.proxyurl = proxyurl
|
self.create_meta(u'proxy server', self.proxy_server)
|
||||||
|
if self.proxy_username:
|
||||||
|
# store the proxy userid
|
||||||
|
self.create_meta(u'proxy username', self.proxy_username)
|
||||||
|
if self.proxy_password:
|
||||||
|
# store the proxy password
|
||||||
|
self.create_meta(u'proxy password', self.proxy_password)
|
||||||
|
return name
|
||||||
|
|
||||||
def set_bibleid(self, bibleid):
|
def get_bible_chapter(self, version, book, chapter):
|
||||||
"""
|
|
||||||
Set the bible id.
|
|
||||||
The shore identifier of the the bible.
|
|
||||||
"""
|
|
||||||
log.debug(u'set_bibleid %s', bibleid)
|
|
||||||
self.bibleid = bibleid
|
|
||||||
|
|
||||||
def set_bible_source(self, biblesource):
|
|
||||||
"""
|
|
||||||
Set the source of where the bible text is coming from
|
|
||||||
"""
|
|
||||||
log.debug(u'set_bible_source %s', biblesource)
|
|
||||||
self.biblesource = biblesource
|
|
||||||
|
|
||||||
def get_bible_chapter(self, version, bookname, chapter):
|
|
||||||
"""
|
"""
|
||||||
Receive the request and call the relevant handler methods
|
Receive the request and call the relevant handler methods
|
||||||
"""
|
"""
|
||||||
log.debug(u'get_bible_chapter %s,%s,%s',
|
log.debug(u'get_bible_chapter %s,%s,%s',
|
||||||
version, bookname, chapter)
|
version, book, chapter)
|
||||||
log.debug(u'biblesource = %s', self.biblesource)
|
log.debug(u'biblesource = %s', self.biblesource)
|
||||||
try:
|
try:
|
||||||
if self.biblesource.lower() == u'crosswalk':
|
if self.biblesource.lower() == u'crosswalk':
|
||||||
ev = CWExtract(self.proxyurl)
|
ev = CWExtract(self.proxyurl)
|
||||||
else:
|
else:
|
||||||
ev = BGExtract(self.proxyurl)
|
ev = BGExtract(self.proxyurl)
|
||||||
return ev.get_bible_chapter(self.bibleid, bookname, chapter)
|
return ev.get_bible_chapter(self.bibleid, book, chapter)
|
||||||
except:
|
except:
|
||||||
log.exception("Failed to get bible chapter")
|
log.exception("Failed to get bible chapter")
|
||||||
|
@ -26,11 +26,12 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from common import parse_reference
|
||||||
from opensong import OpenSongBible
|
from opensong import OpenSongBible
|
||||||
from osis import OSISBible
|
from osis import OSISBible
|
||||||
from csv import CSVBible
|
from csv import CSVBible
|
||||||
from bibleDBimpl import BibleDBImpl
|
from db import BibleDB
|
||||||
from bibleHTTPimpl import BibleHTTPImpl
|
from http import HTTPBible
|
||||||
|
|
||||||
class BibleMode(object):
|
class BibleMode(object):
|
||||||
"""
|
"""
|
||||||
@ -90,9 +91,9 @@ class BibleManager(object):
|
|||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
"""
|
"""
|
||||||
Finds all the bibles defined for the system and creates an
|
Finds all the bibles defined for the system and creates an interface
|
||||||
interface object for each bible containing connection
|
object for each bible containing connection information. Throws
|
||||||
information. Throws Exception if no Bibles are found.
|
Exception if no Bibles are found.
|
||||||
|
|
||||||
Init confirms the bible exists and stores the database path.
|
Init confirms the bible exists and stores the database path.
|
||||||
|
|
||||||
@ -103,23 +104,23 @@ class BibleManager(object):
|
|||||||
log.debug(u'Bible Initialising')
|
log.debug(u'Bible Initialising')
|
||||||
self.web = u'Web'
|
self.web = u'Web'
|
||||||
# dict of bible database objects
|
# dict of bible database objects
|
||||||
self.bible_db_cache = None
|
self.db_cache = None
|
||||||
# dict of bible http readers
|
# dict of bible http readers
|
||||||
self.bible_http_cache = None
|
self.http_cache = None
|
||||||
self.bible_path = self.config.get_data_path()
|
self.path = self.config.get_data_path()
|
||||||
#get proxy name for screen
|
#get proxy name for screen
|
||||||
self.proxy_name = self.config.get_config(u'proxy name')
|
self.proxy_name = self.config.get_config(u'proxy name')
|
||||||
self.bible_suffix = u'sqlite'
|
self.suffix = u'sqlite'
|
||||||
self.import_wizard = None
|
self.import_wizard = None
|
||||||
self.reload_bibles()
|
self.reload_bibles()
|
||||||
self.media = None
|
self.media = None
|
||||||
|
|
||||||
def reload_bibles(self):
|
def reload_bibles(self):
|
||||||
log.debug(u'Reload bibles')
|
log.debug(u'Reload bibles')
|
||||||
files = self.config.get_files(self.bibleSuffix)
|
files = self.config.get_files(self.suffix)
|
||||||
log.debug(u'Bible Files %s', files)
|
log.debug(u'Bible Files %s', files)
|
||||||
self.bible_db_cache = {}
|
self.db_cache = {}
|
||||||
self.bible_http_cache = {}
|
self.http_cache = {}
|
||||||
# books of the bible with testaments
|
# books of the bible with testaments
|
||||||
self.book_testaments = {}
|
self.book_testaments = {}
|
||||||
# books of the bible with chapter count
|
# books of the bible with chapter count
|
||||||
@ -127,38 +128,32 @@ class BibleManager(object):
|
|||||||
# books of the bible with abbreviation
|
# books of the bible with abbreviation
|
||||||
self.book_abbreviations = {}
|
self.book_abbreviations = {}
|
||||||
self.web_bibles_present = False
|
self.web_bibles_present = False
|
||||||
for f in files:
|
for filename in files:
|
||||||
nme = f.split(u'.')
|
name, extension = os.path.splitext(filename)
|
||||||
bname = nme[0]
|
self.db_cache[name] = BibleDB(path=self.path, name=name, config=self.config)
|
||||||
self.bible_db_cache[bname] = BibleDBImpl(self.bible_path,
|
|
||||||
bname, self.config)
|
|
||||||
# look to see if lazy load bible exists and get create getter.
|
# look to see if lazy load bible exists and get create getter.
|
||||||
biblesource = self.bible_db_cache[bname].get_meta(u'WEB')
|
source = self.db_cache[name].get_meta(u'web')
|
||||||
if biblesource:
|
if source:
|
||||||
self.web_bibles_present = True
|
self.web_bibles_present = True
|
||||||
nhttp = BibleHTTPImpl()
|
web_bible = HTTPBible()
|
||||||
# tell The Server where to get the verses from.
|
# tell The Server where to get the verses from.
|
||||||
nhttp.set_bible_source(biblesource.value)
|
web_bible.set_source(source.value)
|
||||||
self.bible_http_cache [bname] = nhttp
|
self.http_cache[name] = web_bible
|
||||||
# look to see if lazy load bible exists and get create getter.
|
# look to see if lazy load bible exists and get create getter.
|
||||||
meta = self.bible_db_cache[bname].get_meta(u'proxy')
|
meta_proxy = self.db_cache[name].get_meta(u'proxy url')
|
||||||
proxy = None
|
proxy_url = None
|
||||||
if meta:
|
if meta_proxy:
|
||||||
proxy = meta.value
|
proxy_url = meta_proxy.value
|
||||||
# tell The Server where to get the verses from.
|
# tell The Server where to get the verses from.
|
||||||
nhttp.set_proxy(proxy)
|
web_bible.set_proxy_url(proxy_url)
|
||||||
# look to see if lazy load bible exists and get create getter.
|
# look to see if lazy load bible exists and get create getter.
|
||||||
bibleid = self.bible_db_cache[bname].get_meta(u'bibleid').value
|
bible_id = self.db_cache[name].get_meta(u'bible id').value
|
||||||
# tell The Server where to get the verses from.
|
# tell The Server where to get the verses from.
|
||||||
nhttp.set_bibleid(bibleid)
|
web_bible.set_bible_id(bible_id)
|
||||||
else:
|
#else:
|
||||||
# makes the Full / partial code easier.
|
# # makes the Full / partial code easier.
|
||||||
self.bible_http_cache [bname] = None
|
# self.http_cache[name] = None
|
||||||
if self.web_bibles_present:
|
if self.web_bibles_present:
|
||||||
# books of the bible linked to bibleid {osis, name}
|
|
||||||
self.book_testaments = {}
|
|
||||||
# books of the bible linked to bibleid {osis, abbrev}
|
|
||||||
self.book_abbreviations = {}
|
|
||||||
filepath = os.path.split(os.path.abspath(__file__))[0]
|
filepath = os.path.split(os.path.abspath(__file__))[0]
|
||||||
filepath = os.path.abspath(os.path.join(
|
filepath = os.path.abspath(os.path.join(
|
||||||
filepath, u'..', u'resources', u'httpbooks.csv'))
|
filepath, u'..', u'resources', u'httpbooks.csv'))
|
||||||
@ -191,13 +186,18 @@ class BibleManager(object):
|
|||||||
Register a bible in the bible cache, and then import the verses.
|
Register a bible in the bible cache, and then import the verses.
|
||||||
|
|
||||||
``type``
|
``type``
|
||||||
What type of Bible,
|
What type of Bible, one of the BibleFormat values.
|
||||||
|
|
||||||
|
``**kwargs``
|
||||||
|
Keyword arguments to send to the actualy importer class.
|
||||||
"""
|
"""
|
||||||
impl_class = BibleFormat.get_handler(type)
|
class_ = BibleFormat.get_class(type)
|
||||||
bible_impl = impl_class(**kwargs)
|
kwargs[u'path'] = self.path
|
||||||
bible_name = bible_impl.register()
|
kwargs[u'config'] = self.config
|
||||||
BibleDBImpl(self.biblePath, bible_name, self.config)
|
importer = class_(**kwargs)
|
||||||
bible_impl.do_import()
|
name = importer.register()
|
||||||
|
self.db_cache[name] = importer
|
||||||
|
return importer.do_import()
|
||||||
|
|
||||||
def register_http_bible(self, biblename, biblesource, bibleid,
|
def register_http_bible(self, biblename, biblesource, bibleid,
|
||||||
proxyurl=None, proxyid=None, proxypass=None):
|
proxyurl=None, proxyid=None, proxypass=None):
|
||||||
@ -236,9 +236,9 @@ class BibleManager(object):
|
|||||||
nhttp.set_bible_source(biblesource)
|
nhttp.set_bible_source(biblesource)
|
||||||
self.bible_http_cache[biblename] = nhttp
|
self.bible_http_cache[biblename] = nhttp
|
||||||
# register a lazy loading interest
|
# register a lazy loading interest
|
||||||
nbible.save_meta(u'WEB', biblesource)
|
nbible.create_meta(u'WEB', biblesource)
|
||||||
# store the web id of the bible
|
# store the web id of the bible
|
||||||
nbible.save_meta(u'bibleid', bibleid)
|
nbible.create_meta(u'bibleid', bibleid)
|
||||||
if proxyurl:
|
if proxyurl:
|
||||||
# store the proxy URL
|
# store the proxy URL
|
||||||
nbible.save_meta(u'proxy', proxyurl)
|
nbible.save_meta(u'proxy', proxyurl)
|
||||||
@ -326,14 +326,14 @@ class BibleManager(object):
|
|||||||
def get_bibles(self, mode=BibleMode.Full):
|
def get_bibles(self, mode=BibleMode.Full):
|
||||||
"""
|
"""
|
||||||
Returns a list of Books of the bible. When ``mode`` is set to
|
Returns a list of Books of the bible. When ``mode`` is set to
|
||||||
``BibleMode.Full`` this method returns all the Bibles for the
|
``BibleMode.Full`` this method returns all the Bibles for the Advanced
|
||||||
Advanced Search, and when the mode is ``BibleMode.Partial``
|
Search, and when the mode is ``BibleMode.Partial`` this method returns
|
||||||
this method returns all the bibles for the Quick Search.
|
all the bibles for the Quick Search.
|
||||||
"""
|
"""
|
||||||
log.debug(u'get_bibles')
|
log.debug(u'get_bibles')
|
||||||
bible_list = []
|
bible_list = []
|
||||||
for bible_name, bible_object in self.bible_db_cache.iteritems():
|
for bible_name, bible_object in self.db_cache.iteritems():
|
||||||
if self.bible_http_cache[bible_name]:
|
if bible_name in self.http_cache and self.http_cache[bible_name]:
|
||||||
bible_name = u'%s (%s)' % (bible_name, self.web)
|
bible_name = u'%s (%s)' % (bible_name, self.web)
|
||||||
bible_list.append(bible_name)
|
bible_list.append(bible_name)
|
||||||
return bible_list
|
return bible_list
|
||||||
@ -378,14 +378,15 @@ class BibleManager(object):
|
|||||||
return self.bible_db_cache[bible].get_max_bible_book_verses(
|
return self.bible_db_cache[bible].get_max_bible_book_verses(
|
||||||
book, chapter)
|
book, chapter)
|
||||||
|
|
||||||
def get_verse_from_text(self, bible, versetext):
|
def get_verses(self, bible, versetext):
|
||||||
"""
|
"""
|
||||||
Returns all the number of verses for a given
|
Returns all the number of verses for a given
|
||||||
book and chapterMaxBibleBookVerses
|
book and chapterMaxBibleBookVerses
|
||||||
"""
|
"""
|
||||||
log.debug(u'get_verses_from_text %s,%s', bible, versetext)
|
log.debug(u'get_verses_from_text %s,%s', bible, versetext)
|
||||||
|
reflist = parse_reference(versetext)
|
||||||
web, bible = self.is_bible_web(bible)
|
web, bible = self.is_bible_web(bible)
|
||||||
return self.bible_db_cache[bible].get_verses_from_text(versetext)
|
return self.bible_db_cache[bible].get_verses(reflist)
|
||||||
|
|
||||||
def save_meta_data(self, bible, version, copyright, permissions):
|
def save_meta_data(self, bible, version, copyright, permissions):
|
||||||
"""
|
"""
|
||||||
@ -505,12 +506,12 @@ class BibleManager(object):
|
|||||||
text.extend(txt)
|
text.extend(txt)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def _is_new_bible(self, name):
|
def exists(self, name):
|
||||||
"""
|
"""
|
||||||
Check cache to see if new bible
|
Check cache to see if new bible
|
||||||
"""
|
"""
|
||||||
for bible, o in self.bible_db_cache.iteritems():
|
for bible, db_object in self.db_cache.iteritems():
|
||||||
log.debug(u'Bible from cache in is_new_bible %s', bible)
|
log.debug(u'Bible from cache in is_new_bible %s', bible)
|
||||||
if bible == name:
|
if bible == name:
|
||||||
return False
|
|
||||||
return True
|
return True
|
||||||
|
return False
|
||||||
|
@ -32,12 +32,17 @@ from openlp.core.lib import MediaManagerItem, Receiver, str_to_bool, \
|
|||||||
BaseListWithDnD
|
BaseListWithDnD
|
||||||
from openlp.plugins.bibles.forms import ImportWizardForm
|
from openlp.plugins.bibles.forms import ImportWizardForm
|
||||||
from openlp.plugins.bibles.lib.manager import BibleMode
|
from openlp.plugins.bibles.lib.manager import BibleMode
|
||||||
|
from openlp.plugins.bibles.lib.common import parse_reference
|
||||||
|
|
||||||
class BibleListView(BaseListWithDnD):
|
class BibleListView(BaseListWithDnD):
|
||||||
|
"""
|
||||||
|
Drag and drop capable list for Bibles.
|
||||||
|
"""
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
self.PluginName = u'Bibles'
|
self.PluginName = u'Bibles'
|
||||||
BaseListWithDnD.__init__(self, parent)
|
BaseListWithDnD.__init__(self, parent)
|
||||||
|
|
||||||
|
|
||||||
class BibleMediaItem(MediaManagerItem):
|
class BibleMediaItem(MediaManagerItem):
|
||||||
"""
|
"""
|
||||||
This is the custom media manager item for Bibles.
|
This is the custom media manager item for Bibles.
|
||||||
@ -380,8 +385,8 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
if self.ClearQuickSearchComboBox.currentIndex() == 0:
|
if self.ClearQuickSearchComboBox.currentIndex() == 0:
|
||||||
self.ListView.clear()
|
self.ListView.clear()
|
||||||
if self.QuickSearchComboBox.currentIndex() == 1:
|
if self.QuickSearchComboBox.currentIndex() == 1:
|
||||||
self.search_results = self.parent.biblemanager.get_verse_from_text(
|
self.search_results = \
|
||||||
bible, text)
|
self.parent.biblemanager.get_verses(bible, text)
|
||||||
else:
|
else:
|
||||||
self.searchByReference(bible, text)
|
self.searchByReference(bible, text)
|
||||||
if self.search_results:
|
if self.search_results:
|
||||||
|
@ -50,7 +50,7 @@ class BibleMeta(BaseModel):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ONTestament(BaseModel):
|
class Testament(BaseModel):
|
||||||
"""
|
"""
|
||||||
Bible Testaments
|
Bible Testaments
|
||||||
"""
|
"""
|
||||||
@ -101,7 +101,7 @@ verse_table = Table(u'verse', metadata,
|
|||||||
Column(u'text', types.UnicodeText, index=True),
|
Column(u'text', types.UnicodeText, index=True),
|
||||||
)
|
)
|
||||||
mapper(BibleMeta, meta_table)
|
mapper(BibleMeta, meta_table)
|
||||||
mapper(ONTestament, testament_table,
|
mapper(Testament, testament_table,
|
||||||
properties={'books': relation(Book, backref='testament')})
|
properties={'books': relation(Book, backref='testament')})
|
||||||
mapper(Book, book_table,
|
mapper(Book, book_table,
|
||||||
properties={'verses': relation(Verse, backref='book')})
|
properties={'verses': relation(Verse, backref='book')})
|
||||||
|
@ -33,54 +33,34 @@ from lxml import objectify
|
|||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
from openlp.core.lib import Receiver
|
from openlp.core.lib import Receiver
|
||||||
|
from db import BibleDB
|
||||||
|
|
||||||
class OpenSongBible(object):
|
log = logging.getLogger(__name__)
|
||||||
"""
|
|
||||||
OSIS Bible format importer class.
|
|
||||||
"""
|
|
||||||
global log
|
|
||||||
log = logging.getLogger(__name__)
|
|
||||||
log.info(u'BibleOpenSongImpl loaded')
|
|
||||||
|
|
||||||
def __init__(self, biblepath, bibledb):
|
class OpenSongBible(BibleDB):
|
||||||
"""
|
"""
|
||||||
Constructor to create and set up an instance of the
|
OpenSong Bible format importer class.
|
||||||
BibleOpenSongImpl class.
|
|
||||||
|
|
||||||
``biblepath``
|
|
||||||
This does not seem to be used.
|
|
||||||
|
|
||||||
``bibledb``
|
|
||||||
A reference to a Bible database object.
|
|
||||||
"""
|
"""
|
||||||
log.info(u'BibleOpenSongImpl Initialising')
|
|
||||||
self.bibledb = bibledb
|
|
||||||
self.loadbible = True
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
|
||||||
QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
|
|
||||||
|
|
||||||
def stop_import(self):
|
def __init__(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
Stops the import of the Bible.
|
Constructor to create and set up an instance of the OpenSongBible
|
||||||
|
class. This class is used to import Bibles from OpenSong's XML format.
|
||||||
"""
|
"""
|
||||||
self.loadbible = False
|
log.debug(__name__)
|
||||||
|
BibleDB.__init__(self, **kwargs)
|
||||||
|
if u'filename' not in kwargs:
|
||||||
|
raise KeyError(u'You have to supply a file name to import from.')
|
||||||
|
self.filename = kwargs[u'filename']
|
||||||
|
|
||||||
def load_data(self, bible_file, dialogobject=None):
|
def do_import(self):
|
||||||
"""
|
"""
|
||||||
Loads a Bible from file.
|
Loads a Bible from file.
|
||||||
|
|
||||||
``bible_file``
|
|
||||||
The file to import from.
|
|
||||||
|
|
||||||
``dialogobject``
|
|
||||||
The Import dialog, so that we can increase the counter on
|
|
||||||
the progress bar.
|
|
||||||
"""
|
"""
|
||||||
log.info(u'Load data for %s' % bible_file)
|
log.debug(u'Starting OpenSong import from "%s"' % self.filename)
|
||||||
bible_file = unicode(bible_file)
|
|
||||||
detect_file = None
|
detect_file = None
|
||||||
try:
|
try:
|
||||||
detect_file = open(bible_file, u'r')
|
detect_file = open(self.filename, u'r')
|
||||||
details = chardet.detect(detect_file.read(3000))
|
details = chardet.detect(detect_file.read(3000))
|
||||||
except:
|
except:
|
||||||
log.exception(u'Failed to detect OpenSong file encoding')
|
log.exception(u'Failed to detect OpenSong file encoding')
|
||||||
@ -88,39 +68,37 @@ class OpenSongBible(object):
|
|||||||
finally:
|
finally:
|
||||||
if detect_file:
|
if detect_file:
|
||||||
detect_file.close()
|
detect_file.close()
|
||||||
opensong_bible = None
|
file = None
|
||||||
success = True
|
success = True
|
||||||
try:
|
try:
|
||||||
opensong_bible = codecs.open(bible_file, u'r', details['encoding'])
|
file = codecs.open(self.filename, u'r', details['encoding'])
|
||||||
opensong = objectify.parse(opensong_bible)
|
opensong = objectify.parse(file)
|
||||||
bible = opensong.getroot()
|
bible = opensong.getroot()
|
||||||
for book in bible.b:
|
for book in bible.b:
|
||||||
if not self.loadbible:
|
if self.stop_import:
|
||||||
break
|
break
|
||||||
dbbook = self.bibledb.create_book(book.attrib[u'n'],
|
db_book = self.create_book(book.attrib[u'n'],
|
||||||
book.attrib[u'n'][:4])
|
book.attrib[u'n'][:4])
|
||||||
for chapter in book.c:
|
for chapter in book.c:
|
||||||
if not self.loadbible:
|
if self.stop_import:
|
||||||
break
|
break
|
||||||
for verse in chapter.v:
|
for verse in chapter.v:
|
||||||
if not self.loadbible:
|
if self.stop_import:
|
||||||
break
|
break
|
||||||
self.bibledb.add_verse(dbbook.id, chapter.attrib[u'n'],
|
self.add_verse(db_book.id, chapter.attrib[u'n'],
|
||||||
verse.attrib[u'n'], verse.text)
|
verse.attrib[u'n'], verse.text)
|
||||||
Receiver.send_message(u'process_events')
|
Receiver.send_message(u'process_events')
|
||||||
dialogobject.incrementProgressBar(u'Importing %s %s' % \
|
self.wizard.incrementProgressBar(u'Importing %s %s' % \
|
||||||
(dbbook.name, str(chapter.attrib[u'n'])))
|
(dbbook.name, str(chapter.attrib[u'n'])))
|
||||||
self.bibledb.save_verses()
|
self.commit()
|
||||||
except:
|
except:
|
||||||
log.exception(u'Loading bible from OpenSong file failed')
|
log.exception(u'Loading bible from OpenSong file failed')
|
||||||
success = False
|
success = False
|
||||||
finally:
|
finally:
|
||||||
if opensong_bible:
|
if file:
|
||||||
opensong_bible.close()
|
file.close()
|
||||||
if not self.loadbible:
|
if self.stop_import:
|
||||||
dialogobject.incrementProgressBar(u'Import canceled!')
|
self.wizard.incrementProgressBar(u'Import canceled!')
|
||||||
dialogobject.ImportProgressBar.setValue(
|
|
||||||
dialogobject.ImportProgressBar.maximum())
|
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return success
|
return success
|
||||||
|
@ -33,8 +33,9 @@ import re
|
|||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
from openlp.core.lib import Receiver
|
from openlp.core.lib import Receiver
|
||||||
|
from db import BibleDB
|
||||||
|
|
||||||
class OSISBible(object):
|
class OSISBible(BibleDB):
|
||||||
"""
|
"""
|
||||||
OSIS Bible format importer class.
|
OSIS Bible format importer class.
|
||||||
"""
|
"""
|
||||||
@ -42,18 +43,16 @@ class OSISBible(object):
|
|||||||
log = logging.getLogger(u'BibleOSISImpl')
|
log = logging.getLogger(u'BibleOSISImpl')
|
||||||
log.info(u'BibleOSISImpl loaded')
|
log.info(u'BibleOSISImpl loaded')
|
||||||
|
|
||||||
def __init__(self, biblepath, bibledb):
|
def __init__(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
Constructor to create and set up an instance of the
|
Constructor to create and set up an instance of the OpenSongBible
|
||||||
BibleOSISImpl class.
|
class. This class is used to import Bibles from OpenSong's XML format.
|
||||||
|
|
||||||
``biblepath``
|
|
||||||
This does not seem to be used.
|
|
||||||
|
|
||||||
``bibledb``
|
|
||||||
A reference to a Bible database object.
|
|
||||||
"""
|
"""
|
||||||
log.info(u'BibleOSISImpl Initialising')
|
log.debug(__name__)
|
||||||
|
BibleDB.__init__(self, **kwargs)
|
||||||
|
if u'filename' not in kwargs:
|
||||||
|
raise KeyError(u'You have to supply a file name to import from.')
|
||||||
|
self.filename = kwargs[u'filename']
|
||||||
self.verse_regex = re.compile(
|
self.verse_regex = re.compile(
|
||||||
r'<verse osisID="([a-zA-Z0-9 ]*).([0-9]*).([0-9]*)">(.*?)</verse>')
|
r'<verse osisID="([a-zA-Z0-9 ]*).([0-9]*).([0-9]*)">(.*?)</verse>')
|
||||||
self.note_regex = re.compile(r'<note(.*?)>(.*?)</note>')
|
self.note_regex = re.compile(r'<note(.*?)>(.*?)</note>')
|
||||||
@ -66,13 +65,11 @@ class OSISBible(object):
|
|||||||
self.w_regex = re.compile(r'<w (.*?)>')
|
self.w_regex = re.compile(r'<w (.*?)>')
|
||||||
self.q_regex = re.compile(r'<q (.*?)>')
|
self.q_regex = re.compile(r'<q (.*?)>')
|
||||||
self.spaces_regex = re.compile(r'([ ]{2,})')
|
self.spaces_regex = re.compile(r'([ ]{2,})')
|
||||||
self.bibledb = bibledb
|
|
||||||
self.books = {}
|
self.books = {}
|
||||||
filepath = os.path.split(os.path.abspath(__file__))[0]
|
filepath = os.path.split(os.path.abspath(__file__))[0]
|
||||||
filepath = os.path.abspath(os.path.join(
|
filepath = os.path.abspath(os.path.join(
|
||||||
filepath, u'..', u'resources', u'osisbooks.csv'))
|
filepath, u'..', u'resources', u'osisbooks.csv'))
|
||||||
fbibles = None
|
fbibles = None
|
||||||
self.loadbible = True
|
|
||||||
try:
|
try:
|
||||||
fbibles = open(filepath, u'r')
|
fbibles = open(filepath, u'r')
|
||||||
for line in fbibles:
|
for line in fbibles:
|
||||||
@ -84,31 +81,15 @@ class OSISBible(object):
|
|||||||
finally:
|
finally:
|
||||||
if fbibles:
|
if fbibles:
|
||||||
fbibles.close()
|
fbibles.close()
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
|
||||||
QtCore.SIGNAL(u'openlpstopimport'), self.stop_import)
|
|
||||||
|
|
||||||
def stop_import(self):
|
def do_import(self):
|
||||||
"""
|
|
||||||
Stops the import of the Bible.
|
|
||||||
"""
|
|
||||||
log.debug('Stopping import!')
|
|
||||||
self.loadbible = False
|
|
||||||
|
|
||||||
def load_data(self, osisfile_record, dialogobject=None):
|
|
||||||
"""
|
"""
|
||||||
Loads a Bible from file.
|
Loads a Bible from file.
|
||||||
|
|
||||||
``osisfile_record``
|
|
||||||
The file to import from.
|
|
||||||
|
|
||||||
``dialogobject``
|
|
||||||
The Import dialog, so that we can increase the counter on
|
|
||||||
the progress bar.
|
|
||||||
"""
|
"""
|
||||||
log.info(u'Load data for %s' % osisfile_record)
|
log.debug(u'Starting OSIS import from "%s"' % self.filename)
|
||||||
detect_file = None
|
detect_file = None
|
||||||
try:
|
try:
|
||||||
detect_file = open(osisfile_record, u'r')
|
detect_file = open(self.filename, u'r')
|
||||||
details = chardet.detect(detect_file.read(3000))
|
details = chardet.detect(detect_file.read(3000))
|
||||||
except:
|
except:
|
||||||
log.exception(u'Failed to detect OSIS file encoding')
|
log.exception(u'Failed to detect OSIS file encoding')
|
||||||
@ -119,12 +100,12 @@ class OSISBible(object):
|
|||||||
osis = None
|
osis = None
|
||||||
success = True
|
success = True
|
||||||
try:
|
try:
|
||||||
osis = codecs.open(osisfile_record, u'r', details['encoding'])
|
osis = codecs.open(self.filename, u'r', details['encoding'])
|
||||||
last_chapter = 0
|
last_chapter = 0
|
||||||
testament = 1
|
testament = 1
|
||||||
db_book = None
|
db_book = None
|
||||||
for file_record in osis:
|
for file_record in osis:
|
||||||
if not self.loadbible:
|
if self.stop_import:
|
||||||
break
|
break
|
||||||
match = self.verse_regex.search(file_record)
|
match = self.verse_regex.search(file_record)
|
||||||
if match:
|
if match:
|
||||||
@ -142,13 +123,13 @@ class OSISBible(object):
|
|||||||
testament)
|
testament)
|
||||||
if last_chapter == 0:
|
if last_chapter == 0:
|
||||||
if book == u'Gen':
|
if book == u'Gen':
|
||||||
dialogobject.ImportProgressBar.setMaximum(1188)
|
self.wizard.ImportProgressBar.setMaximum(1188)
|
||||||
else:
|
else:
|
||||||
dialogobject.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()
|
self.bibledb.save_verses()
|
||||||
dialogobject.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))
|
||||||
last_chapter = chapter
|
last_chapter = chapter
|
||||||
@ -170,20 +151,18 @@ class OSISBible(object):
|
|||||||
.replace(u'</lg>', u'').replace(u'</q>', u'')\
|
.replace(u'</lg>', u'').replace(u'</q>', u'')\
|
||||||
.replace(u'</div>', u'')
|
.replace(u'</div>', u'')
|
||||||
verse_text = self.spaces_regex.sub(u' ', verse_text)
|
verse_text = self.spaces_regex.sub(u' ', verse_text)
|
||||||
self.bibledb.add_verse(db_book.id, chapter, verse, verse_text)
|
self.add_verse(db_book.id, chapter, verse, verse_text)
|
||||||
Receiver.send_message(u'process_events')
|
Receiver.send_message(u'process_events')
|
||||||
self.bibledb.save_verses()
|
self.commit()
|
||||||
dialogobject.incrementProgressBar(u'Finishing import...')
|
self.wizard.incrementProgressBar(u'Finishing import...')
|
||||||
except:
|
except:
|
||||||
log.exception(u'Loading bible from OSIS file failed')
|
log.exception(u'Loading bible from OSIS file failed')
|
||||||
success = False
|
success = False
|
||||||
finally:
|
finally:
|
||||||
if osis:
|
if osis:
|
||||||
osis.close()
|
osis.close()
|
||||||
if not self.loadbible:
|
if self.stop_import:
|
||||||
dialogobject.incrementProgressBar(u'Import canceled!')
|
self.wizard.incrementProgressBar(u'Import canceled!')
|
||||||
dialogobject.ImportProgressBar.setValue(
|
|
||||||
dialogobject.ImportProgressBar.maximum())
|
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return success
|
return success
|
||||||
|
Loading…
Reference in New Issue
Block a user