[core] allow lambda on "group" property

This commit is contained in:
Fabien Castan 2020-11-20 17:40:49 +01:00
parent 4340634ef5
commit 4e5bef2a80

View file

@ -10,6 +10,7 @@ import platform
import re import re
import shutil import shutil
import time import time
import types
import uuid import uuid
from collections import defaultdict, namedtuple from collections import defaultdict, namedtuple
from enum import Enum from enum import Enum
@ -561,15 +562,15 @@ class BaseNode(BaseObject):
def _buildCmdVars(self): def _buildCmdVars(self):
def _buildAttributeCmdVars(cmdVars, name, attr): def _buildAttributeCmdVars(cmdVars, name, attr):
if attr.enabled: if attr.enabled:
if attr.attributeDesc.group is not None: group = attr.attributeDesc.group(attr.node) if isinstance(attr.attributeDesc.group, types.FunctionType) else attr.attributeDesc.group
if group is not None:
# if there is a valid command line "group" # if there is a valid command line "group"
v = attr.getValueStr() v = attr.getValueStr()
cmdVars[name] = '--{name} {value}'.format(name=name, value=v) cmdVars[name] = '--{name} {value}'.format(name=name, value=v)
cmdVars[name + 'Value'] = str(v) cmdVars[name + 'Value'] = str(v)
if v: if v:
cmdVars[attr.attributeDesc.group] = cmdVars.get(attr.attributeDesc.group, '') + \ cmdVars[group] = cmdVars.get(group, '') + ' ' + cmdVars[name]
' ' + cmdVars[name]
elif isinstance(attr, GroupAttribute): elif isinstance(attr, GroupAttribute):
assert isinstance(attr.value, DictModel) assert isinstance(attr.value, DictModel)
# if the GroupAttribute is not set in a single command line argument, # if the GroupAttribute is not set in a single command line argument,