fixed short lines

This commit is contained in:
Andreas Preikschat 2013-02-04 22:39:44 +01:00
parent a72b4283bf
commit 8f5fe64d3e
3 changed files with 18 additions and 37 deletions

View File

@ -61,8 +61,7 @@ def init_db(url, auto_flush=True, auto_commit=False):
""" """
engine = create_engine(url, poolclass=NullPool) engine = create_engine(url, poolclass=NullPool)
metadata = MetaData(bind=engine) metadata = MetaData(bind=engine)
session = scoped_session(sessionmaker(autoflush=auto_flush, session = scoped_session(sessionmaker(autoflush=auto_flush, autocommit=auto_commit, bind=engine))
autocommit=auto_commit, bind=engine))
return session, metadata return session, metadata

View File

@ -139,8 +139,7 @@ class ScreenList(object):
""" """
screen_list = [] screen_list = []
for screen in self.screen_list: for screen in self.screen_list:
screen_name = u'%s %d' % (translate('OpenLP.ScreenList', 'Screen'), screen_name = u'%s %d' % (translate('OpenLP.ScreenList', 'Screen'), screen[u'number'] + 1)
screen[u'number'] + 1)
if screen[u'primary']: if screen[u'primary']:
screen_name = u'%s (%s)' % (screen_name, translate('OpenLP.ScreenList', 'primary')) screen_name = u'%s (%s)' % (screen_name, translate('OpenLP.ScreenList', 'primary'))
screen_list.append(screen_name) screen_list.append(screen_name)
@ -237,8 +236,7 @@ class ScreenList(object):
y = window.y() + (window.height() / 2) y = window.y() + (window.height() / 2)
for screen in self.screen_list: for screen in self.screen_list:
size = screen[u'size'] size = screen[u'size']
if x >= size.x() and x <= (size.x() + size.width()) and \ if x >= size.x() and x <= (size.x() + size.width()) and y >= size.y() and y <= (size.y() + size.height()):
y >= size.y() and y <= (size.y() + size.height()):
return screen[u'number'] return screen[u'number']
def load_screen_settings(self): def load_screen_settings(self):

View File

