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

Function process_tempita

numpy/_build_utils/tempita.py:12–29  ·  view source on GitHub ↗

Process tempita templated file and write out the result. The template file is expected to end in `.c.in` or `.pyx.in`: E.g. processing `template.c.in` generates `template.c`.

(fromfile, outfile=None)

Source from the content-addressed store, hash-verified

10
11
12def process_tempita(fromfile, outfile=None):
13 """Process tempita templated file and write out the result.
14
15 The template file is expected to end in `.c.in` or `.pyx.in`:
16 E.g. processing `template.c.in` generates `template.c`.
17
18 """
19 if outfile is None:
20 # We're dealing with a distutils build here, write in-place
21 outfile = os.path.splitext(fromfile)[0]
22
23 from_filename = tempita.Template.from_filename
24 template = from_filename(fromfile, encoding=sys.getdefaultencoding())
25
26 content = template.substitute()
27
28 with open(outfile, 'w') as f:
29 f.write(content)
30
31
32def main():

Callers 1

mainFunction · 0.85

Calls 3

openFunction · 0.85
substituteMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected