changeset 784:900987e1c0c4

memory: factorize the node checks in Params.__constructProfileXml
author souliane <souliane@mailoo.org>
date Sun, 05 Jan 2014 07:26:41 +0100
parents 27581cddb758
children ff9a52077b36
files src/memory/memory.py
diffstat 1 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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('<params/>')
@@ -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