* fix: __str__ name
This commit is contained in:
+5
-3
@@ -76,14 +76,15 @@ Float = types.FloatType
|
|||||||
class LocalText(dict):
|
class LocalText(dict):
|
||||||
"""Handles XML tags with localized text"""
|
"""Handles XML tags with localized text"""
|
||||||
|
|
||||||
def __init__(self, tag, spec):
|
def __init__(self, tag = "", req = optional):
|
||||||
self.tag = tag
|
self.tag = tag
|
||||||
self.req = spec[1]
|
self.req = req
|
||||||
dict.__init__(self)
|
dict.__init__(self)
|
||||||
#self.locs = {}
|
#self.locs = {}
|
||||||
|
|
||||||
def decode(self, node, errs, where = ""):
|
def decode(self, node, errs, where = ""):
|
||||||
# flags, tag name, instance attribute
|
# flags, tag name, instance attribute
|
||||||
|
assert self.tag != ''
|
||||||
nodes = getAllNodes(node, self.tag)
|
nodes = getAllNodes(node, self.tag)
|
||||||
if not nodes:
|
if not nodes:
|
||||||
if self.req == mandatory:
|
if self.req == mandatory:
|
||||||
@@ -102,6 +103,7 @@ class LocalText(dict):
|
|||||||
self[lang] = c
|
self[lang] = c
|
||||||
|
|
||||||
def encode(self, xml, node, errs):
|
def encode(self, xml, node, errs):
|
||||||
|
assert self.tag != ''
|
||||||
for key in self.iterkeys():
|
for key in self.iterkeys():
|
||||||
newnode = newNode(node, self.tag)
|
newnode = newNode(node, self.tag)
|
||||||
newnode.setAttribute('xml:lang', key)
|
newnode.setAttribute('xml:lang', key)
|
||||||
@@ -139,7 +141,7 @@ class LocalText(dict):
|
|||||||
for x in errs:
|
for x in errs:
|
||||||
ctx.ui.warning(x)
|
ctx.ui.warning(x)
|
||||||
|
|
||||||
def str(self):
|
def __str__(self):
|
||||||
strfile = StringIO()
|
strfile = StringIO()
|
||||||
self.print_text(strfile)
|
self.print_text(strfile)
|
||||||
str = strfile.getvalue()
|
str = strfile.getvalue()
|
||||||
|
|||||||
@@ -91,10 +91,11 @@ class LocalTextTestCase(unittest.TestCase):
|
|||||||
a = xmlfile.LocalText()
|
a = xmlfile.LocalText()
|
||||||
a['tr'] = u'Zibidi'
|
a['tr'] = u'Zibidi'
|
||||||
a['en'] = u'ingiliz hiyarlari ne anlar zibididen'
|
a['en'] = u'ingiliz hiyarlari ne anlar zibididen'
|
||||||
|
self.a = a
|
||||||
|
|
||||||
def testStr(self):
|
def testStr(self):
|
||||||
s = str(a)
|
s = str(self.a)
|
||||||
self.assert_(a != None and len(a)>=6)
|
self.assert_(s!= None and len(s)>=6)
|
||||||
|
|
||||||
suite1 = unittest.makeSuite(AutoXmlTestCase)
|
suite1 = unittest.makeSuite(AutoXmlTestCase)
|
||||||
suite2 = unittest.makeSuite(LocalTextTestCase)
|
suite2 = unittest.makeSuite(LocalTextTestCase)
|
||||||
|
|||||||
Reference in New Issue
Block a user