From 428edf28fb5abf3fea66b13aab61764fb7acc101 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 30 Jan 2011 09:32:09 +0000 Subject: [PATCH 1/6] CSV testing named book format (v1?) --- openlp/plugins/bibles/lib/csvbible.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index fd987dfdf..33a5de714 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -172,8 +172,12 @@ class CSVBible(BibleDB): for line in verse_reader: if self.stop_import_flag: break - if book_ptr != book_list[int(line[0])]: - book = self.get_book(book_list[int(line[0])]) + try: + line_book = book_list[int(line[0])] + except ValueError: + line_book = unicode(line[0], details['encoding']) + if book_ptr != line_book: + book = self.get_book(line_book) book_ptr = book.name self.wizard.incrementProgressBar(unicode(translate( 'BibleDB.Wizard', 'Importing verses from %s...', From 780a8b8b39727c8daea1a418a79c6d71d82971e8 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 30 Jan 2011 09:43:07 +0000 Subject: [PATCH 2/6] Docstring update for CSV formats --- openlp/plugins/bibles/lib/csvbible.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 33a5de714..677f99e6b 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -50,14 +50,17 @@ The format of the books file is: ... 40,2,Matthew,Matt -The format of the verses file is: +There are two acceptable formats of the verses file. They are: ,,, + or + ,,, For example: 1,1,1,"In the beginning God created the heaven and the earth." - 1,1,2,"And the earth was without form, and void; and darkness...." + or + "Genesis",1,2,"And the earth was without form, and void; and...." All CSV files are expected to use a comma (',') as the delimeter and double quotes ('"') as the quote symbol. From 83ac7c6b297e5dd0a388d299195ad91b89b0b4f0 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 30 Jan 2011 10:27:12 +0000 Subject: [PATCH 3/6] Fix up theme override position bugs Fixes: https://launchpad.net/bugs/710065 --- openlp/core/ui/maindisplay.py | 1 + openlp/core/ui/themeform.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 3dfde8640..f6ecfc6fc 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -244,6 +244,7 @@ class MainDisplay(DisplayWidget): Used after Image plugin has changed the background """ log.debug(u'resetImage') + a=c if hasattr(self, u'serviceItem'): self.displayImage(self.serviceItem.bg_image_bytes) else: diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 43f1034f4..8d10f21fa 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -272,14 +272,18 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): def onMainPositionCheckBoxStateChanged(self, value): """ Change state as Main Area Position check box changed + NOTE the font_main_override is the inverse of the check box value """ - self.theme.font_main_override = (value == QtCore.Qt.Checked) + if self.updateThemeAllowed: + self.theme.font_main_override = not (value == QtCore.Qt.Checked) def onFooterPositionCheckBoxStateChanged(self, value): """ Change state as Footer Area Position check box changed + NOTE the font_footer_override is the inverse of the check box value """ - self.theme.font_footer_override = (value == QtCore.Qt.Checked) + if self.updateThemeAllowed: + self.theme.font_footer_override = not (value == QtCore.Qt.Checked) def exec_(self, edit=False): """ From 9c5d7e85912e00401db006ef07acf0d78247143d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 30 Jan 2011 16:51:31 +0000 Subject: [PATCH 4/6] Remove debug --- openlp/core/ui/maindisplay.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index f6ecfc6fc..3dfde8640 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -244,7 +244,6 @@ class MainDisplay(DisplayWidget): Used after Image plugin has changed the background """ log.debug(u'resetImage') - a=c if hasattr(self, u'serviceItem'): self.displayImage(self.serviceItem.bg_image_bytes) else: From b99961d669c9f71ac6d33a3d7e4411f4ad7444af Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 31 Jan 2011 01:55:25 +0000 Subject: [PATCH 5/6] Fix BG Chinese bible (Bug #706211) --- openlp/plugins/bibles/lib/http.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index b844bbe61..e004be9df 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -210,7 +210,8 @@ class BGExtract(object): cleaner = [(re.compile(' |
|\'\+\''), lambda match: '')] soup = get_soup_for_bible_ref( u'http://www.biblegateway.com/passage/?%s' % url_params, - cleaner=cleaner) + pre_parse_regex=r'', pre_parse_substitute='', + cleaner=cleaner) if not soup: return None Receiver.send_message(u'openlp_process_events') @@ -499,7 +500,8 @@ class HTTPBible(BibleDB): """ return HTTPBooks.get_verse_count(book, chapter) -def get_soup_for_bible_ref(reference_url, header=None, cleaner=None): +def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, + pre_parse_substitute=None, cleaner=None): """ Gets a webpage and returns a parsed and optionally cleaned soup or None. @@ -509,6 +511,13 @@ def get_soup_for_bible_ref(reference_url, header=None, cleaner=None): ``header`` An optional HTTP header to pass to the bible web server. + ``pre_parse_regex`` + A regular expression to run on the webpage. Allows manipulation of the + webpage before passing to BeautifulSoup for parsing. + + ``pre_parse_substitute`` + The text to replace any matches to the regular expression with. + ``cleaner`` An optional regex to use during webpage parsing. """ @@ -518,12 +527,15 @@ def get_soup_for_bible_ref(reference_url, header=None, cleaner=None): if not page: send_error_message(u'download') return None + page_source = page.read() + if pre_parse_regex and pre_parse_substitute is not None: + page_source = re.sub(pre_parse_regex, pre_parse_substitute, page_source) soup = None try: if cleaner: - soup = BeautifulSoup(page, markupMassage=cleaner) + soup = BeautifulSoup(page_source, markupMassage=cleaner) else: - soup = BeautifulSoup(page) + soup = BeautifulSoup(page_source) except HTMLParseError: log.exception(u'BeautifulSoup could not parse the bible page.') if not soup: From 250107073e86d399d1b792d9b2d3087e4dca72c4 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 31 Jan 2011 02:43:37 +0000 Subject: [PATCH 6/6] Fix not quite ascii CSVs --- openlp/plugins/bibles/lib/csvbible.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 677f99e6b..82872e15b 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -186,8 +186,11 @@ class CSVBible(BibleDB): 'BibleDB.Wizard', 'Importing verses from %s...', 'Importing verses from ...')) % book.name) self.session.commit() - self.create_verse(book.id, line[1], line[2], - unicode(line[3], details['encoding'])) + try: + verse_text = unicode(line[3], details['encoding']) + except UnicodeError: + verse_text = unicode(line[3], u'cp1252') + self.create_verse(book.id, line[1], line[2], verse_text) self.wizard.incrementProgressBar(translate('BibleDB.Wizard', 'Importing verses... done.')) Receiver.send_message(u'openlp_process_events')