* 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)
|
return getNodeAttribute(node, attr)
|
||||||
def writetext(node, attr, text):
|
def writetext(node, attr, text):
|
||||||
#print 'write attr', 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)
|
anonfuns = cls.gen_anon_basic(attr, spec, readtext, writetext)
|
||||||
return cls.gen_named_comp(attr, spec, anonfuns)
|
return cls.gen_named_comp(attr, spec, anonfuns)
|
||||||
|
|
||||||
@@ -692,7 +692,7 @@ class autoxml(oo.autosuper, oo.autoprop):
|
|||||||
#FIXME: this doesn't look pretty
|
#FIXME: this doesn't look pretty
|
||||||
classnode = newNode(node, tag)
|
classnode = newNode(node, tag)
|
||||||
obj.encode(classnode, errs)
|
obj.encode(classnode, errs)
|
||||||
node.appendChild(classnode)
|
addNode(node, '', classnode)
|
||||||
except Error:
|
except Error:
|
||||||
if req == mandatory:
|
if req == mandatory:
|
||||||
# note: we can receive an error if obj has no content
|
# note: we can receive an error if obj has no content
|
||||||
@@ -738,14 +738,13 @@ class autoxml(oo.autosuper, oo.autoprop):
|
|||||||
ix = 1
|
ix = 1
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
dummy = newNode(node, "Dummy")
|
dummy = newNode(node, "Dummy")
|
||||||
dummy.appendChild(node)
|
addNode(dummy, '', node)
|
||||||
l.append(decode_item(dummy, errs, where + unicode("[%s]" % ix)))
|
l.append(decode_item(dummy, errs, where + unicode("[%s]" % ix)))
|
||||||
#l.append(decode_item(node, errs, where + unicode("[%s]" % ix)))
|
#l.append(decode_item(node, errs, where + unicode("[%s]" % ix)))
|
||||||
ix += 1
|
ix += 1
|
||||||
return l
|
return l
|
||||||
|
|
||||||
def encode(node, l, errs):
|
def encode(node, l, errs):
|
||||||
dom = node.ownerDocument
|
|
||||||
if l and len(l) > 0:
|
if l and len(l) > 0:
|
||||||
for item in l:
|
for item in l:
|
||||||
if list_tagpath:
|
if list_tagpath:
|
||||||
|
|||||||
@@ -12,14 +12,11 @@
|
|||||||
# Authors: Eray Ozkural <eray@pardus.org.tr>
|
# Authors: Eray Ozkural <eray@pardus.org.tr>
|
||||||
|
|
||||||
try:
|
try:
|
||||||
zimbabwe # comment out to disable piks
|
|
||||||
from xmlextpiks import *
|
from xmlextpiks import *
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
#if pisi.context.use_mdom:
|
#if pisi.context.use_mdom:
|
||||||
# gibidi
|
# gibidi
|
||||||
#else:
|
|
||||||
|
|
||||||
from xmlextcdom import *
|
from xmlextcdom import *
|
||||||
except:
|
except:
|
||||||
#raise Error('cannot find 4suite implementation')
|
#raise Error('cannot find 4suite implementation')
|
||||||
|
|||||||
+13
-2
@@ -52,6 +52,10 @@ def getNodeAttribute(node, attrname):
|
|||||||
"""get named attribute from DOM node"""
|
"""get named attribute from DOM node"""
|
||||||
return node.getAttribute(attrname)
|
return node.getAttribute(attrname)
|
||||||
|
|
||||||
|
def setNodeAttribute(node, attrname, value):
|
||||||
|
"""get named attribute from DOM node"""
|
||||||
|
return node.setAttribute(attrname, value)
|
||||||
|
|
||||||
def getChildElts(parent):
|
def getChildElts(parent):
|
||||||
"""get only child elements"""
|
"""get only child elements"""
|
||||||
return [x for x in parent.tags()]
|
return [x for x in parent.tags()]
|
||||||
@@ -84,6 +88,9 @@ def getChildText(node_s, tagpath):
|
|||||||
def getNode(node, tagpath):
|
def getNode(node, tagpath):
|
||||||
"""returns the *first* matching node for given tag path."""
|
"""returns the *first* matching node for given tag path."""
|
||||||
|
|
||||||
|
if tagpath == "":
|
||||||
|
return node
|
||||||
|
|
||||||
assert type(tagpath)==str
|
assert type(tagpath)==str
|
||||||
tags = tagpath.split('/')
|
tags = tagpath.split('/')
|
||||||
assert len(tags)>0
|
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"""
|
"""add newnode at the end of a tag chain, smart one"""
|
||||||
node = createTagPath(node, tags)
|
node = createTagPath(node, tags)
|
||||||
if newnode: # node to add specified
|
if newnode: # node to add specified
|
||||||
node.insertData(newnode)
|
node.insertNode(newnode)
|
||||||
return node
|
return node
|
||||||
|
|
||||||
def addNode(node, tagpath, newnode = None, branch=True):
|
def addNode(node, tagpath, newnode = None, branch=True):
|
||||||
@@ -153,4 +160,8 @@ def addNode(node, tagpath, newnode = None, branch=True):
|
|||||||
return node
|
return node
|
||||||
|
|
||||||
def addText(node, tagpath, text):
|
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
|
import pisi.context
|
||||||
|
|
||||||
try:
|
try:
|
||||||
horagata # comment out to disable piks
|
from xmlfilepiks import *
|
||||||
#from xmlfilepiks import *
|
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
#if pisi.context.use_mdom:
|
#if pisi.context.use_mdom:
|
||||||
@@ -26,5 +25,3 @@ except:
|
|||||||
#raise Error('cannot find 4suite implementation')
|
#raise Error('cannot find 4suite implementation')
|
||||||
print 'xmlext: cDomlette/piksemel implementation cannot be loaded, falling back to minidom'
|
print 'xmlext: cDomlette/piksemel implementation cannot be loaded, falling back to minidom'
|
||||||
from xmlfilemdom import *
|
from xmlfilemdom import *
|
||||||
|
|
||||||
#print 'gumburdop'
|
|
||||||
|
|||||||
Reference in New Issue
Block a user