File: autogen.py

package info (click to toggle)
pypy3 7.3.19%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212,236 kB
  • sloc: python: 2,098,316; ansic: 540,565; sh: 21,462; asm: 14,419; cpp: 4,451; makefile: 4,209; objc: 761; xml: 530; exp: 499; javascript: 314; pascal: 244; lisp: 45; csh: 12; awk: 4
file content (41 lines) | stat: -rw-r--r-- 1,060 bytes parent folder | download | duplicates (4)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
import sys
import py
if sys.version_info[0] < 3:
    print('ERROR: autogen.py should be run on top of Python 3.x')
    sys.exit(1)
if len(sys.argv) != 2:
    print('USAGE: autogen.py /path/to/hpy_repo')
    sys.exit(1)

HPY_PATH = sys.argv[1]
sys.path.insert(0, HPY_PATH)

from hpy.tools.autogen.parse import HPyAPI, PUBLIC_API_H, toC
from hpy.tools.autogen.autogenfile import AutoGenFile

# NOTE: autogen_interp_slots.py is no longer used. We keep the code around
# because it's useful as an example for when we will need to autogen other
# files
class autogen_example_py(AutoGenFile):
    PATH = 'autogen_example.py'
    LANGUAGE = 'Python'
    DISCLAIMER = '## DO NOT EDIT THIS FILE, IT IS AUTOGENERATED'

    def generate(self):
        lines = []
        w = lines.append
        #
        w(f'# example file')
        return '\n'.join(lines)


def main():
    OUTDIR = py.path.local(__file__).dirpath('..')
    api = HPyAPI.parse(PUBLIC_API_H)
    for cls in (autogen_example_py,):
        cls(api).write(OUTDIR)



if __name__ == '__main__':
    main()