From c154302ece49db7e93aef6984d7159d89f36cee2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 17 Aug 2022 07:32:08 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Add=20args=20to=20schema.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/PlatformIO/scripts/schema.py | 45 ++++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/schema.py b/buildroot/share/PlatformIO/scripts/schema.py index 2c20f49dee..5316cb906a 100755 --- a/buildroot/share/PlatformIO/scripts/schema.py +++ b/buildroot/share/PlatformIO/scripts/schema.py @@ -382,21 +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 - subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml']) - import yaml + # Get the first command line argument + import sys + if len(sys.argv) > 1: + arg = sys.argv[1] + else: + arg = 'some' - print("Generating YML ...") - dump_yaml(schema, Path('schema.yml')) + # 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: + 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__': main()