From 5f6740f5d1e05854bd72941386f6ff36b5e78bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Sun, 7 May 2006 20:29:06 +0000 Subject: [PATCH] * implement piksemel, mofo, also really fix 751 --- pisi/pxml/autoxml.py | 7 +++---- pisi/pxml/xmlext.py | 3 --- pisi/pxml/xmlextpiks.py | 15 +++++++++++++-- pisi/pxml/xmlfile.py | 5 +---- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/pisi/pxml/autoxml.py b/pisi/pxml/autoxml.py index 883ced68..555dd754 100644 --- a/pisi/pxml/autoxml.py +++ b/pisi/pxml/autoxml.py @@ -475,7 +475,7 @@ class autoxml(oo.autosuper, oo.autoprop): return getNodeAttribute(node, attr) def writetext(node, attr, text): #print 'write attr', attr, text - node.setAttributeNS(XML_NS, attr, text) + setNodeAttribute(node, attr, text) anonfuns = cls.gen_anon_basic(attr, spec, readtext, writetext) return cls.gen_named_comp(attr, spec, anonfuns) @@ -692,7 +692,7 @@ class autoxml(oo.autosuper, oo.autoprop): #FIXME: this doesn't look pretty classnode = newNode(node, tag) obj.encode(classnode, errs) - node.appendChild(classnode) + addNode(node, '', classnode) except Error: if req == mandatory: # note: we can receive an error if obj has no content @@ -738,14 +738,13 @@ class autoxml(oo.autosuper, oo.autoprop): ix = 1 for node in nodes: dummy = newNode(node, "Dummy") - dummy.appendChild(node) + addNode(dummy, '', node) l.append(decode_item(dummy, errs, where + unicode("[%s]" % ix))) #l.append(decode_item(node, errs, where + unicode("[%s]" % ix))) ix += 1 return l def encode(node, l, errs): - dom = node.ownerDocument if l and len(l) > 0: for item in l: if list_tagpath: diff --git a/pisi/pxml/xmlext.py b/pisi/pxml/xmlext.py index 0497cb0d..02fe77ac 100644 --- a/pisi/pxml/xmlext.py +++ b/pisi/pxml/xmlext.py @@ -12,14 +12,11 @@ # Authors: Eray Ozkural try: - zimbabwe # comment out to disable piks from xmlextpiks import * except: try: #if pisi.context.use_mdom: # gibidi - #else: - from xmlextcdom import * except: #raise Error('cannot find 4suite implementation') diff --git a/pisi/pxml/xmlextpiks.py b/pisi/pxml/xmlextpiks.py index 105c30a3..9189f40d 100644 --- a/pisi/pxml/xmlextpiks.py +++ b/pisi/pxml/xmlextpiks.py @@ -52,6 +52,10 @@ def getNodeAttribute(node, attrname): """get named attribute from DOM node""" return node.getAttribute(attrname) +def setNodeAttribute(node, attrname, value): + """get named attribute from DOM node""" + return node.setAttribute(attrname, value) + def getChildElts(parent): """get only child elements""" return [x for x in parent.tags()] @@ -84,6 +88,9 @@ def getChildText(node_s, tagpath): def getNode(node, tagpath): """returns the *first* matching node for given tag path.""" + if tagpath == "": + return node + assert type(tagpath)==str tags = tagpath.split('/') assert len(tags)>0 @@ -114,7 +121,7 @@ def addTagPath(node, tags, newnode=None): """add newnode at the end of a tag chain, smart one""" node = createTagPath(node, tags) if newnode: # node to add specified - node.insertData(newnode) + node.insertNode(newnode) return node def addNode(node, tagpath, newnode = None, branch=True): @@ -153,4 +160,8 @@ def addNode(node, tagpath, newnode = None, branch=True): return node def addText(node, tagpath, text): - addNode(node, tagpath, text) + node = addNode(node, tagpath) + node.insertData(text) + +def newNode(node, tag): + return iks.newDocument(tag) diff --git a/pisi/pxml/xmlfile.py b/pisi/pxml/xmlfile.py index 9c9c6eed..50673684 100644 --- a/pisi/pxml/xmlfile.py +++ b/pisi/pxml/xmlfile.py @@ -14,8 +14,7 @@ import pisi.context try: - horagata # comment out to disable piks - #from xmlfilepiks import * + from xmlfilepiks import * except: try: #if pisi.context.use_mdom: @@ -26,5 +25,3 @@ except: #raise Error('cannot find 4suite implementation') print 'xmlext: cDomlette/piksemel implementation cannot be loaded, falling back to minidom' from xmlfilemdom import * - -#print 'gumburdop'