|
@ -382,18 +382,37 @@ def main(): |
|
|
schema = None |
|
|
schema = None |
|
|
|
|
|
|
|
|
if schema: |
|
|
if schema: |
|
|
|
|
|
|
|
|
|
|
|
# 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 ...") |
|
|
print("Generating JSON ...") |
|
|
dump_json(schema, Path('schema.json')) |
|
|
dump_json(schema, Path('schema.json')) |
|
|
|
|
|
|
|
|
|
|
|
# JSON schema (wildcard names) |
|
|
|
|
|
if arg in ['group', 'jsons']: |
|
|
group_options(schema) |
|
|
group_options(schema) |
|
|
dump_json(schema, Path('schema_grouped.json')) |
|
|
dump_json(schema, Path('schema_grouped.json')) |
|
|
|
|
|
|
|
|
|
|
|
# YAML |
|
|
|
|
|
if arg in ['some', 'yml', 'yaml']: |
|
|
try: |
|
|
try: |
|
|
import yaml |
|
|
import yaml |
|
|
except ImportError: |
|
|
except ImportError: |
|
|
print("Installing YAML module ...") |
|
|
print("Installing YAML module ...") |
|
|
import subprocess |
|
|
import subprocess |
|
|
|
|
|
try: |
|
|
subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml']) |
|
|
subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml']) |
|
|
import yaml |
|
|
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')) |
|
|