forked from openlp/openlp
Fix unicode bible import error
More Song changes
This commit is contained in:
parent
5b58f7137f
commit
11a9d28bed
@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with
|
|||||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import logging
|
import logging
|
||||||
from openlp.plugins.bibles.lib.bibleDBimpl import BibleDBImpl
|
from openlp.plugins.bibles.lib.bibleDBimpl import BibleDBImpl
|
||||||
@ -23,28 +23,28 @@ from openlp.core.lib import Receiver
|
|||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
class BibleOSISImpl():
|
class BibleOSISImpl():
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger(u'BibleOSISImpl')
|
log=logging.getLogger(u'BibleOSISImpl')
|
||||||
log.info(u'BibleOSISImpl loaded')
|
log.info(u'BibleOSISImpl loaded')
|
||||||
|
|
||||||
def __init__(self, biblepath, bibledb):
|
def __init__(self, biblepath, bibledb):
|
||||||
self.bibledb = bibledb
|
self.bibledb = bibledb
|
||||||
self.booksOfBible = {} # books of the bible linked to bibleid {osis , name}
|
self.booksOfBible = {} # books of the bible linked to bibleid {osis , name}
|
||||||
self.abbrevOfBible = {} # books of the bible linked to bibleid {osis ,Abbrev }
|
self.abbrevOfBible = {} # books of the bible linked to bibleid {osis ,Abbrev }
|
||||||
|
|
||||||
filepath = os.path.split(os.path.abspath(__file__))[0]
|
filepath = os.path.split(os.path.abspath(__file__))[0]
|
||||||
filepath = os.path.abspath(os.path.join(filepath, '..', 'resources','osisbooks.csv'))
|
filepath = os.path.abspath(os.path.join(filepath, '..', 'resources','osisbooks.csv'))
|
||||||
fbibles=open(filepath, 'r')
|
fbibles=open(filepath, 'r')
|
||||||
for line in fbibles:
|
for line in fbibles:
|
||||||
p = line.split(",")
|
p = line.split(",")
|
||||||
self.booksOfBible[p[0]] = p[1].replace('\n', '')
|
self.booksOfBible[p[0]] = p[1].replace('\n', '')
|
||||||
self.abbrevOfBible[p[0]] = p[2].replace('\n', '')
|
self.abbrevOfBible[p[0]] = p[2].replace('\n', '')
|
||||||
self.loadbible = True
|
self.loadbible = True
|
||||||
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL("openlpstopimport"),self.stop_import)
|
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL("openlpstopimport"),self.stop_import)
|
||||||
|
|
||||||
def stop_import(self):
|
def stop_import(self):
|
||||||
self.loadbible= False
|
self.loadbible= False
|
||||||
|
|
||||||
def load_data(self, osisfile, dialogobject=None):
|
def load_data(self, osisfile, dialogobject=None):
|
||||||
osis=open(osisfile, 'r')
|
osis=open(osisfile, 'r')
|
||||||
|
|
||||||
@ -61,27 +61,27 @@ class BibleOSISImpl():
|
|||||||
pos = file.find(verseText)
|
pos = file.find(verseText)
|
||||||
if pos > -1: # we have a verse
|
if pos > -1: # we have a verse
|
||||||
epos= file.find(">", pos)
|
epos= file.find(">", pos)
|
||||||
ref = file[pos+15:epos-1] # Book Reference
|
ref = file[pos+15:epos-1] # Book Reference
|
||||||
|
|
||||||
#lets find the bible text only
|
#lets find the bible text only
|
||||||
pos = epos + 1 # find start of text
|
pos = epos + 1 # find start of text
|
||||||
epos = file.find("</verse>", pos) # end of text
|
epos = file.find("</verse>", pos) # end of text
|
||||||
text = file[pos : epos]
|
text = unicode(file[pos : epos], u'utf8')
|
||||||
#print pos, e, f[pos:e] # Found Basic Text
|
#print pos, e, f[pos:e] # Found Basic Text
|
||||||
|
|
||||||
#remove tags of extra information
|
#remove tags of extra information
|
||||||
text = self.remove_block(u'<title',u'</title>', text)
|
text = self.remove_block(u'<title',u'</title>', text)
|
||||||
text = self.remove_block(u'<note',u'</note>', text)
|
text = self.remove_block(u'<note',u'</note>', text)
|
||||||
text = self.remove_block(u'<divineName',u'</divineName>', text)
|
text = self.remove_block(u'<divineName',u'</divineName>', text)
|
||||||
|
|
||||||
text = self.remove_tag(u'<lb', text)
|
text = self.remove_tag(u'<lb', text)
|
||||||
text = self.remove_tag(u'<q', text)
|
text = self.remove_tag(u'<q', text)
|
||||||
text = self.remove_tag(u'<l', text)
|
text = self.remove_tag(u'<l', text)
|
||||||
text = self.remove_tag(u'<lg', text)
|
text = self.remove_tag(u'<lg', text)
|
||||||
|
|
||||||
# Strange tags where the end is not the same as the start
|
# Strange tags where the end is not the same as the start
|
||||||
# The must be in this order as at least one bible has them
|
# The must be in this order as at least one bible has them
|
||||||
# crossing and the removal does not work.
|
# crossing and the removal does not work.
|
||||||
pos = text.find(u'<FI>')
|
pos = text.find(u'<FI>')
|
||||||
while pos > -1:
|
while pos > -1:
|
||||||
epos = text.find(u'<Fi>', pos)
|
epos = text.find(u'<Fi>', pos)
|
||||||
@ -90,7 +90,7 @@ class BibleOSISImpl():
|
|||||||
pos = -1
|
pos = -1
|
||||||
else:
|
else:
|
||||||
text = text[:pos] + text[epos + 4: ]
|
text = text[:pos] + text[epos + 4: ]
|
||||||
pos = text.find(u'<FI>')
|
pos = text.find(u'<FI>')
|
||||||
|
|
||||||
pos = text.find(u'<RF>')
|
pos = text.find(u'<RF>')
|
||||||
while pos > -1:
|
while pos > -1:
|
||||||
@ -98,9 +98,9 @@ class BibleOSISImpl():
|
|||||||
text = text[:pos] + text[epos + 4: ]
|
text = text[:pos] + text[epos + 4: ]
|
||||||
#print "X", pos, epos, text
|
#print "X", pos, epos, text
|
||||||
pos = text.find(u'<RF>')
|
pos = text.find(u'<RF>')
|
||||||
|
|
||||||
p = ref.split(u'.', 3) # split up the reference
|
p = ref.split(u'.', 3) # split up the reference
|
||||||
#print p, ">>>", text
|
#print p, ">>>", text
|
||||||
|
|
||||||
if book_ptr != p[0]:
|
if book_ptr != p[0]:
|
||||||
if book_ptr == None: # first time through
|
if book_ptr == None: # first time through
|
||||||
@ -113,14 +113,14 @@ class BibleOSISImpl():
|
|||||||
book_ptr = p[0]
|
book_ptr = p[0]
|
||||||
book = self.bibledb.create_book(self.booksOfBible[p[0]] , self.abbrevOfBible[p[0]], testament)
|
book = self.bibledb.create_book(self.booksOfBible[p[0]] , self.abbrevOfBible[p[0]], testament)
|
||||||
dialogobject.incrementProgressBar(self.booksOfBible[p[0]] )
|
dialogobject.incrementProgressBar(self.booksOfBible[p[0]] )
|
||||||
Receiver().send_message("openlpprocessevents")
|
Receiver().send_message("openlpprocessevents")
|
||||||
count = 0
|
count = 0
|
||||||
self.bibledb.add_verse(book.id, p[1], p[2], text)
|
self.bibledb.add_verse(book.id, p[1], p[2], text)
|
||||||
count += 1
|
count += 1
|
||||||
if count % 3 == 0: #Every 3 verses repaint the screen
|
if count % 3 == 0: #Every 3 verses repaint the screen
|
||||||
Receiver().send_message("openlpprocessevents")
|
Receiver().send_message("openlpprocessevents")
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
def remove_block(self, start_tag, end_tag, text):
|
def remove_block(self, start_tag, end_tag, text):
|
||||||
"""
|
"""
|
||||||
removes a block of text between two tags
|
removes a block of text between two tags
|
||||||
@ -134,9 +134,9 @@ class BibleOSISImpl():
|
|||||||
pos = -1
|
pos = -1
|
||||||
else:
|
else:
|
||||||
text = text[:pos] + text[epos + len(end_tag): ]
|
text = text[:pos] + text[epos + len(end_tag): ]
|
||||||
pos = text.find(start_tag)
|
pos = text.find(start_tag)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def remove_tag(self, start_tag, text):
|
def remove_tag(self, start_tag, text):
|
||||||
"""
|
"""
|
||||||
removes a single tag
|
removes a single tag
|
||||||
@ -146,5 +146,5 @@ class BibleOSISImpl():
|
|||||||
while pos > -1:
|
while pos > -1:
|
||||||
epos = text.find(u'/>', pos)
|
epos = text.find(u'/>', pos)
|
||||||
text = text[:pos] + text[epos + 2: ]
|
text = text[:pos] + text[epos + 2: ]
|
||||||
pos = text.find(start_tag)
|
pos = text.find(start_tag)
|
||||||
return text
|
return text
|
||||||
|
@ -70,6 +70,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
def initialise(self):
|
def initialise(self):
|
||||||
self.loadAuthors()
|
self.loadAuthors()
|
||||||
self.loadTopics()
|
self.loadTopics()
|
||||||
|
self.loadBooks()
|
||||||
|
|
||||||
def loadAuthors(self):
|
def loadAuthors(self):
|
||||||
authors = self.songmanager.get_authors()
|
authors = self.songmanager.get_authors()
|
||||||
@ -78,11 +79,17 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.AuthorsSelectionComboItem.addItem(author.display_name)
|
self.AuthorsSelectionComboItem.addItem(author.display_name)
|
||||||
|
|
||||||
def loadTopics(self):
|
def loadTopics(self):
|
||||||
topics= self.songmanager.get_topics()
|
topics = self.songmanager.get_topics()
|
||||||
self.SongTopicCombo.clear()
|
self.SongTopicCombo.clear()
|
||||||
for topic in topics:
|
for topic in topics:
|
||||||
self.SongTopicCombo.addItem(topic.name)
|
self.SongTopicCombo.addItem(topic.name)
|
||||||
|
|
||||||
|
def loadBooks(self):
|
||||||
|
books = self.songmanager.get_books()
|
||||||
|
self.SongbookCombo.clear()
|
||||||
|
for book in books:
|
||||||
|
self.SongbookCombo.addItem(book.name)
|
||||||
|
|
||||||
def loadSong(self, id):
|
def loadSong(self, id):
|
||||||
self.song = self.songmanager.get_song(id)
|
self.song = self.songmanager.get_song(id)
|
||||||
self.TitleEditItem.setText(self.song.title)
|
self.TitleEditItem.setText(self.song.title)
|
||||||
@ -126,6 +133,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
"""
|
"""
|
||||||
self.song_book_form.load_form()
|
self.song_book_form.load_form()
|
||||||
self.song_book_form.exec_()
|
self.song_book_form.exec_()
|
||||||
|
self.loadBooks()
|
||||||
|
|
||||||
def onAddVerseButtonClicked(self):
|
def onAddVerseButtonClicked(self):
|
||||||
self.verse_form.setVerse('')
|
self.verse_form.setVerse('')
|
||||||
|
@ -19,10 +19,6 @@ class Ui_SongBookDialog(object):
|
|||||||
self.DialogLayout.setMargin(8)
|
self.DialogLayout.setMargin(8)
|
||||||
self.DialogLayout.setObjectName("DialogLayout")
|
self.DialogLayout.setObjectName("DialogLayout")
|
||||||
|
|
||||||
# self.BookSongListView = QtGui.QTableWidget(SongBookDialog)
|
|
||||||
# self.BookSongListView.setObjectName("BookSongListView")
|
|
||||||
# self.BookSongListView.setColumnCount(0)
|
|
||||||
# self.BookSongListView.setRowCount(0)
|
|
||||||
self.BookSongListView = QtGui.QListView()
|
self.BookSongListView = QtGui.QListView()
|
||||||
self.BookSongListView.setAlternatingRowColors(True)
|
self.BookSongListView.setAlternatingRowColors(True)
|
||||||
self.BookSongListData = TextListData()
|
self.BookSongListData = TextListData()
|
||||||
|
@ -18,19 +18,18 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
from PyQt4.QtGui import QDialog
|
|
||||||
from PyQt4.QtCore import pyqtSignature
|
|
||||||
from songbookdialog import Ui_SongBookDialog
|
from songbookdialog import Ui_SongBookDialog
|
||||||
|
from openlp.plugins.songs.lib.classes import Book
|
||||||
|
|
||||||
class SongBookForm(QDialog, Ui_SongBookDialog):
|
class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
|
||||||
"""
|
"""
|
||||||
Class documentation goes here.
|
Class documentation goes here.
|
||||||
"""
|
"""
|
||||||
def __init__(self,songmanager, parent = None):
|
def __init__(self, songmanager, parent = None):
|
||||||
"""
|
"""
|
||||||
Constructor
|
Constructor
|
||||||
"""
|
"""
|
||||||
QDialog.__init__(self, parent)
|
QtGui.QDialog.__init__(self, parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.songmanager = songmanager
|
self.songmanager = songmanager
|
||||||
self.currentRow = 0
|
self.currentRow = 0
|
||||||
@ -42,82 +41,85 @@ class SongBookForm(QDialog, Ui_SongBookDialog):
|
|||||||
QtCore.SIGNAL('pressed()'), self.onClearButtonClick)
|
QtCore.SIGNAL('pressed()'), self.onClearButtonClick)
|
||||||
QtCore.QObject.connect(self.AddUpdateButton,
|
QtCore.QObject.connect(self.AddUpdateButton,
|
||||||
QtCore.SIGNAL('pressed()'), self.onAddUpdateButtonClick)
|
QtCore.SIGNAL('pressed()'), self.onAddUpdateButtonClick)
|
||||||
# QtCore.QObject.connect(self.DisplayEdit,
|
QtCore.QObject.connect(self.NameEdit,
|
||||||
# QtCore.SIGNAL('pressed()'), self.onDisplayEditLostFocus)
|
QtCore.SIGNAL('lostFocus()'), self.onBookNameEditLostFocus)
|
||||||
# QtCore.QObject.connect(self.SongBookListView,
|
QtCore.QObject.connect(self.BookSongListView,
|
||||||
# QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSongBookListViewItemClicked)
|
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onBooksListViewItemClicked)
|
||||||
|
|
||||||
def load_form(self):
|
def load_form(self):
|
||||||
"""
|
"""
|
||||||
Refresh the screen and rest fields
|
Refresh the screen and rest fields
|
||||||
"""
|
"""
|
||||||
self.SongBookListData.resetStore()
|
self.BookSongListData.resetStore()
|
||||||
self.onClearButtonClick() # tidy up screen
|
self.onClearButtonClick() # tidy up screen
|
||||||
SongBooks = self.songmanager.get_SongBooks()
|
Books = self.songmanager.get_books()
|
||||||
for SongBook in SongBooks:
|
for Book in Books:
|
||||||
self.SongBookListData.addRow(SongBook.id,SongBook.display_name)
|
self.BookSongListData.addRow(Book.id,Book.name)
|
||||||
row_count = self.SongBookListData.rowCount(None)
|
row_count = self.BookSongListData.rowCount(None)
|
||||||
if self.currentRow > row_count:
|
if self.currentRow > row_count:
|
||||||
# in case we have delete the last row of the table
|
# in case we have delete the last row of the table
|
||||||
self.currentRow = row_count
|
self.currentRow = row_count
|
||||||
row = self.SongBookListData.createIndex(self.currentRow, 0)
|
row = self.BookSongListData.createIndex(self.currentRow, 0)
|
||||||
if row.isValid():
|
if row.isValid():
|
||||||
self.SongBookListView.selectionModel().setCurrentIndex(row, QtGui.QItemSelectionModel.SelectCurrent)
|
self.BookSongListView.selectionModel().setCurrentIndex(row,
|
||||||
|
QtGui.QItemSelectionModel.SelectCurrent)
|
||||||
self._validate_form()
|
self._validate_form()
|
||||||
|
|
||||||
def onDeleteButtonClick(self):
|
def onDeleteButtonClick(self):
|
||||||
"""
|
"""
|
||||||
Delete the SongBook is the SongBook is not attached to any songs
|
Delete the Book is the Book is not attached to any songs
|
||||||
"""
|
"""
|
||||||
self.songmanager.delete_SongBook(self.SongBook.id)
|
self.songmanager.delete_book(self.Book.id)
|
||||||
self.onClearButtonClick()
|
|
||||||
self.load_form()
|
self.load_form()
|
||||||
|
|
||||||
def onDisplayEditLostFocus(self):
|
def onBookNameEditLostFocus(self):
|
||||||
self._validate_form()
|
self._validate_form()
|
||||||
|
|
||||||
def onAddUpdateButtonClick(self):
|
def onAddUpdateButtonClick(self):
|
||||||
"""
|
"""
|
||||||
Sent New or update details to the database
|
Sent New or update details to the database
|
||||||
"""
|
"""
|
||||||
if self.SongBook == None:
|
if self.Book == None:
|
||||||
self.SongBook = SongBook()
|
self.Book = Book()
|
||||||
self.SongBook.display_name = unicode(self.DisplayEdit.displayText())
|
self.Book.name = unicode(self.NameEdit.displayText())
|
||||||
self.songmanager.save_SongBook(self.SongBook)
|
self.Book.publisher = unicode(self.PublisherEdit.displayText())
|
||||||
|
self.songmanager.save_book(self.Book)
|
||||||
self.onClearButtonClick()
|
self.onClearButtonClick()
|
||||||
self.load_form()
|
self.load_form()
|
||||||
self._validate_form()
|
|
||||||
|
|
||||||
def onClearButtonClick(self):
|
def onClearButtonClick(self):
|
||||||
"""
|
"""
|
||||||
Tidy up screen if clear button pressed
|
Tidy up screen if clear button pressed
|
||||||
"""
|
"""
|
||||||
self.DisplayEdit.setText(u'')
|
self.NameEdit.setText(u'')
|
||||||
|
self.PublisherEdit.setText(u'')
|
||||||
self.MessageLabel.setText(u'')
|
self.MessageLabel.setText(u'')
|
||||||
self.DeleteButton.setEnabled(False)
|
self.DeleteButton.setEnabled(False)
|
||||||
self.SongBook = None
|
self.AddUpdateButton.setEnabled(True)
|
||||||
|
self.Book = None
|
||||||
self._validate_form()
|
self._validate_form()
|
||||||
|
|
||||||
def onSongBookListViewItemClicked(self, index):
|
def onBooksListViewItemClicked(self, index):
|
||||||
"""
|
"""
|
||||||
An SongBook has been selected display it
|
An Book has been selected display it
|
||||||
If the SongBook is attached to a Song prevent delete
|
If the Book is attached to a Song prevent delete
|
||||||
"""
|
"""
|
||||||
self.currentRow = index.row()
|
self.currentRow = index.row()
|
||||||
id = int(self.SongBookListData.getId(index))
|
id = int(self.BookSongListData.getId(index))
|
||||||
self.SongBook = self.songmanager.get_SongBook(id)
|
self.Book = self.songmanager.get_book(id)
|
||||||
|
|
||||||
self.DisplayEdit.setText(self.SongBook.display_name)
|
self.NameEdit.setText(self.Book.name)
|
||||||
if len(self.SongBook.songs) > 0:
|
self.PublisherEdit.setText(self.Book.publisher)
|
||||||
self.MessageLabel.setText("SongBook in use 'Delete' is disabled")
|
if len(self.Book.songs) > 0:
|
||||||
|
self.MessageLabel.setText("Book in use 'Delete' is disabled")
|
||||||
self.DeleteButton.setEnabled(False)
|
self.DeleteButton.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
self.MessageLabel.setText("SongBook is not used")
|
self.MessageLabel.setText("Book is not used")
|
||||||
self.DeleteButton.setEnabled(True)
|
self.DeleteButton.setEnabled(True)
|
||||||
self._validate_form()
|
self._validate_form()
|
||||||
|
|
||||||
def _validate_form(self):
|
def _validate_form(self):
|
||||||
if len(self.DisplayEdit.displayText()) == 0: # We need at lease a display name
|
if len(self.NameEdit.displayText()) == 0: # We need at lease a display name
|
||||||
self.AddUpdateButton.setEnabled(False)
|
self.AddUpdateButton.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
self.AddUpdateButton.setEnabled(True)
|
self.AddUpdateButton.setEnabled(True)
|
||||||
|
@ -52,6 +52,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
"""
|
"""
|
||||||
Refresh the screen and rest fields
|
Refresh the screen and rest fields
|
||||||
"""
|
"""
|
||||||
|
print "topics load form start"
|
||||||
self.TopicsListData.resetStore()
|
self.TopicsListData.resetStore()
|
||||||
self.onClearButtonClick() # tidy up screen
|
self.onClearButtonClick() # tidy up screen
|
||||||
Topics = self.songmanager.get_topics()
|
Topics = self.songmanager.get_topics()
|
||||||
@ -66,12 +67,14 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
self.TopicsListView.selectionModel().setCurrentIndex(row,
|
self.TopicsListView.selectionModel().setCurrentIndex(row,
|
||||||
QtGui.QItemSelectionModel.SelectCurrent)
|
QtGui.QItemSelectionModel.SelectCurrent)
|
||||||
self._validate_form()
|
self._validate_form()
|
||||||
|
print "topics load form end"
|
||||||
|
|
||||||
def onDeleteButtonClick(self):
|
def onDeleteButtonClick(self):
|
||||||
"""
|
"""
|
||||||
Delete the Topic is the Topic is not attached to any songs
|
Delete the Topic is the Topic is not attached to any songs
|
||||||
"""
|
"""
|
||||||
self.songmanager.delete_topic(self.Topic.id)
|
self.songmanager.delete_topic(self.Topic.id)
|
||||||
|
self.onClearButtonClick()
|
||||||
self.load_form()
|
self.load_form()
|
||||||
|
|
||||||
def onTopicNameEditLostFocus(self):
|
def onTopicNameEditLostFocus(self):
|
||||||
|
@ -23,7 +23,7 @@ import sys
|
|||||||
|
|
||||||
from sqlalchemy import asc, desc
|
from sqlalchemy import asc, desc
|
||||||
from openlp.plugins.songs.lib.models import init_models, metadata, session, \
|
from openlp.plugins.songs.lib.models import init_models, metadata, session, \
|
||||||
engine, songs_table, Song, Author, Topic
|
engine, songs_table, Song, Author, Topic, Book
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -143,7 +143,6 @@ class SongManager():
|
|||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
log.error("Errow thrown %s", sys.exc_info()[1])
|
log.error("Errow thrown %s", sys.exc_info()[1])
|
||||||
print "Errow thrown ", sys.exc_info()[1]
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_topics(self):
|
def get_topics(self):
|
||||||
@ -180,5 +179,40 @@ class SongManager():
|
|||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
log.error("Errow thrown %s", sys.exc_info()[1])
|
log.error("Errow thrown %s", sys.exc_info()[1])
|
||||||
print "Errow thrown ", sys.exc_info()[1]
|
return False
|
||||||
|
|
||||||
|
def get_books(self):
|
||||||
|
"""
|
||||||
|
Returns a list of all the Books
|
||||||
|
"""
|
||||||
|
return self.session.query(Book).order_by(Book.name).all()
|
||||||
|
|
||||||
|
def get_book(self, id):
|
||||||
|
"""
|
||||||
|
Details of the Books
|
||||||
|
"""
|
||||||
|
return self.session.query(Book).get(id)
|
||||||
|
|
||||||
|
def save_book(self, book):
|
||||||
|
"""
|
||||||
|
Save the Book
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
self.session.add(book)
|
||||||
|
self.session.commit()
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def delete_book(self, bookid):
|
||||||
|
"""
|
||||||
|
Delete the Book
|
||||||
|
"""
|
||||||
|
book = self.get_book(bookid)
|
||||||
|
try:
|
||||||
|
self.session.delete(book)
|
||||||
|
self.session.commit()
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
log.error("Errow thrown %s", sys.exc_info()[1])
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user