forked from openlp/openlp
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:
parent
7a8b700823
commit
3b493aab23
@ -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)
|
||||
|
||||
class bible_impl:
|
||||
def __init__(self, filename):
|
||||
class BibleImpl:
|
||||
def __init__(self, biblename):
|
||||
# Connect to database
|
||||
path = ConfigHelper.getBiblePath()
|
||||
print path
|
||||
biblefile = os.path.join(path, filename+".bible")
|
||||
biblefile = os.path.join(path, biblename+".bible")
|
||||
print biblefile
|
||||
self.db = create_engine("sqlite:///"+biblefile)
|
||||
self.db.echo = False
|
||||
|
@ -4,6 +4,7 @@ mypath=os.path.split(os.path.abspath(__file__))[0]
|
||||
sys.path.insert(0,(os.path.join(mypath, '..', '..')))
|
||||
|
||||
from openlp.utils import ConfigHelper
|
||||
from openlp.database.BibleImpl import *
|
||||
|
||||
class BibleManager:
|
||||
def __init__(self):
|
||||
@ -16,17 +17,26 @@ class BibleManager:
|
||||
"""
|
||||
#if bible != "niv" and bible !="message":
|
||||
# raise Exception('Unsupported bible requested ' + bible)
|
||||
self.biblelist = {}
|
||||
self.biblePath = ConfigHelper.getBiblePath()
|
||||
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):
|
||||
"""
|
||||
Returns a list of Books of the bible
|
||||
"""
|
||||
print "get Bibles"
|
||||
return ["NIV","The_Message"]
|
||||
|
||||
r=[]
|
||||
for b , o in self.biblelist.iteritems():
|
||||
r.append(b)
|
||||
return r
|
||||
|
||||
def getBibleBooks(self,bible):
|
||||
"""
|
||||
Returns a list of the books of the bible
|
||||
|
@ -6,12 +6,12 @@ sys.path.insert(0,(os.path.join(mypath, '..', '..','..')))
|
||||
from openlp.database.BibleImpl import *
|
||||
|
||||
if __name__ == "__main__":
|
||||
bi = bible_impl("TheMessage")
|
||||
bi = BibleImpl("TheMessage")
|
||||
bi.create_tables()
|
||||
bi.Load_Data('biblebooks_msg_short.csv','bibleverses_msg_short.csv')
|
||||
bi.Run_Tests()
|
||||
|
||||
b2 = bible_impl("NIV")
|
||||
b2 = BibleImpl("NIV")
|
||||
b2.create_tables()
|
||||
b2.Load_Data('biblebooks_msg_short.csv','bibleverses_msg_short.csv')
|
||||
b2.Run_Tests()
|
||||
|
Loading…
Reference in New Issue
Block a user