* implement piksemel, mofo, also really fix 751
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -12,14 +12,11 @@
|
||||
# Authors: Eray Ozkural <eray@pardus.org.tr>
|
||||
|
||||
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')
|
||||
|
||||
+13
-2
@@ -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)
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user