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