memory: factorize the node checks in Params.__constructProfileXml

This commit is contained in:
souliane 2014-01-05 07:26:41 +01:00
commit 78a3d845db

View file

@ -533,6 +533,10 @@ class Params(object):
@return: a deferred that fire a minidom.Document of the profile xml (cf warning above)
"""
def checkNode(node):
"""Check the node against security_limit and app"""
return self.checkSecurityLimit(node, security_limit) and self.checkApp(node, app)
def constructProfile(ignore, profile_cache):
# init the result document
prof_xml = minidom.parseString('<params/>')
@ -553,10 +557,7 @@ class Params(object):
for node in dest_cat.childNodes:
if node.nodeName != "param":
continue
if not self.checkSecurityLimit(node, security_limit):
dest_cat.removeChild(node)
continue
if not self.checkApp(node, app):
if not checkNode(node):
dest_cat.removeChild(node)
continue
dest_params[node.getAttribute('name')] = node
@ -571,9 +572,7 @@ class Params(object):
# we have to merge new params (we are parsing individual parameters, we have to add them
# to the previously parsed general ones)
name = param_node.getAttribute('name')
if not self.checkSecurityLimit(param_node, security_limit):
continue
if not self.checkApp(param_node, app):
if not checkNode(param_node):
continue
if name not in dest_params:
# this is reached when a previous category exists