← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~meths/openlp/testing into lp:openlp

 

Jon Tibble has proposed merging lp:~meths/openlp/testing into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~meths/openlp/testing/+merge/51197

Fix handling of verses that are missing but acknowledged - manifested in illegal verse numbers.
-- 
https://code.launchpad.net/~meths/openlp/testing/+merge/51197
Your team OpenLP Core is requested to review the proposed merge of lp:~meths/openlp/testing into lp:openlp.
=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py	2011-02-24 05:47:38 +0000
+++ openlp/plugins/bibles/lib/http.py	2011-02-24 19:32:04 +0000
@@ -236,8 +236,20 @@
         while found_count < verse_count:
             content = content.findNext(u'sup', u'versenum')
             raw_verse_num = content.next
-            raw_verse_text = raw_verse_num.next
-            verse_list[int(str(raw_verse_num))] = unicode(raw_verse_text)
+            clean_verse_num = 0
+            # Not all verses exist in all translations and may or may not be
+            # represented by a verse number.  If they are not fine, if they are
+            # it will probably be in a format that breaks int().  We will then
+            # have no idea what garbage may be sucked in to the verse text so
+            # if we do not get a clean int() then ignore the verse completely.
+            try:
+                clean_verse_num = int(str(raw_verse_num))
+            except ValueError:
+                log.exception(u'Illegal verse number in %s %s %s:%s',
+                    version, bookname, chapter, unicode(raw_verse_num))
+            if clean_verse_num:
+                raw_verse_text = raw_verse_num.next
+                verse_list[clean_verse_num] = unicode(raw_verse_text)
             found_count += 1
         return SearchResults(bookname, chapter, verse_list)
 


Follow ups