# HG changeset patch # User souliane # Date 1388903201 -3600 # Node ID 900987e1c0c4288ecf375f6f6c18e1c51a7c13c2 # Parent 27581cddb758b8d4e37dd20a4e5c364bf6449e65 memory: factorize the node checks in Params.__constructProfileXml diff -r 27581cddb758 -r 900987e1c0c4 src/memory/memory.py --- a/src/memory/memory.py Sat Jan 04 21:09:32 2014 +0100 +++ b/src/memory/memory.py Sun Jan 05 07:26:41 2014 +0100 @@ -533,6 +533,10 @@ @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 @@ 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 @@ # 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