-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·63 lines (43 loc) · 1.55 KB
/
main.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
__author__ = 'Krishnan Chandra'
import argparse
from subprocess import call
import json
def create_project(framework, name):
create_function = {
'django': make_django_project,
'node_js': make_node_js_project,
'flask': make_flask_project,
'rails': make_rails_project
}.get(framework, None)
if create_function is None:
print 'Framework you chose is not supported'
else:
if name is not None:
create_function(name)
else:
print 'Name needs to be non-empty'
def make_project(name, project_loc):
env_name = name + 'Env'
call(['cp', '-R', 'samples/' + project_loc, name])
def make_flask_project(name):
make_project(name, 'flask/examples/blueprintexample')
def make_django_project(name):
make_project(name, 'django/')
def make_rails_project(name):
make_project(name, 'rails/')
def make_node_js_project(name):
make_project(name, 'nodejs/')
def parse_config_file(fname):
with open(fname) as f:
config_dict = json.loads(f.read())
return config_dict
def main():
parser = argparse.ArgumentParser(description='Parse options for projects')
parser.add_argument('config', type=str, help='The path to the JSON config file containing project config information',
metavar='config')
args = parser.parse_args()
config_settings = parse_config_file(args.config)
create_project(config_settings.get('middle', None), config_settings.get('name', None))
if __name__ == "__main__":
main()