X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fsp%2Fcons.py;h=bc9bfa2b23188831a2c3157de1683e5ff7ee8551;hb=fb5f9f27dcabe7fac75e3a69f820c42779539239;hp=4052dce03344e06ee3c00c31b255461f0664cd4e;hpb=4c4dcf7a020ed52ea9d8d9048dbd62ffa3a7d54d;p=wrw.git diff --git a/wrw/sp/cons.py b/wrw/sp/cons.py index 4052dce..bc9bfa2 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 @@ -57,6 +60,8 @@ class context(object): raise Exception("No node conversion known for %s objects" % str(type(ob))) def addchild(self, node, child): + if child is None: + return node.children.append(self.nodefrom(child)) def addattr(self, node, k, v): @@ -72,3 +77,9 @@ class constructor(object): def __getattr__(self, name): return self._elcls(self._ns, name, self._ctx) + +class doctype(node): + def __init__(self, rootname, pubid, dtdid): + self.rootname = rootname + self.pubid = pubid + self.dtdid = dtdid