small cleanups

This commit is contained in:
Armin Köhler 2011-04-16 13:52:20 +02:00
parent e8202924f7
commit 23c8ea8679
7 changed files with 17 additions and 15 deletions

View File

@ -101,7 +101,7 @@ class CSVBible(BibleDB):
success = True success = True
language_id = self.get_language() language_id = self.get_language()
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
books_file = None books_file = None
@ -120,7 +120,7 @@ class CSVBible(BibleDB):
book_ref_id = self.get_book_ref_id_by_name( book_ref_id = self.get_book_ref_id_by_name(
unicode(line[2], details['encoding']), language_id) unicode(line[2], details['encoding']), language_id)
if not book_ref_id: if not book_ref_id:
log.exception(u'Importing books from %s " '\ log.exception(u'Importing books from "%s" '\
'failed' % self.booksfile) 'failed' % self.booksfile)
return False return False
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)

View File

@ -618,7 +618,8 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
``chapter`` ``chapter``
The chapter number. The chapter number.
""" """
log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_id, chapter) log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_id,
chapter)
if not isinstance(chapter, int): if not isinstance(chapter, int):
chapter = int(chapter) chapter = int(chapter)
chapters = BiblesResourcesDB.run_sql(u'SELECT id, book_reference_id, ' chapters = BiblesResourcesDB.run_sql(u'SELECT id, book_reference_id, '
@ -770,8 +771,8 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
u'= ? ORDER BY id', (name, language_id)) u'= ? ORDER BY id', (name, language_id))
else: else:
id = BiblesResourcesDB.run_sql(u'SELECT book_reference_id ' id = BiblesResourcesDB.run_sql(u'SELECT book_reference_id '
u'FROM alternative_book_names WHERE name = ? ORDER BY id', ( u'FROM alternative_book_names WHERE name = ? ORDER BY id',
name, )) (name, ))
if id: if id:
return int(id[0][0]) return int(id[0][0])
else: else:

View File

@ -214,7 +214,8 @@ class BibleManager(object):
books.append( books.append(
{ {
u'name': book.name, u'name': book.name,
u'chapters': self.db_cache[bible].get_chapter_count(book.book_reference_id) u'chapters': self.db_cache[bible].get_chapter_count(
book.book_reference_id)
}) })
return books return books

View File

@ -59,7 +59,7 @@ class OpenLP1Bible(BibleDB):
#Create the bible language #Create the bible language
language_id = self.get_language() language_id = self.get_language()
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
# Create all books. # Create all books.
@ -76,7 +76,7 @@ class OpenLP1Bible(BibleDB):
abbreviation = unicode(book[3], u'cp1252') abbreviation = unicode(book[3], u'cp1252')
book_ref_id = self.get_book_ref_id_by_name(name, language_id) book_ref_id = self.get_book_ref_id_by_name(name, language_id)
if not book_ref_id: if not book_ref_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
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)

View File

@ -63,7 +63,7 @@ class OpenSongBible(BibleDB):
bible = opensong.getroot() bible = opensong.getroot()
language_id = self.get_language() language_id = self.get_language()
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 bible.b: for book in bible.b:
@ -72,7 +72,7 @@ class OpenSongBible(BibleDB):
book_ref_id = self.get_book_ref_id_by_name( book_ref_id = self.get_book_ref_id_by_name(
unicode(book.attrib[u'n']), language_id) unicode(book.attrib[u'n']), language_id)
if not book_ref_id: if not book_ref_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
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)

View File

@ -106,7 +106,7 @@ class OSISBible(BibleDB):
# Set meta language_id # Set meta language_id
language_id = self.get_language() language_id = self.get_language()
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
try: try:
@ -126,7 +126,7 @@ class OSISBible(BibleDB):
book_ref_id = self.get_book_ref_id_by_name( book_ref_id = self.get_book_ref_id_by_name(
unicode(self.books[book][0]), language_id) unicode(self.books[book][0]), language_id)
if not book_ref_id: if not book_ref_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
book_details = BiblesResourcesDB.get_book_by_id( book_details = BiblesResourcesDB.get_book_by_id(