File: run_tempita.py

package info (click to toggle)
python-cykhash 2.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,240 kB
  • sloc: python: 3,954; sh: 90; makefile: 7
file content (28 lines) | stat: -rw-r--r-- 676 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
from Cython import Tempita


def render_templates(pxifiles):
    for pxifile in pxifiles:
        # build pxifiles first, template extension must be *.in
        outfile = pxifile[:-3]

        if (
            os.path.exists(outfile)
            and os.stat(pxifile).st_mtime < os.stat(outfile).st_mtime
        ):
            # if .pxi.in is not updated, no need to output .pxi
            continue

        with open(pxifile) as f:
            tmpl = f.read()
        pyxcontent = Tempita.sub(tmpl)

        with open(outfile, "w") as f:
            f.write(pyxcontent)

if __name__ == '__main__':
    import sys
    lst= sys.argv[1::]
    render_templates(lst)