format: reformat with latest openbmc-build-scripts
Run all the latest formatters from openbmc-build-scripts. Disable
prettier on the configurations subdirectory because these are
script-formatted already with the repo-local `format-code` extension.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ifa4f2ec6688d60fde2a5f42efc96b6046e9be642
diff --git a/scripts/validate_configs.py b/scripts/validate_configs.py
index 7d580c2..5ba8945 100755
--- a/scripts/validate_configs.py
+++ b/scripts/validate_configs.py
@@ -5,10 +5,11 @@
"""
import argparse
import json
-import jsonschema.validators
import os
import sys
+import jsonschema.validators
+
DEFAULT_SCHEMA_FILENAME = "global.json"
@@ -17,24 +18,40 @@
description="Entity manager configuration validator",
)
parser.add_argument(
- "-s", "--schema", help=(
+ "-s",
+ "--schema",
+ help=(
"Use the specified schema file instead of the default "
- "(__file__/../../schemas/global.json)"))
+ "(__file__/../../schemas/global.json)"
+ ),
+ )
parser.add_argument(
- "-c", "--config", action='append', help=(
+ "-c",
+ "--config",
+ action="append",
+ help=(
"Validate the specified configuration files (can be "
"specified more than once) instead of the default "
- "(__file__/../../configurations/**.json)"))
+ "(__file__/../../configurations/**.json)"
+ ),
+ )
parser.add_argument(
- "-e", "--expected-fails", help=(
+ "-e",
+ "--expected-fails",
+ help=(
"A file with a list of configurations to ignore should "
- "they fail to validate"))
+ "they fail to validate"
+ ),
+ )
parser.add_argument(
- "-k", "--continue", action='store_true', help=(
- "keep validating after a failure"))
+ "-k",
+ "--continue",
+ action="store_true",
+ help="keep validating after a failure",
+ )
parser.add_argument(
- "-v", "--verbose", action='store_true', help=(
- "be noisy"))
+ "-v", "--verbose", action="store_true", help="be noisy"
+ )
args = parser.parse_args()
schema_file = args.schema
@@ -42,11 +59,14 @@
try:
source_dir = os.path.realpath(__file__).split(os.sep)[:-2]
schema_file = os.sep + os.path.join(
- *source_dir, 'schemas', DEFAULT_SCHEMA_FILENAME)
+ *source_dir, "schemas", DEFAULT_SCHEMA_FILENAME
+ )
except Exception:
sys.stderr.write(
"Could not guess location of {}\n".format(
- DEFAULT_SCHEMA_FILENAME))
+ DEFAULT_SCHEMA_FILENAME
+ )
+ )
sys.exit(2)
schema = {}
@@ -55,22 +75,22 @@
schema = json.load(fd)
except FileNotFoundError:
sys.stderr.write(
- "Could not read schema file '{}'\n".format(schema_file))
+ "Could not read schema file '{}'\n".format(schema_file)
+ )
sys.exit(2)
config_files = args.config or []
if len(config_files) == 0:
try:
source_dir = os.path.realpath(__file__).split(os.sep)[:-2]
- configs_dir = os.sep + os.path.join(*source_dir, 'configurations')
+ configs_dir = os.sep + os.path.join(*source_dir, "configurations")
data = os.walk(configs_dir)
for root, _, files in data:
for f in files:
- if f.endswith('.json'):
+ if f.endswith(".json"):
config_files.append(os.path.join(root, f))
except Exception:
- sys.stderr.write(
- "Could not guess location of configurations\n")
+ sys.stderr.write("Could not guess location of configurations\n")
sys.exit(2)
configs = []
@@ -80,7 +100,8 @@
configs.append(json.load(fd))
except FileNotFoundError:
sys.stderr.write(
- "Could not parse config file '{}'\n".format(config_file))
+ "Could not parse config file '{}'\n".format(config_file)
+ )
sys.exit(2)
expected_fails = []
@@ -91,12 +112,15 @@
expected_fails.append(line.strip())
except Exception:
sys.stderr.write(
- "Could not read expected fails file '{}'\n".format(
- args.expected_fails))
+ "Could not read expected fails file '{}'\n".format(
+ args.expected_fails
+ )
+ )
sys.exit(2)
base_uri = "file://{}/".format(
- os.path.split(os.path.realpath(schema_file))[0])
+ os.path.split(os.path.realpath(schema_file))[0]
+ )
resolver = jsonschema.RefResolver(base_uri, schema)
validator = jsonschema.Draft7Validator(schema, resolver=resolver)