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)
| 10 | |
| 11 | |
| 12 | def 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 | |
| 32 | def main(): |
no test coverage detected