Browse Source

🔨 Add args to schema.py

FB4S_WIFI
Scott Lahteine 2 years ago
parent
commit
c154302ece
  1. 49
      buildroot/share/PlatformIO/scripts/schema.py

49
buildroot/share/PlatformIO/scripts/schema.py

@ -382,21 +382,40 @@ def main():
schema = None schema = None
if schema: if schema:
print("Generating JSON ...")
dump_json(schema, Path('schema.json')) # Get the first command line argument
group_options(schema) import sys
dump_json(schema, Path('schema_grouped.json')) if len(sys.argv) > 1:
arg = sys.argv[1]
try: else:
import yaml arg = 'some'
except ImportError:
print("Installing YAML module ...") # JSON schema
import subprocess if arg in ['some', 'json', 'jsons']:
subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml']) print("Generating JSON ...")
import yaml dump_json(schema, Path('schema.json'))
print("Generating YML ...") # JSON schema (wildcard names)
dump_yaml(schema, Path('schema.yml')) if arg in ['group', 'jsons']:
group_options(schema)
dump_json(schema, Path('schema_grouped.json'))
# YAML
if arg in ['some', 'yml', 'yaml']:
try:
import yaml
except ImportError:
print("Installing YAML module ...")
import subprocess
try:
subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml'])
import yaml
except:
print("Failed to install YAML module")
return
print("Generating YML ...")
dump_yaml(schema, Path('schema.yml'))
if __name__ == '__main__': if __name__ == '__main__':
main() main()

Loading…
Cancel
Save