openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #01311
[Merge] lp:~raoul-snyman/openlp/biblefixes into lp:openlp
Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/biblefixes into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
--
https://code.launchpad.net/~raoul-snyman/openlp/biblefixes/+merge/22260
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py 2010-03-22 08:37:18 +0000
+++ openlp/plugins/bibles/lib/http.py 2010-03-26 21:03:17 +0000
@@ -27,6 +27,7 @@
import urllib2
import os
import sqlite3
+import re
from BeautifulSoup import BeautifulSoup, Tag, NavigableString
@@ -293,18 +294,22 @@
soup = BeautifulSoup(page)
htmlverses = soup.findAll(u'span', u'versetext')
verses = {}
+ reduce_spaces = re.compile(r'[ ]{2,}')
for verse in htmlverses:
Receiver.send_message(u'process_events')
versenumber = int(verse.contents[0].contents[0])
versetext = u''
for part in verse.contents:
- if str(part)[0] != u'<':
+ if isinstance(part, NavigableString):
versetext = versetext + part
- elif part and part.attrMap and part.attrMap[u'class'] == u'WordsOfChrist':
+ elif part and part.attrMap and \
+ (part.attrMap[u'class'] == u'WordsOfChrist' or \
+ part.attrMap[u'class'] == u'strongs'):
for subpart in part.contents:
- if str(subpart)[0] != '<':
+ if isinstance(subpart, NavigableString):
versetext = versetext + subpart
versetext = versetext.strip(u'\n\r\t ')
+ versetext = reduce_spaces.sub(u' ', versetext)
verses[versenumber] = versetext
return SearchResults(bookname, chapter, verses)
Follow ups