core: importParams renamed to updateParams: it now updates the parameter instead of appending children if it find an existing one.

This commit is contained in:
Goffi 2013-10-31 17:14:15 +01:00
commit bd7f2d6e84
7 changed files with 15 additions and 10 deletions

View file

@ -217,7 +217,7 @@ class Params(object):
#the node is new
return None
def importParams(self, xml):
def updateParams(self, xml):
"""import xml in parameters, do nothing if the param already exist
@param xml: parameters in xml form"""
src_dom = minidom.parseString(xml.encode('utf-8'))
@ -230,7 +230,12 @@ class Params(object):
if not node: # The node is new
tgt_parent.appendChild(child)
else:
import_node(node, child)
if child.nodeName == "param":
# The child update an existing parameter, we replace the node
tgt_parent.replaceChild(child, node)
else:
# the node already exists, we recurse 1 more level
import_node(node, child)
import_node(self.dom.documentElement, src_dom.documentElement)
@ -932,8 +937,8 @@ class Memory(object):
def setParam(self, name, value, category, security_limit=NO_SECURITY_LIMIT, profile_key='@NONE@'):
return self.params.setParam(name, value, category, security_limit, profile_key)
def importParams(self, xml):
return self.params.importParams(xml)
def updateParams(self, xml):
return self.params.updateParams(xml)
def setDefault(self, name, category, callback, errback=None):
return self.params.setDefault(name, category, callback, errback)