* fix: don't mess up if the attribute is None

This commit is contained in:
Eray Özkural
2006-04-05 14:25:00 +00:00
parent 23aebbf22d
commit b03dffd35a
+6 -5
View File
@@ -123,7 +123,7 @@ class LocalText(dict):
def errors(self, where = unicode()): def errors(self, where = unicode()):
errs = [] errs = []
langs = [ LocalText.get_lang(), 'tr', 'en' ] langs = [ LocalText.get_lang(), 'en', 'tr', ]
if not util.any(lambda x : self.has_key(x), langs): if not util.any(lambda x : self.has_key(x), langs):
errs.append( where + ': ' + _("Tag should have at least the current locale, or failing that an English or Turkish version")) errs.append( where + ': ' + _("Tag should have at least the current locale, or failing that an English or Turkish version"))
#FIXME: check if all entries are unicode #FIXME: check if all entries are unicode
@@ -163,7 +163,7 @@ class LocalText(dict):
# fallback to Turkish # fallback to Turkish
return unicode(self['tr']) return unicode(self['tr'])
else: else:
return '' return unicode()
class Writer(formatter.DumbWriter): class Writer(formatter.DumbWriter):
"""adds unicode support""" """adds unicode support"""
@@ -434,11 +434,11 @@ class autoxml(oo.autosuper, oo.autoprop):
self.readxml(uri, tmpDir, sha1sum=sha1sum, compress=compress, sign=sign) self.readxml(uri, tmpDir, sha1sum=sha1sum, compress=compress, sign=sign)
errs = [] errs = []
self.decode(self.rootNode(), errs) self.decode(self.rootNode(), errs)
if hasattr(self, 'read_hook'):
self.read_hook(errs)
if errs: if errs:
errs.append(_("autoxml.read: File '%s' has errors") % uri) errs.append(_("autoxml.read: File '%s' has errors") % uri)
raise Error(*errs) raise Error(*errs)
if hasattr(self, 'read_hook'):
self.read_hook(errs)
if not keepDoc: if not keepDoc:
self.unlink() # get rid of the tree self.unlink() # get rid of the tree
@@ -552,8 +552,9 @@ class autoxml(oo.autosuper, oo.autoprop):
encode_a(node, value, errs) encode_a(node, value, errs)
def errors(self, where): def errors(self, where):
"""return errors in the object"""
errs = [] errs = []
if hasattr(self, name): if hasattr(self, name) and getattr(self, name) != None:
value = getattr(self,name) value = getattr(self,name)
errs.extend(errors_a(value, where + '.' + name)) errs.extend(errors_a(value, where + '.' + name))
else: else: