forked from openlp/openlp
- small clean ups
bzr-revno: 1464
This commit is contained in:
commit
39f1e791d8
@ -177,10 +177,7 @@ class BibleDB(QtCore.QObject, Manager):
|
|||||||
Returns the version name of the Bible.
|
Returns the version name of the Bible.
|
||||||
"""
|
"""
|
||||||
version_name = self.get_object(BibleMeta, u'Version')
|
version_name = self.get_object(BibleMeta, u'Version')
|
||||||
if version_name:
|
self.name = version_name.value if version_name else None
|
||||||
self.name = version_name.value
|
|
||||||
else:
|
|
||||||
self.name = None
|
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def clean_filename(self, old_filename):
|
def clean_filename(self, old_filename):
|
||||||
@ -256,10 +253,10 @@ class BibleDB(QtCore.QObject, Manager):
|
|||||||
# Text list has book and chapter as first two elements of the array.
|
# Text list has book and chapter as first two elements of the array.
|
||||||
for verse_number, verse_text in textlist.iteritems():
|
for verse_number, verse_text in textlist.iteritems():
|
||||||
verse = Verse.populate(
|
verse = Verse.populate(
|
||||||
book_id = book_id,
|
book_id=book_id,
|
||||||
chapter = chapter,
|
chapter=chapter,
|
||||||
verse = verse_number,
|
verse=verse_number,
|
||||||
text = verse_text
|
text=verse_text
|
||||||
)
|
)
|
||||||
self.session.add(verse)
|
self.session.add(verse)
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
@ -383,15 +380,13 @@ class BibleDB(QtCore.QObject, Manager):
|
|||||||
log.debug(u'BibleDB.verse_search("%s")', text)
|
log.debug(u'BibleDB.verse_search("%s")', text)
|
||||||
verses = self.session.query(Verse)
|
verses = self.session.query(Verse)
|
||||||
if text.find(u',') > -1:
|
if text.find(u',') > -1:
|
||||||
or_clause = []
|
keywords = \
|
||||||
keywords = [u'%%%s%%' % keyword.strip()
|
[u'%%%s%%' % keyword.strip() for keyword in text.split(u',')]
|
||||||
for keyword in text.split(u',')]
|
or_clause = [Verse.text.like(keyword) for keyword in keywords]
|
||||||
for keyword in keywords:
|
|
||||||
or_clause.append(Verse.text.like(keyword))
|
|
||||||
verses = verses.filter(or_(*or_clause))
|
verses = verses.filter(or_(*or_clause))
|
||||||
else:
|
else:
|
||||||
keywords = [u'%%%s%%' % keyword.strip()
|
keywords = \
|
||||||
for keyword in text.split(u' ')]
|
[u'%%%s%%' % keyword.strip() for keyword in text.split(u' ')]
|
||||||
for keyword in keywords:
|
for keyword in keywords:
|
||||||
verses = verses.filter(Verse.text.like(keyword))
|
verses = verses.filter(Verse.text.like(keyword))
|
||||||
verses = verses.all()
|
verses = verses.all()
|
||||||
|
Loading…
Reference in New Issue
Block a user