瀏覽代碼

add callable support to add_param_value

Jens Keim 6 年之前
父節點
當前提交
ae80c2ff0e
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      code/Attack/BaseAttack.py

+ 8 - 1
code/Attack/BaseAttack.py

@@ -369,9 +369,16 @@ class BaseAttack(metaclass=abc.ABCMeta):
             sys.exit(-1)
 
         # if parameter is already specified, stop
-        if param_name in self.params.keys():
+        if param_name in self.params.keys()\
+                and not callable(value)\
+                and ((isinstance(value, list) and self.params.values() not in value)
+                     or value not in self.params.values()):
             return
 
+        # call function or method if necessary
+        if callable(value):
+            value = value()
+
         # Get parameter type of attack's required_params
         param_type = self.supported_params.get(param_name)