-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathvscode.py
More file actions
23 lines (17 loc) · 637 Bytes
/
vscode.py
File metadata and controls
23 lines (17 loc) · 637 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import json
import subprocess
from pathlib import Path
def vscode():
venv_path = subprocess.check_output("poetry env info --path".split())
venv_path = venv_path.decode("UTF-8").rstrip()
settings = dict()
Path(".vscode").mkdir(parents=True, exist_ok=True)
Path(".vscode/settings.json").touch()
with open(".vscode/settings.json", "r") as f:
try:
settings = json.load(f)
except json.decoder.JSONDecodeError:
pass
settings["python.pythonPath"] = venv_path
with open(".vscode/settings.json", "w") as f:
json.dump(settings, f, sort_keys=True, indent=4)