-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_template.py
32 lines (25 loc) · 915 Bytes
/
test_template.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
from os import path
from importlib import import_module
import os
import shutil
import sys
import argparse
def main(module_name):
# module_name = 'templates.ultimate_sample_template'
module = import_module(module_name)
t = module.template()
tmpdir = path.join(path.dirname(__file__), 'tmp')
print('Working on '+tmpdir)
shutil.rmtree(tmpdir)
os.makedirs(tmpdir)
t.compile(t.sample_data(), tmpdir, pipe=False)
print('see output at '+tmpdir+'/driver.pdf')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=
"Test template.\n" +
'Ex: python test_template.py templates.basic_template',
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('module', metavar='module', type=str, nargs=1,
help='template module name(ex: templates.basic_template)')
args = parser.parse_args()
main(args.module[0])