From 93655bc92ec8c0fd49b71dcaaa6643142c67dcec Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 9 Jul 2009 17:51:25 +0100 Subject: [PATCH] Stop Presentation Tab failing CSV Bibles get Unicode --- openlp/plugins/bibles/lib/bibleCSVimpl.py | 52 +++++++++++-------- openlp/plugins/presentations/lib/mediaitem.py | 2 - .../presentations/presentationplugin.py | 5 +- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/openlp/plugins/bibles/lib/bibleCSVimpl.py b/openlp/plugins/bibles/lib/bibleCSVimpl.py index 6cc0af681..e97c4173c 100644 --- a/openlp/plugins/bibles/lib/bibleCSVimpl.py +++ b/openlp/plugins/bibles/lib/bibleCSVimpl.py @@ -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 \ No newline at end of file + #Every x verses repaint the screen + if count % 3 == 0: + Receiver().send_message(u'openlpprocessevents') + count = 0 diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 67afbd7cc..6506e5304 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -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) diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index a00b5d0b2..f7f9f9903 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -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()