Added import of types. Added UnicodeType in xml decoding

Solved problem with danish song

bzr-revno: 80
This commit is contained in:
Carsten Tinggaard 2008-11-05 19:35:24 +00:00
parent e28b1f3441
commit da4060711a
2 changed files with 7 additions and 4 deletions

View File

@ -19,6 +19,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
import platform import platform
import sys import sys
import os import os
from types import StringType, NoneType, UnicodeType
sys.path.append(os.path.abspath("./../..")) sys.path.append(os.path.abspath("./../.."))
ver = platform.python_version() ver = platform.python_version()
@ -50,9 +51,11 @@ class XmlRootClass(object):
if element.tag != rootTag: if element.tag != rootTag:
t=element.text t=element.text
#print element.tag, t, type(t) #print element.tag, t, type(t)
if type(t) == type(None): # easy! if type(t) == NoneType: # easy!
val=t val=t
if type(t) == type(" "): # strings need special handling to sort the colours out elif type(t) == UnicodeType :
val=t
elif type(t) == StringType: # strings need special handling to sort the colours out
#print "str", #print "str",
if t[0] == "$": # might be a hex number if t[0] == "$": # might be a hex number
#print "hex", #print "hex",

View File

@ -122,7 +122,7 @@ class Test_OpenSong(object):
assert(s.GetVerseOrder() == "V1 C V2 C V3 C V4 C") assert(s.GetVerseOrder() == "V1 C V2 C V3 C V4 C")
assert(s.GetNumberOfSlides() == 5) assert(s.GetNumberOfSlides() == 5)
def atest_file3(self): def test_file3(self):
"""OpenSong: parse 'På en fjern ensom høj' (danish)""" """OpenSong: parse 'På en fjern ensom høj' (danish)"""
#FIXME: problem with XML convert and danish characters #FIXME: problem with XML convert and danish characters
s = Song() s = Song()
@ -137,5 +137,5 @@ class Test_OpenSong(object):
if '__main__' == __name__: if '__main__' == __name__:
r = Test_OpenSong() r = Test_OpenSong()
r.atest_file3() r.test_file3()