-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpg_ext_create.py
executable file
·47 lines (28 loc) · 1008 Bytes
/
pg_ext_create.py
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
42
43
44
45
46
47
#! /usr/bin/python3
from jinja2 import Environment, FileSystemLoader
import os
import sys
environment = Environment(loader=FileSystemLoader("template/"))
def create_file(template_file, modulename, outname):
template = environment.get_template(template_file)
content = template.render(
name = modulename,
)
filename = os.path.join( modulename,outname)
# print(modulename, filename, outname)
with open(filename, 'w') as f:
f.write(content)
f.close()
def main():
if len(sys.argv) == 1:
print("USAGE:\n {} <module name>".format(sys.argv[0]))
exit(1)
modulename = sys.argv[1]
if not os.path.isdir(modulename):
os.mkdir(modulename, mode=0o755)
create_file('Makefile', modulename, 'Makefile')
create_file('sql--0.1.sql', modulename, modulename + "--0.1.sql")
create_file('c.c', modulename, modulename + ".c")
create_file('control.control', modulename, modulename + ".control")
print( 'the module {} was autogenerated in dir {}'.format(modulename,modulename))
main()