forked from openlp/openlp
Stop Presentation Tab failing
CSV Bibles get Unicode
This commit is contained in:
parent
36113b0d90
commit
93655bc92e
@ -16,6 +16,7 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
import logging
|
||||
import chardet
|
||||
|
||||
from openlp.plugins.bibles.lib.bibleDBimpl import BibleDBImpl
|
||||
from openlp.plugins.bibles.lib.common import BibleCommon
|
||||
@ -23,57 +24,64 @@ from openlp.core.lib import Receiver
|
||||
|
||||
|
||||
class BibleCSVImpl(BibleCommon):
|
||||
global log
|
||||
global log
|
||||
log=logging.getLogger(u'BibleCSVImpl')
|
||||
log.info(u'BibleCVSImpl loaded')
|
||||
log.info(u'BibleCVSImpl loaded')
|
||||
def __init__(self, bibledb):
|
||||
"""
|
||||
Loads a Bible from a pair of CVS files passed in
|
||||
This class assumes the files contain all the information and
|
||||
This class assumes the files contain all the information and
|
||||
a clean bible is being loaded.
|
||||
"""
|
||||
"""
|
||||
self.bibledb = bibledb
|
||||
self.loadbible = True
|
||||
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'openlpstopimport'),self.stop_import)
|
||||
|
||||
|
||||
def stop_import(self):
|
||||
self.loadbible= False
|
||||
|
||||
|
||||
def load_data(self, booksfile, versesfile, dialogobject):
|
||||
#Populate the Tables
|
||||
fbooks=open(booksfile, 'r')
|
||||
fverse=open(versesfile, 'r')
|
||||
|
||||
|
||||
count = 0
|
||||
for line in fbooks:
|
||||
#log.debug( line)
|
||||
if self.loadbible == False: # cancel pressed
|
||||
break
|
||||
# cancel pressed
|
||||
if self.loadbible == False:
|
||||
break
|
||||
details = chardet.detect(line)
|
||||
line = unicode(line, details['encoding'])
|
||||
p = line.split(u',')
|
||||
p1 = p[1].replace(u'"', u'')
|
||||
p1 = p[1].replace(u'"', u'')
|
||||
p2 = p[2].replace(u'"', u'')
|
||||
p3 = p[3].replace(u'"', u'')
|
||||
p3 = p[3].replace(u'"', u'')
|
||||
self.bibledb.create_book(p2, p3, int(p1))
|
||||
count += 1
|
||||
if count % 3 == 0: #Every x verses repaint the screen
|
||||
Receiver().send_message(u'openlpprocessevents')
|
||||
#Flush the screen events
|
||||
if count % 3 == 0:
|
||||
Receiver().send_message(u'openlpprocessevents')
|
||||
count = 0
|
||||
|
||||
|
||||
count = 0
|
||||
book_ptr = None
|
||||
for line in fverse:
|
||||
if self.loadbible == False: # cancel pressed
|
||||
break
|
||||
#log.debug( line)
|
||||
p = line.split(u',', 3) # split into 3 units and leave the rest as a single field
|
||||
break
|
||||
details = chardet.detect(line)
|
||||
line = unicode(line, details['encoding'])
|
||||
# split into 3 units and leave the rest as a single field
|
||||
p = line.split(u',', 3)
|
||||
p0 = p[0].replace(u'"', u'')
|
||||
p3 = p[3].replace(u'"',u'')
|
||||
if book_ptr is not p0:
|
||||
book = self.bibledb.get_bible_book(p0)
|
||||
book_ptr = book.name
|
||||
dialogobject.incrementProgressBar(book.name) # increament the progress bar
|
||||
# increament the progress bar
|
||||
dialogobject.incrementProgressBar(book.name)
|
||||
self.bibledb.add_verse(book.id, p[1], p[2], p3)
|
||||
count += 1
|
||||
if count % 3 == 0: #Every x verses repaint the screen
|
||||
Receiver().send_message(u'openlpprocessevents')
|
||||
count = 0
|
||||
#Every x verses repaint the screen
|
||||
if count % 3 == 0:
|
||||
Receiver().send_message(u'openlpprocessevents')
|
||||
count = 0
|
||||
|
@ -70,9 +70,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
self.DisplayTypeLabel = QtGui.QLabel(self.PresentationWidget)
|
||||
self.DisplayTypeLabel.setObjectName(u'SearchTypeLabel')
|
||||
self.DisplayLayout.addWidget(self.DisplayTypeLabel, 0, 0, 1, 1)
|
||||
|
||||
self.DisplayTypeLabel.setText(translate(u'PresentationMediaItem', u'Present using:'))
|
||||
|
||||
# Add the Presentation widget to the page layout
|
||||
self.PageLayout.addWidget(self.PresentationWidget)
|
||||
|
||||
|
@ -52,6 +52,7 @@ class PresentationPlugin(Plugin):
|
||||
|
||||
def check_pre_conditions(self):
|
||||
log.debug('check_pre_conditions')
|
||||
self.openoffice = Openoffice()
|
||||
return self.openoffice.checkOoPid()
|
||||
return True
|
||||
# self.openoffice = Openoffice()
|
||||
# return self.openoffice.checkOoPid()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user