Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def callbackVar(cnd, expr, use_options, target, add_dict):
if expr in mk.cond_vars:
cond = mk.cond_vars[expr]
var = mk.CondVar(makeUniqueCondVarName('%s_%s' % (cond.name, desc)))
mk.addCondVar(var, hints)
for v in cond.values:
cond2 = mk.mergeConditions(cnd, v.cond)
if '$' in v.value:
var.add(v.cond,
substitute2(v.value, callback, desc, cond2, hints))
else:
if len(v.value) == 0 or v.value.isspace():
var.add(v.cond, v.value)
else:
var.add(v.cond, callback(cond2, v.value))
return '$(%s)' % var.name
if expr in mk.options and mk.options[expr].values != None:
opt = mk.options[expr]
var = mk.CondVar(makeUniqueCondVarName('%s_%s' % (opt.name, desc)))
mk.addCondVar(var, hints)
for v in opt.values:
cond = mk.makeCondition("%s=='%s'" % (opt.name, v))
var.add(v.cond,
substitute2(v.value, callback, desc, cond2, hints))
else:
if len(v.value) == 0 or v.value.isspace():
var.add(v.cond, v.value)
else:
var.add(v.cond, callback(cond2, v.value))
return '$(%s)' % var.name
if expr in mk.options and mk.options[expr].values != None:
opt = mk.options[expr]
var = mk.CondVar(makeUniqueCondVarName('%s_%s' % (opt.name, desc)))
mk.addCondVar(var, hints)
for v in opt.values:
cond = mk.makeCondition("%s=='%s'" % (opt.name, v))
cond2 = mk.mergeConditions(cnd, cond)
if '$' in v:
var.add(cond, substitute2(v, callback, desc, cond2, hints))
else:
if len(v) == 0 or v.isspace(): var.add(cond, v)
else: var.add(cond, callback(cond2, v))
return '$(%s)' % var.name
if expr in __substituteCallbacks:
for func in __substituteCallbacks[expr]:
rval = func(expr, callback, caller)
if rval != None:
return rval
raise errors.Error("'%s' can't be used in this context, "%expr +
"not a conditional variable or option with listed values")