-
Notifications
You must be signed in to change notification settings - Fork 5
/
generate_vstasks.py
61 lines (53 loc) · 1.35 KB
/
generate_vstasks.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
import sys
import os
TEMPLATE = """\
{{
"version": "0.1.0",
"isShellCommand": false,
"args": [],
"showOutput": "always",
"echoCommand": false,
"suppressTaskName": false,
"tasks": [
{{
"taskName": "test",
"command": "{pyexec:s}",
"args": [
"check_{modulename:s}.py",
"--cov",
"--pep8"
]
}},
{{
"taskName": "notebooks",
"options": {{
"cwd": "${{workspaceRoot}}/docs/tutorial"
}},
"command": "{pyexec:s}",
"args": ["make.py"]
}},
{{
"taskName": "docs",
"options": {{
"cwd": "${{workspaceRoot}}/docs"
}},
"command": "make.bat",
"args": ["html"]
}}
]
}}
"""
if __name__ == "__main__":
dirname = ".vscode"
filename = "tasks.json"
filepath = os.path.join(dirname, filename)
if not os.path.exists(dirname):
os.makedirs(dirname)
if len(sys.argv) < 2:
name = os.path.split(os.getcwd())[-1]
else:
name = sys.argv[1]
python = "/".join(sys.executable.split(os.path.sep))
config = TEMPLATE.format(pyexec=python, modulename=name)
with open(filepath, "w") as configfile:
configfile.write(config)