@ -203,8 +203,7 @@ class BGExtract(object):
if clean_verse_num: if clean_verse_num:
verse_text = raw_verse_num.next verse_text = raw_verse_num.next
part = raw_verse_num.next.next part = raw_verse_num.next.next
while not (isinstance(part, Tag) and while not (isinstance(part, Tag) and part.get(u'class') == u'versenum'):
part.get(u'class') == u'versenum'):
# While we are still in the same verse grab all the text. # While we are still in the same verse grab all the text.
if isinstance(part, NavigableString): if isinstance(part, NavigableString):
verse_text += part verse_text += part
@ -320,12 +319,10 @@ class BSExtract(object):
``chapter`` ``chapter``
Chapter number Chapter number
""" """
log.debug(u'BSExtract.get_bible_chapter("%s", "%s", "%s")', version, log.debug(u'BSExtract.get_bible_chapter("%s", "%s", "%s")', version, book_name, chapter)
book_name, chapter)
url_version = urllib.quote(version.encode("utf-8")) url_version = urllib.quote(version.encode("utf-8"))
url_book_name = urllib.quote(book_name.encode("utf-8")) url_book_name = urllib.quote(book_name.encode("utf-8"))
chapter_url = u'http://m.bibleserver.com/text/%s/%s%d' % \ chapter_url = u'http://m.bibleserver.com/text/%s/%s%d' % (url_version, url_book_name, chapter)
(url_version, url_book_name, chapter)
header = (u'Accept-Language', u'en') header = (u'Accept-Language', u'en')
soup = get_soup_for_bible_ref(chapter_url, header) soup = get_soup_for_bible_ref(chapter_url, header)
if not soup: if not soup:
@ -355,8 +352,7 @@ class BSExtract(object):
""" """
log.debug(u'BSExtract.get_books_from_http("%s")', version) log.debug(u'BSExtract.get_books_from_http("%s")', version)
urlversion = urllib.quote(version.encode("utf-8")) urlversion = urllib.quote(version.encode("utf-8"))
chapter_url = u'http://m.bibleserver.com/overlay/selectBook?'\ chapter_url = u'http://m.bibleserver.com/overlay/selectBook?translation=%s' % (urlversion)
'translation=%s' % (urlversion)
soup = get_soup_for_bible_ref(chapter_url) soup = get_soup_for_bible_ref(chapter_url)
if not soup: if not soup:
return None return None
@ -366,9 +362,7 @@ class BSExtract(object):
send_error_message(u'parse') send_error_message(u'parse')
return None return None
content = content.findAll(u'li') content = content.findAll(u'li')
return [ return [book.contents[0].contents[0] for book in content]
book.contents[0].contents[0] for book in content
]
class CWExtract(object): class CWExtract(object):
@ -393,13 +387,11 @@ class CWExtract(object):
``chapter`` ``chapter``
Chapter number Chapter number
""" """
log.debug(u'CWExtract.get_bible_chapter("%s", "%s", "%s")', version, log.debug(u'CWExtract.get_bible_chapter("%s", "%s", "%s")', version, book_name, chapter)
book_name, chapter)
url_book_name = book_name.replace(u' ', u'-') url_book_name = book_name.replace(u' ', u'-')
url_book_name = url_book_name.lower() url_book_name = url_book_name.lower()
url_book_name = urllib.quote(url_book_name.encode("utf-8")) url_book_name = urllib.quote(url_book_name.encode("utf-8"))
chapter_url = u'http://www.biblestudytools.com/%s/%s/%s.html' % \ chapter_url = u'http://www.biblestudytools.com/%s/%s/%s.html' % (version, url_book_name, chapter)
(version, url_book_name, chapter)
soup = get_soup_for_bible_ref(chapter_url) soup = get_soup_for_bible_ref(chapter_url)
if not soup: if not soup:
return None return None
@ -448,8 +440,7 @@ class CWExtract(object):
The version of the bible like NIV for New International Version The version of the bible like NIV for New International Version
""" """
log.debug(u'CWExtract.get_books_from_http("%s")', version) log.debug(u'CWExtract.get_books_from_http("%s")', version)
chapter_url = u'http://www.biblestudytools.com/%s/'\ chapter_url = u'http://www.biblestudytools.com/%s/' % (version)
% (version)
soup = get_soup_for_bible_ref(chapter_url) soup = get_soup_for_bible_ref(chapter_url)
if not soup: if not soup:
return None return None
@ -503,9 +494,7 @@ class HTTPBible(BibleDB):
``True`` on success, ``False`` on failure. ``True`` on success, ``False`` on failure.
""" """
self.wizard.progressBar.setMaximum(68) self.wizard.progressBar.setMaximum(68)
self.wizard.incrementProgressBar(translate( self.wizard.incrementProgressBar(translate('BiblesPlugin.HTTPBible', 'Registering Bible and loading books...'))
'BiblesPlugin.HTTPBible',
'Registering Bible and loading books...'))
self.save_meta(u'download_source', self.download_source) self.save_meta(u'download_source', self.download_source)
self.save_meta(u'download_name', self.download_name) self.save_meta(u'download_name', self.download_name)
if self.proxy_server: if self.proxy_server:
@ -527,19 +516,16 @@ class HTTPBible(BibleDB):
log.exception(u'Importing books from %s - download name: "%s" '\ log.exception(u'Importing books from %s - download name: "%s" '\
'failed' % (self.download_source, self.download_name)) 'failed' % (self.download_source, self.download_name))
return False return False
self.wizard.progressBar.setMaximum(len(books)+2) self.wizard.progressBar.setMaximum(len(books) + 2)
self.wizard.incrementProgressBar(translate( self.wizard.incrementProgressBar(translate( 'BiblesPlugin.HTTPBible', 'Registering Language...'))
'BiblesPlugin.HTTPBible', 'Registering Language...')) bible = BiblesResourcesDB.get_webbible(self.download_name, self.download_source.lower())
bible = BiblesResourcesDB.get_webbible(self.download_name,
self.download_source.lower())
if bible[u'language_id']: if bible[u'language_id']:
language_id = bible[u'language_id'] language_id = bible[u'language_id']
self.save_meta(u'language_id', language_id) self.save_meta(u'language_id', language_id)
else: else:
language_id = self.get_language(bible_name) language_id = self.get_language(bible_name)
if not language_id: if not language_id:
log.exception(u'Importing books from %s " '\ log.exception(u'Importing books from %s failed' % self.filename)
'failed' % self.filename)
return False return False
for book in books: for book in books:
if self.stop_import_flag: if self.stop_import_flag:
@ -547,8 +533,7 @@ class HTTPBible(BibleDB):
self.wizard.incrementProgressBar(translate( self.wizard.incrementProgressBar(translate(
'BiblesPlugin.HTTPBible', 'Importing %s...', 'BiblesPlugin.HTTPBible', 'Importing %s...',
'Importing <book name>...') % book) 'Importing <book name>...') % book)
book_ref_id = self.get_book_ref_id_by_name(book, len(books), book_ref_id = self.get_book_ref_id_by_name(book, len(books), language_id)
language_id)
if not book_ref_id: if not book_ref_id:
log.exception(u'Importing books from %s - download name: "%s" '\ log.exception(u'Importing books from %s - download name: "%s" '\
'failed' % (self.download_source, self.download_name)) 'failed' % (self.download_source, self.download_name))
@ -608,8 +593,7 @@ class HTTPBible(BibleDB):
self.application.process_events() self.application.process_events()
# Check to see if book/chapter exists. # Check to see if book/chapter exists.
db_book = self.get_book(book_name) db_book = self.get_book(book_name)
self.create_chapter(db_book.id, search_results.chapter, self.create_chapter(db_book.id, search_results.chapter, search_results.verselist)
search_results.verselist)
self.application.process_events() self.application.process_events()
self.application.set_normal_cursor() self.application.set_normal_cursor()
self.application.process_events() self.application.process_events()