Python SCons if/then语句
我在顶级目录中有一个SConscript文件,并且有许多子目录,其中包含包含不同键/值对的JSON文件。我的SConscript文件中有一个Python SCons if/then语句,python,json,scons,Python,Json,Scons,我在顶级目录中有一个SConscript文件,并且有许多子目录,其中包含包含不同键/值对的JSON文件。我的SConscript文件中有一个env.Command(),我希望根据特定键的值调用它。在Scons中,最好的方法是什么 我的想法是: env.Command( test = Value(params['json_key']) if test == "True": target = out.txt, source = in.txt,
env.Command()
,我希望根据特定键的值调用它。在Scons中,最好的方法是什么
我的想法是:
env.Command(
test = Value(params['json_key'])
if test == "True":
target = out.txt,
source = in.txt,
action = 'function $SOURCE $TARGET'
else:
pass
)
这是Python,您不能将if/else放在类似的内容中。但是,您可以使用字典将参数传递给
env.Command
if Value(params['json_key']) == "True":
kw = {
'target': 'out.txt',
'source': 'in.txt',
'action': 'function $SOURCE $TARGET',
}
else:
kw = {}
env.Command(**kw)