Updated Manager to read bibles from file system and load dictionary of Impl objects.

getBibles uses this list now

bzr-revno: 31
This commit is contained in:
Tim Bentley 2008-10-22 19:59:03 +00:00
parent 7a8b700823
commit 3b493aab23
3 changed files with 18 additions and 8 deletions

View File

@ -46,12 +46,12 @@ verses = Table('Verses', metadata,
) )
Index('idx_chapter_verse_book', verses.c.chapter, verses.c.verse, verses.c.book_id, verses.c.id) Index('idx_chapter_verse_book', verses.c.chapter, verses.c.verse, verses.c.book_id, verses.c.id)
class bible_impl: class BibleImpl:
def __init__(self, filename): def __init__(self, biblename):
# Connect to database # Connect to database
path = ConfigHelper.getBiblePath() path = ConfigHelper.getBiblePath()
print path print path
biblefile = os.path.join(path, filename+".bible") biblefile = os.path.join(path, biblename+".bible")
print biblefile print biblefile
self.db = create_engine("sqlite:///"+biblefile) self.db = create_engine("sqlite:///"+biblefile)
self.db.echo = False self.db.echo = False

View File

@ -4,6 +4,7 @@ mypath=os.path.split(os.path.abspath(__file__))[0]
sys.path.insert(0,(os.path.join(mypath, '..', '..'))) sys.path.insert(0,(os.path.join(mypath, '..', '..')))
from openlp.utils import ConfigHelper from openlp.utils import ConfigHelper
from openlp.database.BibleImpl import *
class BibleManager: class BibleManager:
def __init__(self): def __init__(self):
@ -16,16 +17,25 @@ class BibleManager:
""" """
#if bible != "niv" and bible !="message": #if bible != "niv" and bible !="message":
# raise Exception('Unsupported bible requested ' + bible) # raise Exception('Unsupported bible requested ' + bible)
self.biblelist = {}
self.biblePath = ConfigHelper.getBiblePath() self.biblePath = ConfigHelper.getBiblePath()
print self.biblePath print self.biblePath
files = os.listdir(self.biblePath)
for f in files:
b = f.split('.')[0]
self.biblelist[b] = BibleImpl(b)
print self.biblelist
def getBibles(self): def getBibles(self):
""" """
Returns a list of Books of the bible Returns a list of Books of the bible
""" """
print "get Bibles" r=[]
return ["NIV","The_Message"] for b , o in self.biblelist.iteritems():
r.append(b)
return r
def getBibleBooks(self,bible): def getBibleBooks(self,bible):
""" """

View File

@ -6,12 +6,12 @@ sys.path.insert(0,(os.path.join(mypath, '..', '..','..')))
from openlp.database.BibleImpl import * from openlp.database.BibleImpl import *
if __name__ == "__main__": if __name__ == "__main__":
bi = bible_impl("TheMessage") bi = BibleImpl("TheMessage")
bi.create_tables() bi.create_tables()
bi.Load_Data('biblebooks_msg_short.csv','bibleverses_msg_short.csv') bi.Load_Data('biblebooks_msg_short.csv','bibleverses_msg_short.csv')
bi.Run_Tests() bi.Run_Tests()
b2 = bible_impl("NIV") b2 = BibleImpl("NIV")
b2.create_tables() b2.create_tables()
b2.Load_Data('biblebooks_msg_short.csv','bibleverses_msg_short.csv') b2.Load_Data('biblebooks_msg_short.csv','bibleverses_msg_short.csv')
b2.Run_Tests() b2.Run_Tests()