From 78a3d845db69327f8a7a5c2ee2d318e10416f36f Mon Sep 17 00:00:00 2001 From: souliane Date: Sun, 5 Jan 2014 07:26:41 +0100 Subject: [PATCH] memory: factorize the node checks in Params.__constructProfileXml --- src/memory/memory.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/memory/memory.py b/src/memory/memory.py index 461a964a..9bbc8f1d 100644 --- a/src/memory/memory.py +++ b/src/memory/memory.py @@ -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('') @@ -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