0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-03-01 12:27:13 +00:00

🔨 Add args to schema.py

This commit is contained in:
Scott Lahteine 2022-08-17 07:32:08 -05:00
parent 0100b7be4d
commit ce26fccc3e

View file

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