X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fsp%2Fcons.py;h=1e3d678c0cec11e87599fb3677ee9111fb8445d9;hb=50be6d543e7a6067b631930a025bfdaf53fedbc4;hp=ce258c65325b3318c6b66b636f1ca35f05586403;hpb=9bc70dab473c7057a20d182ce8566ad0a70a7c5d;p=wrw.git diff --git a/wrw/sp/cons.py b/wrw/sp/cons.py index ce258c6..1e3d678 100644 --- a/wrw/sp/cons.py +++ b/wrw/sp/cons.py @@ -1,3 +1,4 @@ +import sys import xml.dom.minidom class node(object): @@ -39,9 +40,11 @@ class element(node): return self.__todom__(doc).toxml() class context(object): + charset = (sys.getfilesystemencoding() or "ascii") + def __init__(self): self.nodeconv = {} - self.nodeconv[str] = lambda ob: text(ob, "utf-8") + self.nodeconv[str] = lambda ob: text(ob, self.charset) self.nodeconv[unicode] = text self.nodeconv[int] = text self.nodeconv[long] = text @@ -60,7 +63,8 @@ class context(object): node.children.append(self.nodefrom(child)) def addattr(self, node, k, v): - node.attrs[unicode(k)] = unicode(v) + if v is not None: + node.attrs[unicode(k)] = unicode(v) class constructor(object): def __init__(self, ns, elcls=element, ctx=None):