Removed "dbversion" as it is not actually used.

Renamed some other variables.
Removed one use of "proxy_url" which was pretty much invalid.
This commit is contained in:
Raoul Snyman 2012-04-22 20:19:36 +02:00
parent 4452d4834c
commit b6cf925bd8
6 changed files with 59 additions and 42 deletions

View File

@ -418,28 +418,29 @@ class BibleUpgradeForm(OpenLPWizard):
if meta[u'key'] == u'Bookname language':
meta[u'key'] = 'book_name_language'
meta[u'key'] = meta[u'key'].lower().replace(' ', '_')
# Copy the metadata
meta_data[meta[u'key']] = meta[u'value']
if meta[u'key'] != u'name' and meta[u'key'] != u'dbversion':
self.newbibles[number].save_meta(meta[u'key'],
meta[u'value'])
if meta[u'key'] == u'download source':
if meta[u'key'] == u'download_source':
web_bible = True
self.includeWebBible = True
if meta.has_key(u'proxy server'):
proxy_server = meta[u'proxy server']
if meta.has_key(u'proxy_server'):
proxy_server = meta[u'proxy_server']
if web_bible:
if meta_data[u'download source'].lower() == u'crosswalk':
if meta_data[u'download_source'].lower() == u'crosswalk':
handler = CWExtract(proxy_server)
elif meta_data[u'download source'].lower() == u'biblegateway':
elif meta_data[u'download_source'].lower() == u'biblegateway':
handler = BGExtract(proxy_server)
elif meta_data[u'download source'].lower() == u'bibleserver':
elif meta_data[u'download_source'].lower() == u'bibleserver':
handler = BSExtract(proxy_server)
books = handler.get_books_from_http(meta_data[u'download name'])
books = handler.get_books_from_http(meta_data[u'download_name'])
if not books:
log.error(u'Upgrading books from %s - download '\
u'name: "%s" failed' % (
meta_data[u'download source'],
meta_data[u'download name']))
meta_data[u'download_source'],
meta_data[u'download_name']))
self.newbibles[number].session.close()
del self.newbibles[number]
critical_error_message_box(
@ -456,8 +457,8 @@ class BibleUpgradeForm(OpenLPWizard):
self.success[number] = False
continue
bible = BiblesResourcesDB.get_webbible(
meta_data[u'download name'],
meta_data[u'download source'].lower())
meta_data[u'download_name'],
meta_data[u'download_source'].lower())
if bible and bible[u'language_id']:
language_id = bible[u'language_id']
self.newbibles[number].save_meta(u'language_id',
@ -490,8 +491,8 @@ class BibleUpgradeForm(OpenLPWizard):
if not book_ref_id:
log.warn(u'Upgrading books from %s - download '\
u'name: "%s" aborted by user' % (
meta_data[u'download source'],
meta_data[u'download name']))
meta_data[u'download_source'],
meta_data[u'download_name']))
self.newbibles[number].session.close()
del self.newbibles[number]
self.success[number] = False

View File

@ -76,7 +76,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
int(book_name_language.value) + 1)
self.books = {}
self.webbible = self.manager.get_meta_data(self.bible,
u'download source')
u'download_source')
if self.webbible:
self.bookNameNotice.setText(translate('BiblesPlugin.EditBibleForm',
'This is a Web Download Bible.\nIt is not possible to '

View File

@ -183,7 +183,6 @@ class BibleDB(QtCore.QObject, Manager):
The actual Qt wizard form.
"""
self.wizard = wizard
self.save_meta(u'dbversion', u'2')
return self.name
def create_book(self, name, bk_ref_id, testament=1):

View File

@ -49,9 +49,9 @@ class BGExtract(object):
"""
Extract verses from BibleGateway
"""
def __init__(self, proxyurl=None):
log.debug(u'BGExtract.init("%s")', proxyurl)
self.proxyurl = proxyurl
def __init__(self, proxy_url=None):
log.debug(u'BGExtract.init("%s")', proxy_url)
self.proxy_url = proxy_url
socket.setdefaulttimeout(30)
def get_bible_chapter(self, version, book_name, chapter):
@ -195,9 +195,9 @@ class BSExtract(object):
"""
Extract verses from Bibleserver.com
"""
def __init__(self, proxyurl=None):
log.debug(u'BSExtract.init("%s")', proxyurl)
self.proxyurl = proxyurl
def __init__(self, proxy_url=None):
log.debug(u'BSExtract.init("%s")', proxy_url)
self.proxy_url = proxy_url
socket.setdefaulttimeout(30)
def get_bible_chapter(self, version, book_name, chapter):
@ -268,9 +268,9 @@ class CWExtract(object):
"""
Extract verses from CrossWalk/BibleStudyTools
"""
def __init__(self, proxyurl=None):
log.debug(u'CWExtract.init("%s")', proxyurl)
self.proxyurl = proxyurl
def __init__(self, proxy_url=None):
log.debug(u'CWExtract.init("%s")', proxy_url)
self.proxy_url = proxy_url
socket.setdefaulttimeout(30)
def get_bible_chapter(self, version, book_name, chapter):
@ -401,16 +401,16 @@ class HTTPBible(BibleDB):
self.wizard.incrementProgressBar(unicode(translate(
'BiblesPlugin.HTTPBible',
'Registering Bible and loading books...')))
self.save_meta(u'download source', self.download_source)
self.save_meta(u'download name', self.download_name)
self.save_meta(u'download_source', self.download_source)
self.save_meta(u'download_name', self.download_name)
if self.proxy_server:
self.save_meta(u'proxy server', self.proxy_server)
self.save_meta(u'proxy_server', self.proxy_server)
if self.proxy_username:
# Store the proxy userid.
self.save_meta(u'proxy username', self.proxy_username)
self.save_meta(u'proxy_username', self.proxy_username)
if self.proxy_password:
# Store the proxy password.
self.save_meta(u'proxy password', self.proxy_password)
self.save_meta(u'proxy_password', self.proxy_password)
if self.download_source.lower() == u'crosswalk':
handler = CWExtract(self.proxy_server)
elif self.download_source.lower() == u'biblegateway':

View File

@ -164,12 +164,12 @@ class BibleManager(object):
self.db_cache[name] = bible
# Look to see if lazy load bible exists and get create getter.
source = self.db_cache[name].get_object(BibleMeta,
u'download source')
u'download_source')
if source:
download_name = self.db_cache[name].get_object(BibleMeta,
u'download name').value
u'download_name').value
meta_proxy = self.db_cache[name].get_object(BibleMeta,
u'proxy url')
u'proxy_server')
web_bible = HTTPBible(self.parent, path=self.path,
file=filename, download_source=source.value,
download_name=download_name)
@ -410,17 +410,17 @@ class BibleManager(object):
return None
# Check if the bible or second_bible is a web bible.
webbible = self.db_cache[bible].get_object(BibleMeta,
u'download source')
u'download_source')
second_webbible = u''
if second_bible:
second_webbible = self.db_cache[second_bible].get_object(BibleMeta,
u'download source')
u'download_source')
if webbible or second_webbible:
Receiver.send_message(u'openlp_information_message', {
u'title': translate('BiblesPlugin.BibleManager',
'Web Bible cannot be used'),
'Web Bible cannot be used'),
u'message': translate('BiblesPlugin.BibleManager',
'Text Search is not available with Web Bibles.')
'Text Search is not available with Web Bibles.')
})
return None
if text:
@ -428,12 +428,12 @@ class BibleManager(object):
else:
Receiver.send_message(u'openlp_information_message', {
u'title': translate('BiblesPlugin.BibleManager',
'Scripture Reference Error'),
'Scripture Reference Error'),
u'message': translate('BiblesPlugin.BibleManager',
'You did not enter a search keyword.\n'
'You can separate different keywords by a space to search for '
'all of your keywords and you can separate them by a comma to '
'search for one of them.')
'You did not enter a search keyword.\n'
'You can separate different keywords by a space to '
'search for all of your keywords and you can separate '
'them by a comma to search for one of them.')
})
return None

View File

@ -29,7 +29,7 @@ The :mod:`upgrade` module provides a way for the database and schema that is the
backend for the Bibles plugin
"""
from sqlalchemy import Table, update, or_
from sqlalchemy import Table, update, delete, or_
__version__ = 1
@ -70,4 +70,21 @@ def upgrade_1(session, metadata, tables):
session.execute(update(metadata_table)\
.where(metadata_table.c.key == u'Permissions')\
.values(key=u'permissions'))
session.execute(update(metadata_table)\
.where(metadata_table.c.key == u'download source')\
.values(key=u'download_source'))
session.execute(update(metadata_table)\
.where(metadata_table.c.key == u'download name')\
.values(key=u'download_name'))
session.execute(update(metadata_table)\
.where(metadata_table.c.key == u'proxy server')\
.values(key=u'proxy_server'))
session.execute(update(metadata_table)\
.where(metadata_table.c.key == u'proxy username')\
.values(key=u'proxy_username'))
session.execute(update(metadata_table)\
.where(metadata_table.c.key == u'proxy password')\
.values(key=u'proxy_password'))
session.execute(delete(metadata_table)\
.where(metadata_table.c.key == u'dbversion'))
session.commit()