mirror of
https://github.com/pybricks/pybricks-projects.git
synced 2026-07-28 04:06:07 +00:00
44 lines
991 B
Python
Executable File
44 lines
991 B
Python
Executable File
#!/usr/bin/env python3
|
|
from os import scandir, path
|
|
from json import dump
|
|
|
|
|
|
def make_workspace(root):
|
|
|
|
# Get list of folder names
|
|
names = [d.name for d in scandir(root) if d.is_dir()]
|
|
names.sort()
|
|
|
|
# Make the workspace dictionary
|
|
workspace = {
|
|
"folders": [
|
|
{
|
|
"path": name
|
|
}
|
|
for name in names
|
|
],
|
|
"settings": {
|
|
"debug.openDebug": "neverOpen"
|
|
}
|
|
}
|
|
|
|
# Work space name is same as path
|
|
workspace_name = root.replace('/', '_').replace('\\', '_')
|
|
workspace_name += '.code-workspace'
|
|
|
|
# Save workspace
|
|
with open(path.join(root, workspace_name), 'w') as f:
|
|
dump(workspace, f, indent=4)
|
|
|
|
|
|
# Make all the workspaces
|
|
roots = (
|
|
path.join('sets', 'ev3', 'education_core'),
|
|
path.join('sets', 'ev3', 'education_expansion'),
|
|
path.join('sets', 'ev3', 'home'),
|
|
path.join('sets', 'ev3', 'home_bonus'),
|
|
)
|
|
|
|
for root in roots:
|
|
make_workspace(root)
|