Skip to content

Commit

Permalink
馃敤 Add args to schema.py
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Aug 17, 2022
1 parent 0100b7b commit ce26fcc
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions buildroot/share/PlatformIO/scripts/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,25 +382,40 @@ def main():
schema = None

if schema:
print("Generating JSON ...")
dump_json(schema, Path('schema.json'))
group_options(schema)
dump_json(schema, Path('schema_grouped.json'))

try:
import yaml
except ImportError:
print("Installing YAML module ...")
import subprocess

# Get the first command line argument
import sys
if len(sys.argv) > 1:
arg = sys.argv[1]
else:
arg = 'some'

# JSON schema
if arg in ['some', 'json', 'jsons']:
print("Generating JSON ...")
dump_json(schema, Path('schema.json'))

# JSON schema (wildcard names)
if arg in ['group', 'jsons']:
group_options(schema)
dump_json(schema, Path('schema_grouped.json'))

# YAML
if arg in ['some', 'yml', 'yaml']:
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'))
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__':
main()

0 comments on commit ce26fcc

Please sign in to comment.