-
Notifications
You must be signed in to change notification settings - Fork 6
/
generate_vstasks.py
99 lines (94 loc) · 2.46 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import sys
from pathlib import Path
TEMPLATE = """\
{{
"version": "2.0.0",
"args": [],
"echoCommand": false,
"runner": "terminal",
"tasks": [
{{
"label": "format-code",
"type": "shell",
"command": "black",
"args": [
"*.py",
"{modulename:s}/*.py",
"{modulename:s}/*/*.py",
],
}},
{{
"label": "test",
"type": "shell",
"command": "{pyexec:s}",
"args": [
"check_{modulename:s}.py",
"--tb=short",
"--strict",
"--cov-report=xml:cov.xml",
"--cov={modulename:s}"
],
"group": {{
"kind": "test",
"isDefault": true
}}
}},
{{
"label": "test-lastfailed",
"command": "{pyexec:s}",
"args": [
"check_{modulename:s}.py",
"--strict",
"--tb=short",
"--lf",
],
"group": {{
"kind": "test",
"isDefault": true
}},
"type": "shell"
}},
{{
"label": "test-debuggin",
"command": "{pyexec:s}",
"args": [
"check_{modulename:s}.py",
"--strict",
"--tb=short",
"--lf",
"--pdb"
],
"group": {{
"kind": "test",
"isDefault": true
}},
"type": "shell"
}},
{{
"label": "notebooks",
"options": {{
"cwd": "${{workspaceRoot}}/docs/tutorial"
}},
"command": "{pyexec:s}",
"args": ["make.py"]
}},
{{
"label": "docs",
"options": {{
"cwd": "${{workspaceRoot}}/docs"
}},
"command": "make.bat",
"args": ["html"]
}}
]
}}
"""
if __name__ == "__main__":
configdir = Path(".vscode")
configdir.mkdir(exist_ok=True, parents=True)
configpath = configdir / "tasks.json"
python = str(Path(sys.executable))
name = Path.cwd().name if len(sys.argv) < 2 else sys.argv[1]
config = TEMPLATE.format(pyexec=python, modulename=name)
with configpath.open("w") as configfile:
configfile.write(config)