MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / template_eval

Function template_eval

tools/te.py:471–481  ·  view source on GitHub ↗
(template, **kwargs)

Source from the content-addressed store, hash-verified

469
470
471def template_eval(template, **kwargs):
472 start = '<%'
473 end = '%>'
474 escaped = (re.escape(start), re.escape(end))
475 mark = re.compile('%s(.*?)%s' % escaped, re.DOTALL)
476 for key in kwargs:
477 exec('%s = %s' % (key, kwargs[key]))
478 for item in mark.findall(template):
479 template = template.replace(start + item + end,
480 str(eval(item.strip())))
481 return template
482
483
484def run(p):

Callers 1

runFunction · 0.70

Calls 4

execFunction · 0.85
evalFunction · 0.50
compileMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected