Substitute any occurrence of @foo@ by d['foo'] from source file into target.
(target, source, d)
| 23 | from numpy.distutils.conv_template import process_file as process_c_file |
| 24 | |
| 25 | def 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 | |
| 38 | class build_src(build_ext.build_ext): |
| 39 |
no test coverage detected