MCPcopy Create free account
hub / github.com/numpy/numpy / subst_vars

Function subst_vars

numpy/distutils/command/build_src.py:25–36  ·  view source on GitHub ↗

Substitute any occurrence of @foo@ by d['foo'] from source file into target.

(target, source, d)

Source from the content-addressed store, hash-verified

23from numpy.distutils.conv_template import process_file as process_c_file
24
25def subst_vars(target, source, d):
26 """Substitute any occurrence of @foo@ by d['foo'] from source file into
27 target."""
28 var = re.compile('@([a-zA-Z_]+)@')
29 with open(source, 'r') as fs:
30 with open(target, 'w') as ft:
31 for l in fs:
32 m = var.search(l)
33 if m:
34 ft.write(l.replace('@%s@' % m.group(1), d[m.group(1)]))
35 else:
36 ft.write(l)
37
38class build_src(build_ext.build_ext):
39

Callers 1

_build_npy_pkg_configMethod · 0.85

Calls 4

openFunction · 0.85
replaceMethod · 0.80
compileMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected