forked from openlp/openlp
General cleanups Jon missed
This commit is contained in:
parent
459a728443
commit
9c4e5ae137
@ -396,7 +396,6 @@ class Renderer(object):
|
||||
startx = x
|
||||
starty = y
|
||||
rightextent = None
|
||||
#print "inputs", startx, starty, maxx, maxy
|
||||
# dont allow alignment messing with footers
|
||||
if footer:
|
||||
align = 0
|
||||
@ -404,7 +403,6 @@ class Renderer(object):
|
||||
else:
|
||||
align = int(self._theme .display_horizontalAlign)
|
||||
shadow_offset = self._shadow_offset
|
||||
#print lines
|
||||
for linenum in range(len(lines)):
|
||||
line = lines[linenum]
|
||||
#find out how wide line is
|
||||
|
@ -93,7 +93,7 @@ class SongXMLBuilder(object):
|
||||
"""
|
||||
Debugging aid to dump XML so that we can see what we have.
|
||||
"""
|
||||
print self.song_xml.toprettyxml(indent=u' ')
|
||||
return self.song_xml.toprettyxml(indent=u' ')
|
||||
|
||||
def extract_xml(self):
|
||||
"""
|
||||
@ -149,4 +149,4 @@ class SongXMLParser(object):
|
||||
"""
|
||||
Debugging aid to dump XML so that we can see what we have.
|
||||
"""
|
||||
print dump(self.song_xml)
|
||||
return dump(self.song_xml)
|
||||
|
@ -295,7 +295,7 @@ class ThemeXML(object):
|
||||
Dump the XML to file.
|
||||
"""
|
||||
# Debugging aid to see what we have
|
||||
print self.theme_xml.toprettyxml(indent=u' ')
|
||||
return self.theme_xml.toprettyxml(indent=u' ')
|
||||
|
||||
def extract_xml(self):
|
||||
"""
|
||||
|
@ -98,7 +98,6 @@ class Theme:
|
||||
# init to defaults
|
||||
self._set_from_XML(blankstylexml)
|
||||
self._set_from_XML(xml)
|
||||
# print self.__str__()
|
||||
|
||||
def _get_as_string(self):
|
||||
s = u''
|
||||
@ -115,23 +114,18 @@ class Theme:
|
||||
for element in iter:
|
||||
if element.tag != u'Theme':
|
||||
t = element.text
|
||||
# print element.tag, t, type(t)
|
||||
val = 0
|
||||
# easy!
|
||||
if type(t) == type(None):
|
||||
val = t
|
||||
# strings need special handling to sort the colours out
|
||||
if type(t) is types.StringType or type(t) is types.UnicodeType:
|
||||
# print u'str',
|
||||
if t[0] == u'$': # might be a hex number
|
||||
# print u'hex',
|
||||
try:
|
||||
val = int(t[1:], 16)
|
||||
except ValueError: # nope
|
||||
# print u'nope'
|
||||
pass
|
||||
elif DelphiColors.has_key(t):
|
||||
# print u'colour ', t
|
||||
val = DelphiColors[t]
|
||||
else:
|
||||
try:
|
||||
@ -142,8 +136,6 @@ class Theme:
|
||||
(element.tag.find(u'BackgroundParameter') == 0 and type(val) == type(0))):
|
||||
# convert to a wx.Colour
|
||||
val= QtGui.QColor((val>>16) & 0xFF, (val>>8)&0xFF, val&0xFF)
|
||||
# print [val]
|
||||
# print u'>> ', element.tag, val
|
||||
setattr(self, element.tag, val)
|
||||
|
||||
def __str__(self):
|
||||
|
@ -194,7 +194,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
|
||||
def onImageToolButtonClicked(self):
|
||||
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file')
|
||||
if filename != "":
|
||||
if filename != u'':
|
||||
self.ImageLineEdit.setText(filename)
|
||||
self.theme.background_filename = filename
|
||||
self.previewTheme(self.theme)
|
||||
|
@ -57,28 +57,23 @@ class BGExtract(BibleCommon):
|
||||
unicode(bookid) + u'&chapter' + unicode(chapter) + u'&version=' + \
|
||||
unicode(version)
|
||||
xml_string = self._get_web_text(urlstring, self.proxyurl)
|
||||
#print xml_string
|
||||
VerseSearch = u'class=' + u'"' + u'sup' + u'"' + u'>'
|
||||
verse = 1
|
||||
i = xml_string.find(u'result-text-style-normal')
|
||||
xml_string = xml_string[i:len(xml_string)]
|
||||
versePos = xml_string.find(VerseSearch)
|
||||
#print versePos
|
||||
bible = {}
|
||||
while versePos > -1:
|
||||
verseText = '' # clear out string
|
||||
# clear out string
|
||||
verseText = ''
|
||||
versePos = xml_string.find(u'</span', versePos)
|
||||
i = xml_string.find(VerseSearch, versePos+1)
|
||||
#print i, versePos
|
||||
if i == -1:
|
||||
i = xml_string.find(u'</div', versePos+1)
|
||||
j = xml_string.find(u'<strong', versePos+1)
|
||||
#print i, j
|
||||
if j > 0 and j < i:
|
||||
i = j
|
||||
verseText = xml_string[versePos + 7 : i ]
|
||||
#print xml_string
|
||||
#print 'VerseText = ' + unicode(verse) +' '+ verseText
|
||||
bible[verse] = self._clean_text(verseText) # store the verse
|
||||
versePos = -1
|
||||
else:
|
||||
@ -121,9 +116,9 @@ class CWExtract(BibleCommon):
|
||||
log.debug(u'get_bible_chapter %s,%s,%s,%s',
|
||||
version, bookid, bookname, chapter)
|
||||
bookname = bookname.replace(u' ', u'')
|
||||
urlstring = u'http://bible.crosswalk.com/OnlineStudyBible/bible.cgi?word=%s+%d&version=%s' % (bookname, chapter, version)
|
||||
urlstring = u'http://bible.crosswalk.com/OnlineStudyBible/bible.cgi?word=%s+%d&version=%s'\
|
||||
% (bookname, chapter, version)
|
||||
xml_string = self._get_web_text(urlstring, self.proxyurl)
|
||||
#log.debug(u'Return data %s', xml_string)
|
||||
## Strip Book Title from Heading to return it to system
|
||||
##
|
||||
i= xml_string.find(u'<title>')
|
||||
@ -136,11 +131,8 @@ class CWExtract(BibleCommon):
|
||||
book_title = book_title[:i].rstrip()
|
||||
log.debug(u'Book Title %s', book_title)
|
||||
log.debug(u'Book Chapter %s', book_chapter)
|
||||
# Strip Verse Data from Page and build an array
|
||||
|
||||
## Strip Verse Data from Page and build an array
|
||||
##
|
||||
#log.debug(u'bible data %s', xml_string)
|
||||
#print xml_string
|
||||
i= xml_string.find(u'NavCurrentChapter')
|
||||
xml_string = xml_string[i:len(xml_string)]
|
||||
i= xml_string.find(u'<TABLE')
|
||||
@ -153,15 +145,13 @@ class CWExtract(BibleCommon):
|
||||
#remove the <B> at the front
|
||||
xml_string = xml_string[i + 3 :len(xml_string)]
|
||||
versePos = xml_string.find(u'<BLOCKQUOTE>')
|
||||
#log.debug(u'verse pos %d', versePos)
|
||||
bible = {}
|
||||
while versePos > 0:
|
||||
verseText = u''
|
||||
versePos = xml_string.find(u'<B><I>', versePos) + 6
|
||||
i = xml_string.find(u'</I></B>', versePos)
|
||||
#log.debug( versePos, i)
|
||||
verse= xml_string[versePos:i] # Got the Chapter
|
||||
#log.debug( 'Chapter = %s', verse)
|
||||
# Got the Chapter
|
||||
verse= xml_string[versePos:i]
|
||||
# move the starting position to begining of the text
|
||||
versePos = i + 8
|
||||
# find the start of the next verse
|
||||
@ -171,14 +161,9 @@ class CWExtract(BibleCommon):
|
||||
verseText = xml_string[versePos: i]
|
||||
versePos = 0
|
||||
else:
|
||||
#log.debug( i, versePos)
|
||||
verseText = xml_string[versePos: i]
|
||||
versePos = i
|
||||
#print verseText
|
||||
#print self._clean_text(verseText)
|
||||
bible[verse] = self._clean_text(verseText)
|
||||
|
||||
#log.debug( bible)
|
||||
return SearchResults(book_title, book_chapter, bible)
|
||||
|
||||
class BibleHTTPImpl():
|
||||
|
@ -153,7 +153,6 @@ class BibleCommon(object):
|
||||
text = text.replace(u'</P>', u'')
|
||||
text = text.replace(u'<BR>', u'')
|
||||
text = text.replace(u'<BR />', u'')
|
||||
#text = text.replace(chr(189), u'1/2');print "l"
|
||||
text = text.replace(u'"', u'\"')
|
||||
text = text.replace(u''', u'\'')
|
||||
# Remove some other tags
|
||||
|
@ -177,14 +177,14 @@ class BibleManager(object):
|
||||
nbible.save_meta(u'WEB', biblesource)
|
||||
# store the web id of the bible
|
||||
nbible.save_meta(u'bibleid', bibleid)
|
||||
if proxyurl is not None and proxyurl != "":
|
||||
if proxyurl is not None and proxyurl != u'':
|
||||
# store the proxy URL
|
||||
nbible.save_meta(u'proxy', proxyurl)
|
||||
nhttp.set_proxy(proxyurl)
|
||||
if proxyid is not None and proxyid != "":
|
||||
if proxyid is not None and proxyid != u'':
|
||||
# store the proxy userid
|
||||
nbible.save_meta(u'proxyid', proxyid)
|
||||
if proxypass is not None and proxypass != "":
|
||||
if proxypass is not None and proxypass != u'':
|
||||
# store the proxy password
|
||||
nbible.save_meta(u'proxypass', proxypass)
|
||||
return True
|
||||
|
@ -474,11 +474,8 @@ class BibleMediaItem(MediaManagerItem):
|
||||
start_chapter = chapter
|
||||
else:
|
||||
# more complex
|
||||
#print search
|
||||
sp = search.split(u'-') #find first
|
||||
#print sp, len(sp)
|
||||
sp1 = sp[0].split(u':')
|
||||
#print sp1, len(sp1)
|
||||
if len(sp1) == 1:
|
||||
start_chapter = sp1[0]
|
||||
start_verse = 1
|
||||
|
Loading…
Reference in New Issue
Block a user