forked from openlp/openlp
Fix None testing and general cleanups
This commit is contained in:
parent
d5a3cf705b
commit
8a44484aee
@ -24,9 +24,10 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import logging, logging.handlers
|
import logging
|
||||||
from optparse import OptionParser
|
import logging.handlers
|
||||||
|
|
||||||
|
from optparse import OptionParser
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, str_to_bool
|
from openlp.core.lib import Receiver, str_to_bool
|
||||||
|
@ -28,6 +28,7 @@ OpenLP work.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import types
|
import types
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
def translate(context, text):
|
def translate(context, text):
|
||||||
|
@ -107,17 +107,17 @@ class PluginConfig(object):
|
|||||||
files = os.listdir(self.get_data_path())
|
files = os.listdir(self.get_data_path())
|
||||||
except:
|
except:
|
||||||
return []
|
return []
|
||||||
if suffix != None:
|
if suffix is not None:
|
||||||
return_files = []
|
return_files = []
|
||||||
for f in files:
|
for file in files:
|
||||||
if f.find(u'.') != -1:
|
if file.find(u'.') != -1:
|
||||||
nme = f.split(u'.')
|
filename = file.split(u'.')
|
||||||
bname = nme[0]
|
#bname = nme[0]
|
||||||
sfx = nme[1].lower()
|
filesuffix = filename[1].lower()
|
||||||
sfx = sfx.lower()
|
filesuffix = filesuffix.lower()
|
||||||
# only load files with the correct suffix
|
# only load files with the correct suffix
|
||||||
if suffix.find(sfx) > -1 :
|
if suffix.find(filesuffix) > -1 :
|
||||||
return_files.append(f)
|
return_files.append(file)
|
||||||
return return_files
|
return return_files
|
||||||
else:
|
else:
|
||||||
# no filtering required
|
# no filtering required
|
||||||
|
@ -151,7 +151,6 @@ class Renderer(object):
|
|||||||
The footer of the slide.
|
The footer of the slide.
|
||||||
"""
|
"""
|
||||||
log.debug(u'format_slide - Start')
|
log.debug(u'format_slide - Start')
|
||||||
verses = []
|
|
||||||
words = words.replace(u'\r\n', u'\n')
|
words = words.replace(u'\r\n', u'\n')
|
||||||
verses_text = words.split(u'\n')
|
verses_text = words.split(u'\n')
|
||||||
text = []
|
text = []
|
||||||
@ -174,7 +173,6 @@ class Renderer(object):
|
|||||||
split_pages = []
|
split_pages = []
|
||||||
page = []
|
page = []
|
||||||
split_lines = []
|
split_lines = []
|
||||||
count = 0
|
|
||||||
for line in text:
|
for line in text:
|
||||||
#Must be a blank line so keep it.
|
#Must be a blank line so keep it.
|
||||||
if len(line) == 0:
|
if len(line) == 0:
|
||||||
|
@ -88,7 +88,7 @@ class ServiceItem(object):
|
|||||||
self.frames = []
|
self.frames = []
|
||||||
if self.service_item_type == ServiceType.Text:
|
if self.service_item_type == ServiceType.Text:
|
||||||
log.debug(u'Formatting slides')
|
log.debug(u'Formatting slides')
|
||||||
if self.theme == None:
|
if self.theme is None:
|
||||||
self.RenderManager.set_override_theme(None)
|
self.RenderManager.set_override_theme(None)
|
||||||
else:
|
else:
|
||||||
self.RenderManager.set_override_theme(self.theme)
|
self.RenderManager.set_override_theme(self.theme)
|
||||||
@ -114,7 +114,7 @@ class ServiceItem(object):
|
|||||||
|
|
||||||
def render_individual(self, row):
|
def render_individual(self, row):
|
||||||
log.debug(u'render individual')
|
log.debug(u'render individual')
|
||||||
if self.theme == None:
|
if self.theme is None:
|
||||||
self.RenderManager.set_override_theme(None)
|
self.RenderManager.set_override_theme(None)
|
||||||
else:
|
else:
|
||||||
self.RenderManager.set_override_theme(self.theme)
|
self.RenderManager.set_override_theme(self.theme)
|
||||||
|
@ -48,7 +48,7 @@ class SettingsTab(QtGui.QWidget):
|
|||||||
self.setupUi()
|
self.setupUi()
|
||||||
self.retranslateUi()
|
self.retranslateUi()
|
||||||
self.initialise()
|
self.initialise()
|
||||||
if section == None:
|
if section is None:
|
||||||
self.config = PluginConfig(title)
|
self.config = PluginConfig(title)
|
||||||
else:
|
else:
|
||||||
self.config = PluginConfig(section)
|
self.config = PluginConfig(section)
|
||||||
|
@ -17,12 +17,13 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os, os.path
|
import os
|
||||||
|
import os.path
|
||||||
|
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
|
|
||||||
from openlp.core.theme import Theme
|
from openlp.core.theme import Theme
|
||||||
from openlp.core import Renderer
|
from openlp.core.lib import Renderer
|
||||||
|
|
||||||
mypath = os.path.split(os.path.abspath(__file__))[0]
|
mypath = os.path.split(os.path.abspath(__file__))[0]
|
||||||
sys.path.insert(0, (os.path.join(mypath, '..', '..', '..')))
|
sys.path.insert(0, (os.path.join(mypath, '..', '..', '..')))
|
||||||
@ -104,8 +105,8 @@ class TestRender_base:
|
|||||||
frame = TstFrame(size = self.size)
|
frame = TstFrame(size = self.size)
|
||||||
self.frame = frame
|
self.frame = frame
|
||||||
self.paintdest = frame.GetPixmap()
|
self.paintdest = frame.GetPixmap()
|
||||||
self.r=Renderer()
|
self.renderer = Renderer()
|
||||||
self.r.set_paint_dest(self.paintdest)
|
self.renderer.set_paint_dest(self.paintdest)
|
||||||
self.expected_answer = "Don't know yet"
|
self.expected_answer = "Don't know yet"
|
||||||
self.answer = None
|
self.answer = None
|
||||||
print "--------------- Setup Done -------------"
|
print "--------------- Setup Done -------------"
|
||||||
@ -119,24 +120,27 @@ class TestRender(TestRender_base):
|
|||||||
|
|
||||||
def setup_method(self, method):
|
def setup_method(self, method):
|
||||||
TestRender_base.setup_method(self, method)
|
TestRender_base.setup_method(self, method)
|
||||||
self.r.set_debug(1)
|
self.renderer.set_debug(1)
|
||||||
themefile = os.path.abspath(u'data_for_tests/render_theme.xml')
|
themefile = os.path.abspath(u'data_for_tests/render_theme.xml')
|
||||||
self.r.set_theme(Theme(themefile)) # set default theme
|
self.renderer.set_theme(Theme(themefile)) # set default theme
|
||||||
self.r._render_background()
|
self.renderer._render_background()
|
||||||
self.r.set_text_rectangle(QtCore.QRect(0,0, self.size.width()-1,
|
self.renderer.set_text_rectangle(QtCore.QRect(
|
||||||
self.size.height()-1))
|
0,0, self.size.width()-1, self.size.height()-1))
|
||||||
self.msg = None
|
self.msg = None
|
||||||
|
|
||||||
def test_easy(self):
|
def test_easy(self):
|
||||||
answer = self.r._render_single_line(u'Test line', tlcorner = (0,100))
|
answer = self.renderer._render_single_line(
|
||||||
|
u'Test line', tlcorner = (0,100))
|
||||||
assert(answer == (219,163))
|
assert(answer == (219,163))
|
||||||
|
|
||||||
def test_longer(self):
|
def test_longer(self):
|
||||||
answer = self.r._render_single_line(
|
answer = self.renderer._render_single_line(
|
||||||
u'Test line with more words than fit on one line',
|
u'Test line with more words than fit on one line',
|
||||||
tlcorner = (10,10))
|
tlcorner = (10,10))
|
||||||
assert(answer == (753,136))
|
assert(answer == (753,136))
|
||||||
|
|
||||||
def test_even_longer(self):
|
def test_even_longer(self):
|
||||||
answer = self.r._render_single_line(
|
answer = self.renderer._render_single_line(
|
||||||
u'Test line with more words than fit on either one or two lines',
|
u'Test line with more words than fit on either one or two lines',
|
||||||
tlcorner = (10,10))
|
tlcorner = (10,10))
|
||||||
assert(answer == (753,199))
|
assert(answer == (753,199))
|
||||||
@ -146,7 +150,7 @@ class TestRender(TestRender_base):
|
|||||||
lines.append(u'Line Two')
|
lines.append(u'Line Two')
|
||||||
lines.append(u'Line Three and should be long enough to wrap')
|
lines.append(u'Line Three and should be long enough to wrap')
|
||||||
lines.append(u'Line Four and should be long enough to wrap also')
|
lines.append(u'Line Four and should be long enough to wrap also')
|
||||||
answer = self.r._render_lines(lines)
|
answer = self.renderer._render_lines(lines)
|
||||||
assert(answer == QtCore.QRect(0,0,741,378))
|
assert(answer == QtCore.QRect(0,0,741,378))
|
||||||
|
|
||||||
def test_set_words_openlp(self):
|
def test_set_words_openlp(self):
|
||||||
@ -161,7 +165,7 @@ Verse 3: Line 1
|
|||||||
Line 2
|
Line 2
|
||||||
Line 3"""
|
Line 3"""
|
||||||
expected_answer = ["Verse 1: Line 1\nLine 2","Verse 2: Line 1\nLine 2","Verse 3: Line 1\nLine 2\nLine 3"]
|
expected_answer = ["Verse 1: Line 1\nLine 2","Verse 2: Line 1\nLine 2","Verse 3: Line 1\nLine 2\nLine 3"]
|
||||||
answer = self.r.set_words_openlp(words)
|
answer = self.renderer.set_words_openlp(words)
|
||||||
assert(answer == expected_answer)
|
assert(answer == expected_answer)
|
||||||
|
|
||||||
def test_render_screens(self):
|
def test_render_screens(self):
|
||||||
@ -175,14 +179,14 @@ Line 2
|
|||||||
Verse 3: Line 1
|
Verse 3: Line 1
|
||||||
Line 2
|
Line 2
|
||||||
Line 3"""
|
Line 3"""
|
||||||
verses = self.r.set_words_openlp(words)
|
verses = self.renderer.set_words_openlp(words)
|
||||||
expected_answer = ["Verse 1: Line 1\nLine 2","Verse 2: Line 1\nLine 2","Verse 3: Line 1\nLine 2\nLine 3"]
|
expected_answer = ["Verse 1: Line 1\nLine 2","Verse 2: Line 1\nLine 2","Verse 3: Line 1\nLine 2\nLine 3"]
|
||||||
assert(verses == expected_answer)
|
assert(verses == expected_answer)
|
||||||
|
|
||||||
expected_answer = [QtCore.QRect(0,0,397,126), QtCore.QRect(0,0,397,126),
|
expected_answer = [QtCore.QRect(0,0,397,126), QtCore.QRect(0,0,397,126),
|
||||||
QtCore.QRect(0,0,397,189)]
|
QtCore.QRect(0,0,397,189)]
|
||||||
for v in range(len(verses)):
|
for v in range(len(verses)):
|
||||||
answer=self.r.render_screen(v)
|
answer=self.renderer.render_screen(v)
|
||||||
# print v, answer.x(), answer.y(), answer.width(), answer.height()
|
# print v, answer.x(), answer.y(), answer.width(), answer.height()
|
||||||
assert(answer == expected_answer[v])
|
assert(answer == expected_answer[v])
|
||||||
|
|
||||||
@ -194,11 +198,11 @@ Line 3"""
|
|||||||
if i == 51: # make an extra long line on line 51 to test wrapping
|
if i == 51: # make an extra long line on line 51 to test wrapping
|
||||||
extra = "Some more words to make it wrap around don't you know until it wraps so many times we don't know what to do"
|
extra = "Some more words to make it wrap around don't you know until it wraps so many times we don't know what to do"
|
||||||
lines.append(u'Line %d %s' % (i, extra))
|
lines.append(u'Line %d %s' % (i, extra))
|
||||||
result = self.r.split_set_of_lines(lines)
|
result = self.renderer.split_set_of_lines(lines)
|
||||||
print "results---------------__", result
|
print "results---------------__", result
|
||||||
for i in range(len(result)):
|
for i in range(len(result)):
|
||||||
self.setup_method(None)
|
self.setup_method(None)
|
||||||
answer = self.r._render_lines(result[i])
|
answer = self.renderer._render_lines(result[i])
|
||||||
print answer
|
print answer
|
||||||
self.write_to_file(self.frame.GetPixmap(), "split_test_%03d"% i)
|
self.write_to_file(self.frame.GetPixmap(), "split_test_%03d"% i)
|
||||||
print number, i, answer.x(), answer.y(), answer.width(), \
|
print number, i, answer.x(), answer.y(), answer.width(), \
|
||||||
|
@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License along with
|
|||||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ def compare_images(goldenim, testim, threshold=0.01):
|
|||||||
# how close are they? Calculated the sum of absolute differences in
|
# how close are they? Calculated the sum of absolute differences in
|
||||||
# each channel of each pixel and divide by the number of pixels in the image
|
# each channel of each pixel and divide by the number of pixels in the image
|
||||||
# if this sum is < threshold, the images are deemed to be "close enough"
|
# if this sum is < threshold, the images are deemed to be "close enough"
|
||||||
sad=0;
|
sad = 0;
|
||||||
for x in range(goldenim.width()):
|
for x in range(goldenim.width()):
|
||||||
for y in range(goldenim.height()):
|
for y in range(goldenim.height()):
|
||||||
p1=goldenim.pixel(x,y)
|
p1=goldenim.pixel(x,y)
|
||||||
@ -44,9 +45,7 @@ def compare_images(goldenim, testim, threshold=0.01):
|
|||||||
sad /= float(goldenim.width()*goldenim.height())
|
sad /= float(goldenim.width()*goldenim.height())
|
||||||
if (sad < threshold):
|
if (sad < threshold):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
class TestRenderTheme(TestRender_base):
|
class TestRenderTheme(TestRender_base):
|
||||||
# {{{ Basics
|
# {{{ Basics
|
||||||
@ -58,15 +57,15 @@ class TestRenderTheme(TestRender_base):
|
|||||||
TestRender_base.setup_method(self, method)
|
TestRender_base.setup_method(self, method)
|
||||||
print "Theme setup", method
|
print "Theme setup", method
|
||||||
# print "setup theme"
|
# print "setup theme"
|
||||||
self.r.set_theme(Theme(u'blank_theme.xml')) # set "blank" theme
|
self.renderer.set_theme(Theme(u'blank_theme.xml')) # set "blank" theme
|
||||||
self.r.set_text_rectangle(QtCore.QRect(0,0, self.size.width(),
|
self.renderer.set_text_rectangle(QtCore.QRect(0,0, self.size.width(),
|
||||||
self.size.height()))
|
self.size.height()))
|
||||||
words = """How sweet the name of Jesus sounds
|
words = """How sweet the name of Jesus sounds
|
||||||
In a believer's ear!
|
In a believer's ear!
|
||||||
It soothes his sorrows, heals his wounds,
|
It soothes his sorrows, heals his wounds,
|
||||||
And drives away his fear.
|
And drives away his fear.
|
||||||
"""
|
"""
|
||||||
verses = self.r.set_words_openlp(words)
|
verses = self.renderer.set_words_openlp(words)
|
||||||
# usually the same
|
# usually the same
|
||||||
self.expected_answer = QtCore.QRect(0, 0, 559, 342)
|
self.expected_answer = QtCore.QRect(0, 0, 559, 342)
|
||||||
self.msg = None
|
self.msg = None
|
||||||
@ -75,9 +74,9 @@ And drives away his fear.
|
|||||||
|
|
||||||
def teardown_method(self, method):
|
def teardown_method(self, method):
|
||||||
print "============ teardown =============", method, self.bmpname
|
print "============ teardown =============", method, self.bmpname
|
||||||
if self.bmpname != None:
|
if self.bmpname is not None:
|
||||||
assert (self.compare_DC_to_file(self.bmpname))
|
assert (self.compare_DC_to_file(self.bmpname))
|
||||||
if self.expected_answer != None: # result=None => No result to check
|
if self.expected_answer is not None: # result=None => Nothing to check
|
||||||
assert self.expected_answer == self.answer
|
assert self.expected_answer == self.answer
|
||||||
print "============ teardown done ========="
|
print "============ teardown done ========="
|
||||||
|
|
||||||
@ -104,9 +103,9 @@ And drives away his fear.
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def test_theme_basic(self):
|
def test_theme_basic(self):
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
print self.r._theme.FontProportion
|
print self.renderer._theme.FontProportion
|
||||||
print self.answer, self.expected_answer, \
|
print self.answer, self.expected_answer, \
|
||||||
self.answer == self.expected_answer
|
self.answer == self.expected_answer
|
||||||
# self.msg=self.bmpname
|
# self.msg=self.bmpname
|
||||||
@ -116,20 +115,20 @@ And drives away his fear.
|
|||||||
# {{{ Gradients
|
# {{{ Gradients
|
||||||
def test_gradient_h(self):
|
def test_gradient_h(self):
|
||||||
# normally we wouldn't hack with these directly!
|
# normally we wouldn't hack with these directly!
|
||||||
self.r._theme.BackgroundType = 1
|
self.renderer._theme.BackgroundType = 1
|
||||||
self.r._theme.BackgroundParameter1 = QtGui.QColor(255,0,0)
|
self.renderer._theme.BackgroundParameter1 = QtGui.QColor(255,0,0)
|
||||||
self.r._theme.BackgroundParameter2 = QtGui.QColor(255,255,0)
|
self.renderer._theme.BackgroundParameter2 = QtGui.QColor(255,255,0)
|
||||||
self.r._theme.BackgroundParameter3 = 1
|
self.renderer._theme.BackgroundParameter3 = 1
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
|
|
||||||
def test_gradient_v(self):
|
def test_gradient_v(self):
|
||||||
# normally we wouldn't hack with these directly!
|
# normally we wouldn't hack with these directly!
|
||||||
self.r._theme.BackgroundType = 1
|
self.renderer._theme.BackgroundType = 1
|
||||||
self.r._theme.BackgroundParameter1 = QtGui.QColor(255,0,0)
|
self.renderer._theme.BackgroundParameter1 = QtGui.QColor(255,0,0)
|
||||||
self.r._theme.BackgroundParameter2 = QtGui.QColor(255,255,0)
|
self.renderer._theme.BackgroundParameter2 = QtGui.QColor(255,255,0)
|
||||||
self.r._theme.BackgroundParameter3 = 0
|
self.renderer._theme.BackgroundParameter3 = 0
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@ -142,9 +141,9 @@ And drives away his fear.
|
|||||||
t.BackgroundParameter2 = QtGui.QColor(0,0,64)
|
t.BackgroundParameter2 = QtGui.QColor(0,0,64)
|
||||||
t.BackgroundParameter3 = 0
|
t.BackgroundParameter3 = 0
|
||||||
t.Name = "stretch y"
|
t.Name = "stretch y"
|
||||||
self.r.set_theme(t)
|
self.renderer.set_theme(t)
|
||||||
print "render"
|
print "render"
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
print "whoami"
|
print "whoami"
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
print "fone"
|
print "fone"
|
||||||
@ -156,8 +155,8 @@ And drives away his fear.
|
|||||||
t.BackgroundParameter2 = QtGui.QColor(0,0,64)
|
t.BackgroundParameter2 = QtGui.QColor(0,0,64)
|
||||||
t.BackgroundParameter3 = 0
|
t.BackgroundParameter3 = 0
|
||||||
t.Name = "shrink y"
|
t.Name = "shrink y"
|
||||||
self.r.set_theme(t)
|
self.renderer.set_theme(t)
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
|
|
||||||
def test_bg_stretch_x(self):
|
def test_bg_stretch_x(self):
|
||||||
@ -169,8 +168,8 @@ And drives away his fear.
|
|||||||
t.BackgroundParameter3 = 0
|
t.BackgroundParameter3 = 0
|
||||||
t.VerticalAlign = 2
|
t.VerticalAlign = 2
|
||||||
t.Name = "stretch x"
|
t.Name = "stretch x"
|
||||||
self.r.set_theme(t)
|
self.renderer.set_theme(t)
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
self.expected_answer = QtCore.QRect(0, 129, 559, 342)
|
self.expected_answer = QtCore.QRect(0, 129, 559, 342)
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
|
|
||||||
@ -183,9 +182,9 @@ And drives away his fear.
|
|||||||
t.BackgroundParameter3 = 0
|
t.BackgroundParameter3 = 0
|
||||||
t.VerticalAlign = 2
|
t.VerticalAlign = 2
|
||||||
t.Name = "shrink x"
|
t.Name = "shrink x"
|
||||||
self.r.set_theme(t)
|
self.renderer.set_theme(t)
|
||||||
self.expected_answer = QtCore.QRect(0, 129, 559, 342)
|
self.expected_answer = QtCore.QRect(0, 129, 559, 342)
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@ -196,8 +195,8 @@ And drives away his fear.
|
|||||||
t.BackgroundParameter1 = QtGui.QColor(0,0,64)
|
t.BackgroundParameter1 = QtGui.QColor(0,0,64)
|
||||||
t.VerticalAlign = 0
|
t.VerticalAlign = 0
|
||||||
t.Name = "valign top"
|
t.Name = "valign top"
|
||||||
self.r.set_theme(t)
|
self.renderer.set_theme(t)
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
|
|
||||||
def test_theme_vertical_align_bot(self):
|
def test_theme_vertical_align_bot(self):
|
||||||
@ -206,8 +205,8 @@ And drives away his fear.
|
|||||||
t.BackgroundParameter1 = QtGui.QColor(0,0,64)
|
t.BackgroundParameter1 = QtGui.QColor(0,0,64)
|
||||||
t.VerticalAlign = 1
|
t.VerticalAlign = 1
|
||||||
t.Name = "valign bot"
|
t.Name = "valign bot"
|
||||||
self.r.set_theme(t)
|
self.renderer.set_theme(t)
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
self.expected_answer = QtCore.QRect(0, 257, 559, 342)
|
self.expected_answer = QtCore.QRect(0, 257, 559, 342)
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
|
|
||||||
@ -217,8 +216,8 @@ And drives away his fear.
|
|||||||
t.BackgroundParameter1 = QtGui.QColor(0,0,64)
|
t.BackgroundParameter1 = QtGui.QColor(0,0,64)
|
||||||
t.VerticalAlign = 2
|
t.VerticalAlign = 2
|
||||||
t.Name = "valign cen"
|
t.Name = "valign cen"
|
||||||
self.r.set_theme(t)
|
self.renderer.set_theme(t)
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
self.expected_answer = QtCore.QRect(0, 129, 559, 342)
|
self.expected_answer = QtCore.QRect(0, 129, 559, 342)
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
# }}}
|
# }}}
|
||||||
@ -231,8 +230,8 @@ And drives away his fear.
|
|||||||
t.VerticalAlign = 0
|
t.VerticalAlign = 0
|
||||||
t.HorizontalAlign = 0
|
t.HorizontalAlign = 0
|
||||||
t.Name = "halign left"
|
t.Name = "halign left"
|
||||||
self.r.set_theme(t)
|
self.renderer.set_theme(t)
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
|
|
||||||
def test_theme_horizontal_align_right(self):
|
def test_theme_horizontal_align_right(self):
|
||||||
@ -242,9 +241,9 @@ And drives away his fear.
|
|||||||
t.VerticalAlign = 0
|
t.VerticalAlign = 0
|
||||||
t.HorizontalAlign = 1
|
t.HorizontalAlign = 1
|
||||||
t.Name = "halign right"
|
t.Name = "halign right"
|
||||||
self.r.set_theme(t)
|
self.renderer.set_theme(t)
|
||||||
self.expected_answer = QtCore.QRect(0, 0, 800, 342)
|
self.expected_answer = QtCore.QRect(0, 0, 800, 342)
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
|
|
||||||
def test_theme_horizontal_align_centre(self):
|
def test_theme_horizontal_align_centre(self):
|
||||||
@ -254,8 +253,8 @@ And drives away his fear.
|
|||||||
t.VerticalAlign = 0
|
t.VerticalAlign = 0
|
||||||
t.HorizontalAlign = 2
|
t.HorizontalAlign = 2
|
||||||
t.Name = "halign centre"
|
t.Name = "halign centre"
|
||||||
self.r.set_theme(t)
|
self.renderer.set_theme(t)
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
self.expected_answer = QtCore.QRect(0, 0, 679, 342)
|
self.expected_answer = QtCore.QRect(0, 0, 679, 342)
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
|
|
||||||
@ -267,8 +266,8 @@ And drives away his fear.
|
|||||||
t.HorizontalAlign = 0
|
t.HorizontalAlign = 0
|
||||||
t.WrapStyle = 1
|
t.WrapStyle = 1
|
||||||
t.Name = "halign left lyric"
|
t.Name = "halign left lyric"
|
||||||
self.r.set_theme(t)
|
self.renderer.set_theme(t)
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
self.expected_answer = QtCore.QRect(0, 0, 778, 342)
|
self.expected_answer = QtCore.QRect(0, 0, 778, 342)
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
# }}}
|
# }}}
|
||||||
@ -284,11 +283,11 @@ And drives away his fear.
|
|||||||
t.Outline = 1
|
t.Outline = 1
|
||||||
t.ShadowColor = QtGui.QColor(64,128,0)
|
t.ShadowColor = QtGui.QColor(64,128,0)
|
||||||
t.OutlineColor = QtGui.QColor(128,0,0)
|
t.OutlineColor = QtGui.QColor(128,0,0)
|
||||||
self.r.set_debug(1)
|
self.renderer.set_debug(1)
|
||||||
self.r.set_theme(t)
|
self.renderer.set_theme(t)
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
hoffset = self.r._shadow_offset+2*(self.r._outline_offset)
|
hoffset = self.renderer._shadow_offset+2*(self.renderer._outline_offset)
|
||||||
voffset = hoffset * (len(self.r.words[0])+1)
|
voffset = hoffset * (len(self.renderer.words[0])+1)
|
||||||
|
|
||||||
self.expected_answer = QtCore.QRect(0, 0, 559+hoffset, 342+voffset)
|
self.expected_answer = QtCore.QRect(0, 0, 559+hoffset, 342+voffset)
|
||||||
self.bmpname = whoami()
|
self.bmpname = whoami()
|
||||||
@ -300,15 +299,14 @@ And drives away his fear.
|
|||||||
t.BackgroundParameter1 = QtGui.QColor(0,0,64)
|
t.BackgroundParameter1 = QtGui.QColor(0,0,64)
|
||||||
t.Name = "font"
|
t.Name = "font"
|
||||||
t.FontName = "Times New Roman"
|
t.FontName = "Times New Roman"
|
||||||
self.r.set_theme(t)
|
self.renderer.set_theme(t)
|
||||||
self.answer = self.r.render_screen(0)
|
self.answer = self.renderer.render_screen(0)
|
||||||
self.expected_answer = QtCore.QRect(0, 0, 499, 336)
|
self.expected_answer = QtCore.QRect(0, 0, 499, 336)
|
||||||
self.bmpname=whoami()
|
self.bmpname=whoami()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
t = TestRenderTheme()
|
test_render_theme = TestRenderTheme()
|
||||||
t.setup_class()
|
test_render_theme.setup_class()
|
||||||
t.setup_method(None)
|
test_render_theme.setup_method(None)
|
||||||
t.test_bg_stretch_y()
|
test_render_theme.test_bg_stretch_y()
|
||||||
t.teardown_method(None)
|
test_render_theme.teardown_method(None)
|
||||||
|
@ -1,55 +1,57 @@
|
|||||||
import os
|
import os
|
||||||
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
mypath=os.path.split(os.path.abspath(__file__))[0]
|
|
||||||
|
|
||||||
sys.path.insert(0,(os.path.join(mypath, '..' ,'..', '..', '..')))
|
from PyQt4 import QtGui
|
||||||
print sys.path
|
|
||||||
|
|
||||||
from openlp.core.theme import Theme
|
from openlp.core.theme import Theme
|
||||||
import os.path
|
|
||||||
from PyQt4 import QtGui
|
mypath = os.path.split(os.path.abspath(__file__))[0]
|
||||||
|
sys.path.insert(0, (os.path.join(mypath, '..', '..', '..', '..')))
|
||||||
|
|
||||||
|
print sys.path
|
||||||
|
|
||||||
def test_read_theme():
|
def test_read_theme():
|
||||||
dir=os.path.split(__file__)[0]
|
dir = os.path.split(__file__)[0]
|
||||||
# test we can read a theme
|
# test we can read a theme
|
||||||
t=Theme(os.path.join(dir, 'test_theme.xml'))
|
theme = Theme(os.path.join(dir, 'test_theme.xml'))
|
||||||
print t
|
print theme
|
||||||
assert(t.BackgroundParameter1 == 'sunset1.jpg')
|
assert(theme.BackgroundParameter1 == 'sunset1.jpg')
|
||||||
assert(t.BackgroundParameter2 == None)
|
assert(theme.BackgroundParameter2 is None)
|
||||||
assert(t.BackgroundParameter3 == None)
|
assert(theme.BackgroundParameter3 is None)
|
||||||
assert(t.BackgroundType == 2)
|
assert(theme.BackgroundType == 2)
|
||||||
assert(t.FontColor == QtGui.QColor(255,255,255))
|
assert(theme.FontColor == QtGui.QColor(255,255,255))
|
||||||
assert(t.FontName == 'Tahoma')
|
assert(theme.FontName == 'Tahoma')
|
||||||
assert(t.FontProportion == 16)
|
assert(theme.FontProportion == 16)
|
||||||
assert(t.FontUnits == 'pixels')
|
assert(theme.FontUnits == 'pixels')
|
||||||
assert(t.HorizontalAlign == 2)
|
assert(theme.HorizontalAlign == 2)
|
||||||
assert(t.Name == 'openlp.org Packaged Theme')
|
assert(theme.Name == 'openlp.org Packaged Theme')
|
||||||
assert(t.Outline == -1)
|
assert(theme.Outline == -1)
|
||||||
assert(t.OutlineColor == QtGui.QColor(255,0,0))
|
assert(theme.OutlineColor == QtGui.QColor(255,0,0))
|
||||||
assert(t.Shadow == -1)
|
assert(theme.Shadow == -1)
|
||||||
assert(t.ShadowColor == QtGui.QColor(0,0,1))
|
assert(theme.ShadowColor == QtGui.QColor(0,0,1))
|
||||||
assert(t.VerticalAlign == 0)
|
assert(theme.VerticalAlign == 0)
|
||||||
|
|
||||||
def test_theme():
|
def test_theme():
|
||||||
# test we create a "blank" theme correctly
|
# test we create a "blank" theme correctly
|
||||||
t=Theme()
|
theme = Theme()
|
||||||
print t
|
print theme
|
||||||
assert(t.BackgroundParameter1 == QtGui.QColor(0,0,0))
|
assert(theme.BackgroundParameter1 == QtGui.QColor(0,0,0))
|
||||||
assert(t.BackgroundParameter2 == None)
|
assert(theme.BackgroundParameter2 is None)
|
||||||
assert(t.BackgroundParameter3 == None)
|
assert(theme.BackgroundParameter3 is None)
|
||||||
assert(t.BackgroundType == 0)
|
assert(theme.BackgroundType == 0)
|
||||||
assert(t.FontColor == QtGui.QColor(255,255,255))
|
assert(theme.FontColor == QtGui.QColor(255,255,255))
|
||||||
assert(t.FontName == 'Arial')
|
assert(theme.FontName == 'Arial')
|
||||||
assert(t.FontProportion == 30)
|
assert(theme.FontProportion == 30)
|
||||||
assert(t.HorizontalAlign == 0)
|
assert(theme.HorizontalAlign == 0)
|
||||||
assert(t.FontUnits == 'pixels')
|
assert(theme.FontUnits == 'pixels')
|
||||||
assert(t.Name == 'BlankStyle')
|
assert(theme.Name == 'BlankStyle')
|
||||||
assert(t.Outline == 0)
|
assert(theme.Outline == 0)
|
||||||
assert(t.Shadow == 0)
|
assert(theme.Shadow == 0)
|
||||||
assert(t.VerticalAlign == 0)
|
assert(theme.VerticalAlign == 0)
|
||||||
|
|
||||||
|
|
||||||
print "Tests passed"
|
print "Tests passed"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_read_theme()
|
test_read_theme()
|
||||||
test_theme()
|
test_theme()
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os, os.path
|
import os
|
||||||
|
import os.path
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
@ -178,7 +179,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
|
|
||||||
def loadTheme(self, theme):
|
def loadTheme(self, theme):
|
||||||
log.debug(u'LoadTheme %s', theme)
|
log.debug(u'LoadTheme %s', theme)
|
||||||
if theme == None:
|
if theme is None:
|
||||||
self.theme.parse(self.thememanager.baseTheme())
|
self.theme.parse(self.thememanager.baseTheme())
|
||||||
else:
|
else:
|
||||||
xml_file = os.path.join(self.path, theme, theme + u'.xml')
|
xml_file = os.path.join(self.path, theme, theme + u'.xml')
|
||||||
|
@ -420,8 +420,6 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.config.set_last_dir(filename)
|
self.config.set_last_dir(filename)
|
||||||
try:
|
try:
|
||||||
zip = zipfile.ZipFile(unicode(filename))
|
zip = zipfile.ZipFile(unicode(filename))
|
||||||
filexml = None
|
|
||||||
themename = None
|
|
||||||
for file in zip.namelist():
|
for file in zip.namelist():
|
||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
winfile = string.replace(file, '/', os.path.sep)
|
winfile = string.replace(file, '/', os.path.sep)
|
||||||
|
@ -292,7 +292,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
label = QtGui.QLabel()
|
label = QtGui.QLabel()
|
||||||
label.setMargin(8)
|
label.setMargin(8)
|
||||||
#It is a Image
|
#It is a Image
|
||||||
if frame[u'text'] == None:
|
if frame[u'text'] is None:
|
||||||
pixmap = self.parent.RenderManager.resize_image(frame[u'image'])
|
pixmap = self.parent.RenderManager.resize_image(frame[u'image'])
|
||||||
label.setScaledContents(True)
|
label.setScaledContents(True)
|
||||||
label.setPixmap(QtGui.QPixmap.fromImage(pixmap))
|
label.setPixmap(QtGui.QPixmap.fromImage(pixmap))
|
||||||
@ -340,7 +340,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
label = self.PreviewListWidget.cellWidget(row, 0)
|
label = self.PreviewListWidget.cellWidget(row, 0)
|
||||||
frame = self.serviceitem.frames[row][u'image']
|
frame = self.serviceitem.frames[row][u'image']
|
||||||
before = time.time()
|
before = time.time()
|
||||||
if frame == None:
|
if frame is None:
|
||||||
frame = self.serviceitem.render_individual(row)
|
frame = self.serviceitem.render_individual(row)
|
||||||
self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
|
self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
|
||||||
log.info(u'Slide Rendering took %4s' % (time.time() - before))
|
log.info(u'Slide Rendering took %4s' % (time.time() - before))
|
||||||
|
@ -17,7 +17,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os, os.path
|
import os
|
||||||
|
import os.path
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
@ -26,7 +26,7 @@ import logging
|
|||||||
|
|
||||||
class Display():
|
class Display():
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger(u'Display Logger')
|
log = logging.getLogger(u'Display Logger')
|
||||||
log.info(u'Display Class loaded')
|
log.info(u'Display Class loaded')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -36,6 +36,6 @@ class Display():
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def sub_output(string):
|
def sub_output(string):
|
||||||
if not string == None:
|
if not string is None:
|
||||||
log.debug(u' '+string);
|
log.debug(u' '+string);
|
||||||
print (u' '+string)
|
print (u' '+string)
|
||||||
|
@ -168,7 +168,6 @@ class MigrateSongs():
|
|||||||
author.first_name = u''
|
author.first_name = u''
|
||||||
author.last_name = u''
|
author.last_name = u''
|
||||||
else:
|
else:
|
||||||
id = int(bb[0])
|
|
||||||
author = self.session.query(Author).get(bb[0])
|
author = self.session.query(Author).get(bb[0])
|
||||||
song.authors.append(author)
|
song.authors.append(author)
|
||||||
try:
|
try:
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os, os.path
|
import os
|
||||||
|
import os.path
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ from openlp.core.lib import Receiver, translate
|
|||||||
|
|
||||||
class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
|
class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger(u'BibleImportForm')
|
log = logging.getLogger(u'BibleImportForm')
|
||||||
log.info(u'BibleImportForm loaded')
|
log.info(u'BibleImportForm loaded')
|
||||||
"""
|
"""
|
||||||
Class documentation goes here.
|
Class documentation goes here.
|
||||||
@ -136,13 +137,16 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
|
|||||||
self.checkOsis()
|
self.checkOsis()
|
||||||
|
|
||||||
def onProxyAddressEditLostFocus(self):
|
def onProxyAddressEditLostFocus(self):
|
||||||
self.config.set_config(u'proxy_address', unicode(self.AddressEdit.displayText()))
|
self.config.set_config(
|
||||||
|
u'proxy_address', unicode(self.AddressEdit.displayText()))
|
||||||
|
|
||||||
def onProxyUsernameEditLostFocus(self):
|
def onProxyUsernameEditLostFocus(self):
|
||||||
self.config.set_config(u'proxy_username', unicode(self.UsernameEdit.displayText()))
|
self.config.set_config(
|
||||||
|
u'proxy_username', unicode(self.UsernameEdit.displayText()))
|
||||||
|
|
||||||
def onProxyPasswordEditLostFocus(self):
|
def onProxyPasswordEditLostFocus(self):
|
||||||
self.config.set_config(u'proxy_password', unicode(self.PasswordEdit.displayText()))
|
self.config.set_config(
|
||||||
|
u'proxy_password', unicode(self.PasswordEdit.displayText()))
|
||||||
|
|
||||||
def onLocationComboBoxSelected(self):
|
def onLocationComboBoxSelected(self):
|
||||||
self.checkHttp()
|
self.checkHttp()
|
||||||
@ -161,8 +165,9 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
|
|||||||
|
|
||||||
def onImportButtonClicked(self):
|
def onImportButtonClicked(self):
|
||||||
message = u'Bible import completed'
|
message = u'Bible import completed'
|
||||||
if self.biblemanager != None:
|
if self.biblemanager is not None:
|
||||||
if not self.bible_type == None and len(self.BibleNameEdit.displayText()) > 0:
|
if not self.bible_type is None and \
|
||||||
|
len(self.BibleNameEdit.displayText()) > 0:
|
||||||
self.MessageLabel.setText(u'Import Started')
|
self.MessageLabel.setText(u'Import Started')
|
||||||
self.ProgressBar.setMinimum(0)
|
self.ProgressBar.setMinimum(0)
|
||||||
self.setMax(65)
|
self.setMax(65)
|
||||||
@ -286,7 +291,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
|
|||||||
|
|
||||||
def resetScreenFieldStates(self):
|
def resetScreenFieldStates(self):
|
||||||
# only reset if no bible type set.
|
# only reset if no bible type set.
|
||||||
if self.bible_type == None:
|
if self.bible_type is None:
|
||||||
self.BooksLocationEdit.setReadOnly(False)
|
self.BooksLocationEdit.setReadOnly(False)
|
||||||
self.VerseLocationEdit.setReadOnly(False)
|
self.VerseLocationEdit.setReadOnly(False)
|
||||||
self.BooksFileButton.setEnabled(True)
|
self.BooksFileButton.setEnabled(True)
|
||||||
|
@ -137,12 +137,12 @@ class BibleDBImpl(BibleCommon):
|
|||||||
|
|
||||||
def get_bible_book(self, bookname):
|
def get_bible_book(self, bookname):
|
||||||
log.debug(u'get_bible_book %s', bookname)
|
log.debug(u'get_bible_book %s', bookname)
|
||||||
bk = self.session.query(Book).filter(
|
book = self.session.query(Book).filter(
|
||||||
Book.name.like(bookname + u'%')).first()
|
Book.name.like(bookname + u'%')).first()
|
||||||
if bk == None:
|
if book is None:
|
||||||
bk = self.session.query(Book).filter(
|
book = self.session.query(Book).filter(
|
||||||
Book.abbreviation.like(bookname + u'%')).first()
|
Book.abbreviation.like(bookname + u'%')).first()
|
||||||
return bk
|
return book
|
||||||
|
|
||||||
def get_bible_chapter(self, id, chapter):
|
def get_bible_chapter(self, id, chapter):
|
||||||
log.debug(u'get_bible_chapter %s, %s', id, chapter)
|
log.debug(u'get_bible_chapter %s, %s', id, chapter)
|
||||||
|
@ -195,19 +195,19 @@ class BibleHTTPImpl():
|
|||||||
|
|
||||||
Init confirms the bible exists and stores the database path.
|
Init confirms the bible exists and stores the database path.
|
||||||
"""
|
"""
|
||||||
bible = {}
|
#bible = {}
|
||||||
biblesource = ''
|
self.biblesource = ''
|
||||||
proxyurl = None
|
self.proxyurl = None
|
||||||
bibleid = None
|
self.bibleid = None
|
||||||
|
|
||||||
def set_proxy(self,proxyurl):
|
def set_proxy(self, proxyurl):
|
||||||
"""
|
"""
|
||||||
Set the Proxy Url
|
Set the Proxy Url
|
||||||
"""
|
"""
|
||||||
log.debug(u'set_proxy %s', proxyurl)
|
log.debug(u'set_proxy %s', proxyurl)
|
||||||
self.proxyurl = proxyurl
|
self.proxyurl = proxyurl
|
||||||
|
|
||||||
def set_bibleid(self,bibleid):
|
def set_bibleid(self, bibleid):
|
||||||
"""
|
"""
|
||||||
Set the bible id.
|
Set the bible id.
|
||||||
The shore identifier of the the bible.
|
The shore identifier of the the bible.
|
||||||
@ -215,7 +215,7 @@ class BibleHTTPImpl():
|
|||||||
log.debug(u'set_bibleid %s', bibleid)
|
log.debug(u'set_bibleid %s', bibleid)
|
||||||
self.bibleid = bibleid
|
self.bibleid = bibleid
|
||||||
|
|
||||||
def set_bible_source(self,biblesource):
|
def set_bible_source(self, biblesource):
|
||||||
"""
|
"""
|
||||||
Set the source of where the bible text is coming from
|
Set the source of where the bible text is coming from
|
||||||
"""
|
"""
|
||||||
@ -235,6 +235,5 @@ class BibleHTTPImpl():
|
|||||||
else:
|
else:
|
||||||
ev = BGExtract(self.proxyurl)
|
ev = BGExtract(self.proxyurl)
|
||||||
return ev.get_bible_chapter(self.bibleid, bookid, bookname, chapter)
|
return ev.get_bible_chapter(self.bibleid, bookid, bookname, chapter)
|
||||||
except Exception, e:
|
except:
|
||||||
log.error(u'Error thrown = %s', e.args[0])
|
log.exception("Failed to get bible chapter")
|
||||||
print e
|
|
||||||
|
@ -90,7 +90,7 @@ class BibleOSISImpl():
|
|||||||
detect_file.close()
|
detect_file.close()
|
||||||
osis = codecs.open(osisfile_record, u'r', details['encoding'])
|
osis = codecs.open(osisfile_record, u'r', details['encoding'])
|
||||||
book_ptr = None
|
book_ptr = None
|
||||||
id = 0
|
#id = 0
|
||||||
count = 0
|
count = 0
|
||||||
verseText = u'<verse osisID='
|
verseText = u'<verse osisID='
|
||||||
testament = 1
|
testament = 1
|
||||||
@ -138,7 +138,7 @@ class BibleOSISImpl():
|
|||||||
p = ref.split(u'.', 3)
|
p = ref.split(u'.', 3)
|
||||||
if book_ptr != p[0]:
|
if book_ptr != p[0]:
|
||||||
# first time through
|
# first time through
|
||||||
if book_ptr == None:
|
if book_ptr is None:
|
||||||
# set the max book size depending on the first book read
|
# set the max book size depending on the first book read
|
||||||
if p[0] == u'Gen':
|
if p[0] == u'Gen':
|
||||||
dialogobject.setMax(65)
|
dialogobject.setMax(65)
|
||||||
|
@ -39,7 +39,7 @@ class BibleManager(object):
|
|||||||
The Bible manager which holds and manages all the Bibles.
|
The Bible manager which holds and manages all the Bibles.
|
||||||
"""
|
"""
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger(u'BibleManager')
|
log = logging.getLogger(u'BibleManager')
|
||||||
log.info(u'Bible manager loaded')
|
log.info(u'Bible manager loaded')
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
@ -102,7 +102,7 @@ class BibleManager(object):
|
|||||||
# look to see if lazy load bible exists and get create getter.
|
# look to see if lazy load bible exists and get create getter.
|
||||||
meta = self.bible_db_cache[bname].get_meta(u'proxy')
|
meta = self.bible_db_cache[bname].get_meta(u'proxy')
|
||||||
proxy = None
|
proxy = None
|
||||||
if meta != None:
|
if meta is not None:
|
||||||
proxy = meta.value
|
proxy = meta.value
|
||||||
# tell The Server where to get the verses from.
|
# tell The Server where to get the verses from.
|
||||||
nhttp.set_proxy(proxy)
|
nhttp.set_proxy(proxy)
|
||||||
@ -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 != None and proxyurl != "":
|
if proxyurl is not None and proxyurl != "":
|
||||||
# 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 != None and proxyid != "":
|
if proxyid is not None and proxyid != "":
|
||||||
# store the proxy userid
|
# store the proxy userid
|
||||||
nbible.save_meta(u'proxyid', proxyid)
|
nbible.save_meta(u'proxyid', proxyid)
|
||||||
if proxypass != None and proxypass != "":
|
if proxypass is not None and proxypass != "":
|
||||||
# store the proxy password
|
# store the proxy password
|
||||||
nbible.save_meta(u'proxypass', proxypass)
|
nbible.save_meta(u'proxypass', proxypass)
|
||||||
return True
|
return True
|
||||||
@ -329,8 +329,8 @@ c
|
|||||||
# check to see if book/chapter exists fow HTTP bibles and load cache
|
# check to see if book/chapter exists fow HTTP bibles and load cache
|
||||||
# if necessary
|
# if necessary
|
||||||
if self.bible_http_cache[bible] is not None:
|
if self.bible_http_cache[bible] is not None:
|
||||||
book= self.bible_db_cache[bible].get_bible_book(bookname)
|
book = self.bible_db_cache[bible].get_bible_book(bookname)
|
||||||
if book == None:
|
if book is None:
|
||||||
self.media.setQuickMsg1(u'Downloading')
|
self.media.setQuickMsg1(u'Downloading')
|
||||||
log.debug(u'get_verse_text : new book')
|
log.debug(u'get_verse_text : new book')
|
||||||
for chapter in range(schapter, echapter + 1):
|
for chapter in range(schapter, echapter + 1):
|
||||||
@ -347,7 +347,7 @@ c
|
|||||||
# check to see if book/chapter exists
|
# check to see if book/chapter exists
|
||||||
book = self.bible_db_cache[bible].get_bible_book(
|
book = self.bible_db_cache[bible].get_bible_book(
|
||||||
bookname)
|
bookname)
|
||||||
if book == None:
|
if book is None:
|
||||||
## Then create book, chapter and text
|
## Then create book, chapter and text
|
||||||
book = self.bible_db_cache[bible].create_book(
|
book = self.bible_db_cache[bible].create_book(
|
||||||
bookname, self.book_abbreviations[bookname],
|
bookname, self.book_abbreviations[bookname],
|
||||||
@ -361,7 +361,7 @@ c
|
|||||||
## Book exists check chapter and texts only.
|
## Book exists check chapter and texts only.
|
||||||
v = self.bible_db_cache[bible].get_bible_chapter(
|
v = self.bible_db_cache[bible].get_bible_chapter(
|
||||||
book.id, chapter)
|
book.id, chapter)
|
||||||
if v == None:
|
if v is None:
|
||||||
self.media.setQuickMsg2(u'%s: %s'% (
|
self.media.setQuickMsg2(u'%s: %s'% (
|
||||||
bookname, chapter))
|
bookname, chapter))
|
||||||
self.bible_db_cache[bible].create_chapter(
|
self.bible_db_cache[bible].create_chapter(
|
||||||
@ -372,7 +372,7 @@ c
|
|||||||
for chapter in range(schapter, echapter + 1):
|
for chapter in range(schapter, echapter + 1):
|
||||||
v = self.bible_db_cache[bible].get_bible_chapter(
|
v = self.bible_db_cache[bible].get_bible_chapter(
|
||||||
book.id, chapter)
|
book.id, chapter)
|
||||||
if v == None:
|
if v is None:
|
||||||
try:
|
try:
|
||||||
self.media.setQuickMsg1(u'Downloading')
|
self.media.setQuickMsg1(u'Downloading')
|
||||||
self.media.setQuickMsg2(u'%s: %s'% \
|
self.media.setQuickMsg2(u'%s: %s'% \
|
||||||
@ -411,8 +411,8 @@ c
|
|||||||
"""
|
"""
|
||||||
Check cache to see if new bible
|
Check cache to see if new bible
|
||||||
"""
|
"""
|
||||||
for b, o in self.bible_db_cache.iteritems():
|
for bible, o in self.bible_db_cache.iteritems():
|
||||||
log.debug(u'Bible from cache in is_new_bible %s', b )
|
log.debug(u'Bible from cache in is_new_bible %s', bible)
|
||||||
if b == name :
|
if bible == name:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
@ -315,14 +315,14 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.adjustComboBox(frm, self.verses, self.AdvancedToVerse)
|
self.adjustComboBox(frm, self.verses, self.AdvancedToVerse)
|
||||||
|
|
||||||
def onAdvancedToChapter(self):
|
def onAdvancedToChapter(self):
|
||||||
t1 = self.AdvancedFromChapter.currentText()
|
text1 = self.AdvancedFromChapter.currentText()
|
||||||
t2 = self.AdvancedToChapter.currentText()
|
text2 = self.AdvancedToChapter.currentText()
|
||||||
if t1 != t2:
|
if text1 != text2:
|
||||||
bible = unicode(self.AdvancedVersionComboBox.currentText())
|
bible = unicode(self.AdvancedVersionComboBox.currentText())
|
||||||
book = unicode(self.AdvancedBookComboBox.currentText())
|
book = unicode(self.AdvancedBookComboBox.currentText())
|
||||||
# get the verse count for new chapter
|
# get the verse count for new chapter
|
||||||
verses = self.parent.biblemanager.get_book_verse_count(
|
verses = self.parent.biblemanager.get_book_verse_count(
|
||||||
bible, book, int(t2))[0]
|
bible, book, int(text2))[0]
|
||||||
self.adjustComboBox(1, verses, self.AdvancedToVerse)
|
self.adjustComboBox(1, verses, self.AdvancedToVerse)
|
||||||
|
|
||||||
def onAdvancedSearchButton(self):
|
def onAdvancedSearchButton(self):
|
||||||
@ -482,7 +482,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
start_verse = u''
|
start_verse = u''
|
||||||
end_verse = u''
|
end_verse = u''
|
||||||
search = search.replace(u' ', u' ').strip()
|
search = search.replace(u' ', u' ').strip()
|
||||||
original = search
|
#original = search
|
||||||
message = None
|
message = None
|
||||||
# Remove book beware 0 index arrays
|
# Remove book beware 0 index arrays
|
||||||
for i in range (len(search)-1, 0, - 1):
|
for i in range (len(search)-1, 0, - 1):
|
||||||
@ -547,7 +547,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
log.debug(u'results = %s @ %s : %s @ %s : %s'% \
|
log.debug(u'results = %s @ %s : %s @ %s : %s'% \
|
||||||
(unicode(book), unicode(start_chapter), unicode(end_chapter),
|
(unicode(book), unicode(start_chapter), unicode(end_chapter),
|
||||||
unicode(start_verse), unicode(end_verse)))
|
unicode(start_verse), unicode(end_verse)))
|
||||||
if message == None:
|
if message is None:
|
||||||
self.search_results = None
|
self.search_results = None
|
||||||
self.search_results = self.parent.biblemanager.get_verse_text(
|
self.search_results = self.parent.biblemanager.get_verse_text(
|
||||||
bible, book, int(start_chapter), int(end_chapter),
|
bible, book, int(start_chapter), int(end_chapter),
|
||||||
|
@ -17,7 +17,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os, os.path
|
import os
|
||||||
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from openlp.plugins.bibles.lib.biblemanager import BibleManager
|
from openlp.plugins.bibles.lib.biblemanager import BibleManager
|
||||||
|
@ -17,7 +17,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os, os.path
|
import os
|
||||||
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from openlp.plugins.biblemanager.bibleManager import BibleManager
|
from openlp.plugins.biblemanager.bibleManager import BibleManager
|
||||||
|
@ -17,7 +17,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os, os.path
|
import os
|
||||||
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from openlp.plugins.bibles.lib.biblemanager import BibleManager
|
from openlp.plugins.bibles.lib.biblemanager import BibleManager
|
||||||
|
@ -17,7 +17,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os, os.path
|
import os
|
||||||
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from openlp.plugins.bibles.lib.biblemanager import BibleManager
|
from openlp.plugins.bibles.lib.biblemanager import BibleManager
|
||||||
|
@ -112,7 +112,7 @@ class ImpressController(object):
|
|||||||
context = uno.getComponentContext()
|
context = uno.getComponentContext()
|
||||||
resolver = context.ServiceManager.createInstanceWithContext(
|
resolver = context.ServiceManager.createInstanceWithContext(
|
||||||
u'com.sun.star.bridge.UnoUrlResolver', context)
|
u'com.sun.star.bridge.UnoUrlResolver', context)
|
||||||
while ctx == None and loop < 3:
|
while ctx is None and loop < 3:
|
||||||
try:
|
try:
|
||||||
ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext')
|
ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext')
|
||||||
except:
|
except:
|
||||||
|
@ -47,9 +47,9 @@ class PowerPointApp(object):
|
|||||||
self._app.WindowState = 2
|
self._app.WindowState = 2
|
||||||
|
|
||||||
def getApp(self):
|
def getApp(self):
|
||||||
if self._app == None:
|
if self._app is None:
|
||||||
self.createApp()
|
self.createApp()
|
||||||
if self._app == None:
|
if self._app is None:
|
||||||
return None
|
return None
|
||||||
if self._app.Windows.Count == 0:
|
if self._app.Windows.Count == 0:
|
||||||
self.createApp()
|
self.createApp()
|
||||||
@ -69,17 +69,17 @@ class PowerPointPres(object):
|
|||||||
self.open()
|
self.open()
|
||||||
|
|
||||||
def getPres(self):
|
def getPres(self):
|
||||||
if self._pres == None:
|
if self._pres is None:
|
||||||
for p in self.pptApp.app.Presentations:
|
for p in self.pptApp.app.Presentations:
|
||||||
if p.FullName == self.filename:
|
if p.FullName == self.filename:
|
||||||
self._pres = p
|
self._pres = p
|
||||||
break
|
break
|
||||||
if self._pres != None:
|
if self._pres is not None:
|
||||||
try:
|
try:
|
||||||
x = self._pres.Name
|
x = self._pres.Name
|
||||||
except:
|
except:
|
||||||
self._pres = None
|
self._pres = None
|
||||||
if self._pres == None:
|
if self._pres is None:
|
||||||
self.openPres()
|
self.openPres()
|
||||||
return self._pres
|
return self._pres
|
||||||
|
|
||||||
@ -94,9 +94,9 @@ class PowerPointPres(object):
|
|||||||
self._pres = None
|
self._pres = None
|
||||||
|
|
||||||
def isActive(self):
|
def isActive(self):
|
||||||
if self.pres.SlideShowWindow == None:
|
if self.pres.SlideShowWindow is None:
|
||||||
return False
|
return False
|
||||||
if self.pres.SlideShowWindow.View == None:
|
if self.pres.SlideShowWindow.View is None:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ class PowerPointSlide(object):
|
|||||||
self.slide = pres.Slides[index]
|
self.slide = pres.Slides[index]
|
||||||
|
|
||||||
def preview(self):
|
def preview(self):
|
||||||
if self.preview == None:
|
if self.preview is None:
|
||||||
self.slide.Copy
|
self.slide.Copy
|
||||||
# import win32clipboard as w
|
# import win32clipboard as w
|
||||||
# import win32con
|
# import win32con
|
||||||
@ -165,4 +165,3 @@ class PowerPointSlide(object):
|
|||||||
# self.preview = w.GetClipboardData.GetData(win32con.CF_BITMAP)
|
# self.preview = w.GetClipboardData.GetData(win32con.CF_BITMAP)
|
||||||
# w.CloseClipboard()
|
# w.CloseClipboard()
|
||||||
return self.preview
|
return self.preview
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ class SongManager():
|
|||||||
self.session.add(book)
|
self.session.add(book)
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
return True
|
return True
|
||||||
except Exception, e:
|
except:
|
||||||
self.session.rollback()
|
self.session.rollback()
|
||||||
log.exception(u'Could not save book to song database')
|
log.exception(u'Could not save book to song database')
|
||||||
return False
|
return False
|
||||||
|
@ -270,7 +270,7 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
self.ListView.takeItem(row)
|
self.ListView.takeItem(row)
|
||||||
|
|
||||||
def generateSlideData(self, service_item):
|
def generateSlideData(self, service_item):
|
||||||
raw_slides =[]
|
#raw_slides =[]
|
||||||
raw_footer = []
|
raw_footer = []
|
||||||
author_list = u''
|
author_list = u''
|
||||||
author_audit = []
|
author_audit = []
|
||||||
@ -297,7 +297,7 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
author_list = author_list + u', '
|
author_list = author_list + u', '
|
||||||
author_list = author_list + unicode(author.display_name)
|
author_list = author_list + unicode(author.display_name)
|
||||||
author_audit.append(unicode(author.display_name))
|
author_audit.append(unicode(author.display_name))
|
||||||
if song.ccli_number == None or len(song.ccli_number) == 0:
|
if song.ccli_number is None or len(song.ccli_number) == 0:
|
||||||
ccl = self.parent.settings.GeneralTab.CCLNumber
|
ccl = self.parent.settings.GeneralTab.CCLNumber
|
||||||
else:
|
else:
|
||||||
ccl = unicode(song.ccli_number)
|
ccl = unicode(song.ccli_number)
|
||||||
|
@ -24,7 +24,8 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from types import StringType, ListType, NoneType
|
|
||||||
|
from types import StringType, ListType
|
||||||
|
|
||||||
sys.path.append(os.path.abspath(u'./../../../..'))
|
sys.path.append(os.path.abspath(u'./../../../..'))
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ class _OpenSong(XmlRootClass):
|
|||||||
def from_buffer(self, xmlContent):
|
def from_buffer(self, xmlContent):
|
||||||
"""Initialize from buffer(string) with xml content"""
|
"""Initialize from buffer(string) with xml content"""
|
||||||
self._reset()
|
self._reset()
|
||||||
if xmlContent != None :
|
if xmlContent is not None:
|
||||||
self._setFromXml(xmlContent, 'song')
|
self._setFromXml(xmlContent, 'song')
|
||||||
|
|
||||||
def get_author_list(self):
|
def get_author_list(self):
|
||||||
@ -94,9 +95,9 @@ class _OpenSong(XmlRootClass):
|
|||||||
return as a string
|
return as a string
|
||||||
"""
|
"""
|
||||||
res = []
|
res = []
|
||||||
if self.author != None :
|
if self.author is not None:
|
||||||
lst = self.author.split(u' and ')
|
lst = self.author.split(u' and ')
|
||||||
for l in lst :
|
for l in lst:
|
||||||
res.append(l.strip())
|
res.append(l.strip())
|
||||||
s = u', '.join(res)
|
s = u', '.join(res)
|
||||||
return s
|
return s
|
||||||
@ -107,9 +108,9 @@ class _OpenSong(XmlRootClass):
|
|||||||
return as a string
|
return as a string
|
||||||
"""
|
"""
|
||||||
res = []
|
res = []
|
||||||
if self.theme != None :
|
if self.theme is not None:
|
||||||
res.append(self.theme)
|
res.append(self.theme)
|
||||||
if self.alttheme != None :
|
if self.alttheme is not None:
|
||||||
res.append(self.alttheme)
|
res.append(self.alttheme)
|
||||||
s = u', u'.join(res)
|
s = u', u'.join(res)
|
||||||
return s
|
return s
|
||||||
@ -123,25 +124,25 @@ class _OpenSong(XmlRootClass):
|
|||||||
res = []
|
res = []
|
||||||
for c in '1234567890 ':
|
for c in '1234567890 ':
|
||||||
tagPending = True
|
tagPending = True
|
||||||
for l in tmpVerse :
|
for l in tmpVerse:
|
||||||
if l.startswith(c) :
|
if l.startswith(c):
|
||||||
if tagPending :
|
if tagPending:
|
||||||
tagPending = False
|
tagPending = False
|
||||||
t = tag.strip(u'[]').lower()
|
t = tag.strip(u'[]').lower()
|
||||||
if 'v' == t :
|
if 'v' == t:
|
||||||
newtag = "Verse"
|
newtag = "Verse"
|
||||||
elif 'c' == t :
|
elif 'c' == t:
|
||||||
newtag = "Chorus"
|
newtag = "Chorus"
|
||||||
elif 'b' == t :
|
elif 'b' == t:
|
||||||
newtag = "Bridge"
|
newtag = "Bridge"
|
||||||
elif 'p' == t :
|
elif 'p' == t:
|
||||||
newtag = "Pre-chorus"
|
newtag = "Pre-chorus"
|
||||||
else :
|
else:
|
||||||
newtag = t
|
newtag = t
|
||||||
s = (u'# %s %s'%(newtag, c)).rstrip()
|
s = (u'# %s %s'%(newtag, c)).rstrip()
|
||||||
res.append(s)
|
res.append(s)
|
||||||
res.append(l[1:])
|
res.append(l[1:])
|
||||||
if (len(l) == 0) and (not tagPending) :
|
if (len(l) == 0) and (not tagPending):
|
||||||
res.append(l)
|
res.append(l)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@ -156,13 +157,13 @@ class _OpenSong(XmlRootClass):
|
|||||||
tag = ""
|
tag = ""
|
||||||
for l in lyrics:
|
for l in lyrics:
|
||||||
line = l.rstrip()
|
line = l.rstrip()
|
||||||
if not line.startswith(u'.') :
|
if not line.startswith(u'.'):
|
||||||
# drop all chords
|
# drop all chords
|
||||||
tmpVerse.append(line)
|
tmpVerse.append(line)
|
||||||
if len(line) > 0 :
|
if len(line) > 0:
|
||||||
if line.startswith(u'['):
|
if line.startswith(u'['):
|
||||||
tag = line
|
tag = line
|
||||||
else :
|
else:
|
||||||
r = self._reorder_verse(tag, tmpVerse)
|
r = self._reorder_verse(tag, tmpVerse)
|
||||||
finalLyrics.extend(r)
|
finalLyrics.extend(r)
|
||||||
tag = ""
|
tag = ""
|
||||||
@ -173,12 +174,12 @@ class _OpenSong(XmlRootClass):
|
|||||||
return finalLyrics
|
return finalLyrics
|
||||||
|
|
||||||
|
|
||||||
class Song(object) :
|
class Song(object):
|
||||||
"""Handling song properties and methods
|
"""Handling song properties and methods
|
||||||
|
|
||||||
handles all conversions between various input and output formats
|
handles all conversions between various input and output formats
|
||||||
|
|
||||||
CCLI :
|
CCLI:
|
||||||
from_ccli_text_file
|
from_ccli_text_file
|
||||||
to_ccli_text_file
|
to_ccli_text_file
|
||||||
from_ccli_text_buffer
|
from_ccli_text_buffer
|
||||||
@ -195,13 +196,13 @@ class Song(object) :
|
|||||||
get_preview_slide
|
get_preview_slide
|
||||||
get_render_slide
|
get_render_slide
|
||||||
|
|
||||||
openlp1 :
|
openlp1:
|
||||||
from_openlp1_lyrics_buffer
|
from_openlp1_lyrics_buffer
|
||||||
to_openlp1_lyrics_buffer
|
to_openlp1_lyrics_buffer
|
||||||
set_author_list
|
set_author_list
|
||||||
get_author_list
|
get_author_list
|
||||||
|
|
||||||
editing and openlp2 :
|
editing and openlp2:
|
||||||
set_*
|
set_*
|
||||||
get_*
|
get_*
|
||||||
"""
|
"""
|
||||||
@ -263,13 +264,13 @@ class Song(object) :
|
|||||||
"""Initialize from buffer(string) of xml lines in opensong format"""
|
"""Initialize from buffer(string) of xml lines in opensong format"""
|
||||||
self._reset()
|
self._reset()
|
||||||
opensong = _OpenSong(xmlcontent)
|
opensong = _OpenSong(xmlcontent)
|
||||||
if opensong.title != None:
|
if opensong.title is not None:
|
||||||
self.set_title(opensong.title)
|
self.set_title(opensong.title)
|
||||||
if opensong.copyright != None :
|
if opensong.copyright is not None:
|
||||||
self.set_copyright(opensong.copyright)
|
self.set_copyright(opensong.copyright)
|
||||||
if opensong.presentation != None:
|
if opensong.presentation is not None:
|
||||||
self.set_verse_order(opensong.presentation)
|
self.set_verse_order(opensong.presentation)
|
||||||
if opensong.ccli != None:
|
if opensong.ccli is not None:
|
||||||
self.set_song_cclino(opensong.ccli)
|
self.set_song_cclino(opensong.ccli)
|
||||||
self.set_author_list(opensong.get_author_list())
|
self.set_author_list(opensong.get_author_list())
|
||||||
self.set_category_array(opensong.get_category_array())
|
self.set_category_array(opensong.get_category_array())
|
||||||
@ -282,7 +283,7 @@ class Song(object) :
|
|||||||
"""
|
"""
|
||||||
lst = []
|
lst = []
|
||||||
f = open(xmlfilename, 'r')
|
f = open(xmlfilename, 'r')
|
||||||
for line in f :
|
for line in f:
|
||||||
lst.append(line)
|
lst.append(line)
|
||||||
f.close()
|
f.close()
|
||||||
xml = "".join(lst)
|
xml = "".join(lst)
|
||||||
@ -295,7 +296,7 @@ class Song(object) :
|
|||||||
"""
|
"""
|
||||||
punctuation = ".,:;!?&%#'\"/\\@`$|^~*-"
|
punctuation = ".,:;!?&%#'\"/\\@`$|^~*-"
|
||||||
s = title
|
s = title
|
||||||
for c in punctuation :
|
for c in punctuation:
|
||||||
s = s.replace(c, '')
|
s = s.replace(c, '')
|
||||||
return s
|
return s
|
||||||
|
|
||||||
@ -308,9 +309,9 @@ class Song(object) :
|
|||||||
"""
|
"""
|
||||||
self.title = title.strip()
|
self.title = title.strip()
|
||||||
self.search_title = self._remove_punctuation(title).strip()
|
self.search_title = self._remove_punctuation(title).strip()
|
||||||
if len(self.title) < 1 :
|
if len(self.title) < 1:
|
||||||
raise SongTitleError(u'The title is empty')
|
raise SongTitleError(u'The title is empty')
|
||||||
if len(self.search_title) < 1 :
|
if len(self.search_title) < 1:
|
||||||
raise SongTitleError(u'The searchable title is empty')
|
raise SongTitleError(u'The searchable title is empty')
|
||||||
|
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
@ -340,32 +341,32 @@ class Song(object) :
|
|||||||
n = 0
|
n = 0
|
||||||
metMisc = False
|
metMisc = False
|
||||||
lyrics = []
|
lyrics = []
|
||||||
for l in textList :
|
for l in textList:
|
||||||
n += 1
|
n += 1
|
||||||
if lastpart > 0 :
|
if lastpart > 0:
|
||||||
lastpart += 1
|
lastpart += 1
|
||||||
if lastpart == 2 :
|
if lastpart == 2:
|
||||||
sCopyright = l[1:].strip()
|
sCopyright = l[1:].strip()
|
||||||
if lastpart == 3 :
|
if lastpart == 3:
|
||||||
sAuthor = l
|
sAuthor = l
|
||||||
elif l.startswith(u'CCLI Song') :
|
elif l.startswith(u'CCLI Song'):
|
||||||
sCcli = l[13:].strip()
|
sCcli = l[13:].strip()
|
||||||
lastpart = 1
|
lastpart = 1
|
||||||
else :
|
else:
|
||||||
if metMisc :
|
if metMisc:
|
||||||
metMisc = False
|
metMisc = False
|
||||||
if l.upper().startswith(u'(BRIDGE)') :
|
if l.upper().startswith(u'(BRIDGE)'):
|
||||||
lyrics.append(u'# Bridge')
|
lyrics.append(u'# Bridge')
|
||||||
# otherwise unknown misc keyword
|
# otherwise unknown misc keyword
|
||||||
elif l.startswith(u'Misc') :
|
elif l.startswith(u'Misc'):
|
||||||
metMisc = True
|
metMisc = True
|
||||||
elif l.startswith(u'Verse') or l.startswith(u'Chorus'):
|
elif l.startswith(u'Verse') or l.startswith(u'Chorus'):
|
||||||
lyrics.append(u'# %s'%l)
|
lyrics.append(u'# %s'%l)
|
||||||
else :
|
else:
|
||||||
# should we remove multiple blank lines?
|
# should we remove multiple blank lines?
|
||||||
if n == 1 :
|
if n == 1:
|
||||||
sName = l
|
sName = l
|
||||||
else :
|
else:
|
||||||
lyrics.append(l)
|
lyrics.append(l)
|
||||||
# split on known separators
|
# split on known separators
|
||||||
lst = sAuthor.split(u'/')
|
lst = sAuthor.split(u'/')
|
||||||
@ -390,33 +391,33 @@ class Song(object) :
|
|||||||
f.close()
|
f.close()
|
||||||
self.from_ccli_text_buffer(lines)
|
self.from_ccli_text_buffer(lines)
|
||||||
|
|
||||||
def _assure_string(self, s):
|
def _assure_string(self, string_in):
|
||||||
"""Force a string is returned"""
|
"""Force a string is returned"""
|
||||||
if s == None :
|
if string_in is None:
|
||||||
r = ""
|
string_out = ""
|
||||||
else :
|
else:
|
||||||
r = unicode(s)
|
string_out = unicode(s)
|
||||||
return r
|
return string_out
|
||||||
|
|
||||||
def _split_to_list(self, aString):
|
def _split_to_list(self, aString):
|
||||||
"""Split a string into a list - comma separated"""
|
"""Split a string into a list - comma separated"""
|
||||||
res = []
|
res = []
|
||||||
if aString != None :
|
if aString is not None:
|
||||||
lst = aString.split(u',')
|
lst = aString.split(u',')
|
||||||
for l in lst :
|
for l in lst:
|
||||||
# remove whitespace
|
# remove whitespace
|
||||||
res.append(l.strip())
|
res.append(l.strip())
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _list_to_string(self, strOrList):
|
def _list_to_string(self, strOrList):
|
||||||
"""Force a possibly list into a string"""
|
"""Force a possibly list into a string"""
|
||||||
if type(strOrList) == StringType :
|
if type(strOrList) == StringType:
|
||||||
lst = self._split_to_list(strOrList)
|
lst = self._split_to_list(strOrList)
|
||||||
elif type(strOrList) == ListType :
|
elif type(strOrList) == ListType:
|
||||||
lst = strOrList
|
lst = strOrList
|
||||||
elif type(strOrList) == NoneType :
|
elif strOrList is None:
|
||||||
lst = []
|
lst = []
|
||||||
else :
|
else:
|
||||||
raise SongTypeError(u'Variable not String or List')
|
raise SongTypeError(u'Variable not String or List')
|
||||||
s = u', '.join(lst)
|
s = u', '.join(lst)
|
||||||
return s
|
return s
|
||||||
@ -486,9 +487,9 @@ class Song(object) :
|
|||||||
False -- list of strings
|
False -- list of strings
|
||||||
["John Newton", u'A Parker"]
|
["John Newton", u'A Parker"]
|
||||||
"""
|
"""
|
||||||
if asOneString :
|
if asOneString:
|
||||||
res = self._assure_string(self.author_list)
|
res = self._assure_string(self.author_list)
|
||||||
else :
|
else:
|
||||||
res = self._split_to_list(self.author_list)
|
res = self._split_to_list(self.author_list)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@ -497,9 +498,9 @@ class Song(object) :
|
|||||||
|
|
||||||
author_list -- a string or list of strings
|
author_list -- a string or list of strings
|
||||||
"""
|
"""
|
||||||
if author_list == None :
|
if author_list is None:
|
||||||
self.author_list = None
|
self.author_list = None
|
||||||
else :
|
else:
|
||||||
self.author_list = self._list_to_string(author_list)
|
self.author_list = self._list_to_string(author_list)
|
||||||
|
|
||||||
def get_category_array(self, asOneString = True):
|
def get_category_array(self, asOneString = True):
|
||||||
@ -511,9 +512,9 @@ class Song(object) :
|
|||||||
False -- list of strings
|
False -- list of strings
|
||||||
["Hymn", u'Gospel"]
|
["Hymn", u'Gospel"]
|
||||||
"""
|
"""
|
||||||
if asOneString :
|
if asOneString:
|
||||||
res = self._assure_string(self.category_array)
|
res = self._assure_string(self.category_array)
|
||||||
else :
|
else:
|
||||||
res = self._split_to_list(self.category_array)
|
res = self._split_to_list(self.category_array)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@ -522,9 +523,9 @@ class Song(object) :
|
|||||||
|
|
||||||
category_array -- a string or list of strings
|
category_array -- a string or list of strings
|
||||||
"""
|
"""
|
||||||
if category_array == None :
|
if category_array is None:
|
||||||
self.category_array = None
|
self.category_array = None
|
||||||
else :
|
else:
|
||||||
self.category_array = self._list_to_string(category_array)
|
self.category_array = self._list_to_string(category_array)
|
||||||
|
|
||||||
def get_show_title(self):
|
def get_show_title(self):
|
||||||
@ -577,12 +578,12 @@ class Song(object) :
|
|||||||
self.slideList = []
|
self.slideList = []
|
||||||
tmpSlide = []
|
tmpSlide = []
|
||||||
metContent = False
|
metContent = False
|
||||||
for l in self.lyrics :
|
for l in self.lyrics:
|
||||||
if len(l) > 0 :
|
if len(l) > 0:
|
||||||
metContent = True
|
metContent = True
|
||||||
tmpSlide.append(l)
|
tmpSlide.append(l)
|
||||||
else :
|
else:
|
||||||
if metContent :
|
if metContent:
|
||||||
metContent = False
|
metContent = False
|
||||||
self.slideList.append(tmpSlide)
|
self.slideList.append(tmpSlide)
|
||||||
tmpSlide = []
|
tmpSlide = []
|
||||||
@ -598,22 +599,22 @@ class Song(object) :
|
|||||||
def get_preview_slide(self, slideNumber):
|
def get_preview_slide(self, slideNumber):
|
||||||
"""Return the preview text for specified slide number
|
"""Return the preview text for specified slide number
|
||||||
|
|
||||||
slideNumber -- 0: all slides, 1..n : specific slide
|
slideNumber -- 0: all slides, 1..n: specific slide
|
||||||
a list of strings are returned
|
a list of strings are returned
|
||||||
"""
|
"""
|
||||||
num = len(self.slideList)
|
num = len(self.slideList)
|
||||||
if num < 1 :
|
if num < 1:
|
||||||
raise SongSlideError(u'No slides in this song')
|
raise SongSlideError(u'No slides in this song')
|
||||||
elif slideNumber > num :
|
elif slideNumber > num:
|
||||||
raise SongSlideError(u'Slide number too high')
|
raise SongSlideError(u'Slide number too high')
|
||||||
if slideNumber > 0 :
|
if slideNumber > 0:
|
||||||
# return this slide
|
# return this slide
|
||||||
res = self.slideList[slideNumber-1]
|
res = self.slideList[slideNumber-1]
|
||||||
# find theme in this slide
|
# find theme in this slide
|
||||||
else :
|
else:
|
||||||
res = []
|
res = []
|
||||||
for i in range(num):
|
for i in range(num):
|
||||||
if i > 0 :
|
if i > 0:
|
||||||
res.append(u'')
|
res.append(u'')
|
||||||
res.extend()
|
res.extend()
|
||||||
# remove formattingincluding themes
|
# remove formattingincluding themes
|
||||||
@ -633,26 +634,26 @@ class Song(object) :
|
|||||||
lyric-part as a list of strings]
|
lyric-part as a list of strings]
|
||||||
"""
|
"""
|
||||||
num = len(self.slideList)
|
num = len(self.slideList)
|
||||||
if num < 1 :
|
if num < 1:
|
||||||
raise SongSlideError(u'No slides in this song')
|
raise SongSlideError(u'No slides in this song')
|
||||||
elif slideNumber > num :
|
elif slideNumber > num:
|
||||||
raise SongSlideError(u'Slide number too high')
|
raise SongSlideError(u'Slide number too high')
|
||||||
res = []
|
res = []
|
||||||
if self.show_title :
|
if self.show_title:
|
||||||
title = self.get_title()
|
title = self.get_title()
|
||||||
else :
|
else:
|
||||||
title = ""
|
title = ""
|
||||||
if self.show_author_list :
|
if self.show_author_list:
|
||||||
author = self.get_author_list(True)
|
author = self.get_author_list(True)
|
||||||
else :
|
else:
|
||||||
author = ""
|
author = ""
|
||||||
if self.show_copyright :
|
if self.show_copyright:
|
||||||
cpright = self.get_copyright()
|
cpright = self.get_copyright()
|
||||||
else :
|
else:
|
||||||
cpright = ""
|
cpright = ""
|
||||||
if self.show_song_cclino :
|
if self.show_song_cclino:
|
||||||
ccli = self.get_song_cclino()
|
ccli = self.get_song_cclino()
|
||||||
else :
|
else:
|
||||||
ccli = ""
|
ccli = ""
|
||||||
theme = self.get_theme()
|
theme = self.get_theme()
|
||||||
# examine the slide for a theme
|
# examine the slide for a theme
|
||||||
|
Loading…
Reference in New Issue
Block a user