Skip to content

Commit

Permalink
Sort schema keys with same indenting as .editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix committed May 30, 2024
1 parent efbf2bd commit f657678
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions .automation/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2350,7 +2350,7 @@ def add_in_config_schema_file(variables):
json_schema["properties"] = json_schema_props
if updated is True:
with open(CONFIG_JSON_SCHEMA, "w", encoding="utf-8") as outfile:
json.dump(json_schema, outfile, indent=4, sort_keys=True)
json.dump(json_schema, outfile, indent=2, sort_keys=True)
outfile.write("\n")


Expand All @@ -2367,7 +2367,7 @@ def remove_in_config_schema_file(variables):
json_schema["properties"] = json_schema_props
if updated is True:
with open(CONFIG_JSON_SCHEMA, "w", encoding="utf-8") as outfile:
json.dump(json_schema, outfile, indent=4, sort_keys=True)
json.dump(json_schema, outfile, indent=2, sort_keys=True)
outfile.write("\n")


Expand Down Expand Up @@ -2707,8 +2707,8 @@ def generate_json_schema_enums():
with open(DESCRIPTOR_JSON_SCHEMA, "r", encoding="utf-8") as json_file:
json_schema = json.load(json_file)
json_schema["definitions"]["enum_flavors"]["enum"] = ["all_flavors"] + list(
flavors.keys()
).sort()
sorted(set(list(flavors.keys())))
)
with open(DESCRIPTOR_JSON_SCHEMA, "w", encoding="utf-8") as outfile:
json.dump(json_schema, outfile, indent=2, sort_keys=True)
outfile.write("\n")
Expand All @@ -2719,13 +2719,19 @@ def generate_json_schema_enums():
json_schema = json.load(json_file)
json_schema["definitions"]["enum_descriptor_keys"]["enum"] = [
x["descriptor_id"] for x in descriptors
].sort()
]
json_schema["definitions"]["enum_descriptor_keys"]["enum"] += ["CREDENTIALS", "GIT"]
json_schema["definitions"]["enum_linter_keys"]["enum"] = [
x.name for x in linters
].sort()
json_schema["definitions"]["enum_linter_keys"]["enum"] = [x.name for x in linters]
# Deprecated linters
json_schema["definitions"]["enum_linter_keys"]["enum"] += DEPRECATED_LINTERS

# Sort:
json_schema["definitions"]["enum_descriptor_keys"]["enum"] = sorted(
set(json_schema["definitions"]["enum_descriptor_keys"]["enum"])
)
json_schema["definitions"]["enum_linter_keys"]["enum"] = sorted(
set(json_schema["definitions"]["enum_linter_keys"]["enum"])
)
with open(CONFIG_JSON_SCHEMA, "w", encoding="utf-8") as outfile:
json.dump(json_schema, outfile, indent=2, sort_keys=True)
outfile.write("\n")
Expand Down Expand Up @@ -3354,17 +3360,22 @@ def update_workflow_linters(file_path, linters):


if __name__ == "__main__":
logging_format = (
"[%(levelname)s] %(message)s"
if "CI" in os.environ
else "%(asctime)s [%(levelname)s] %(message)s"
)
try:
logging.basicConfig(
force=True,
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
format=logging_format,
handlers=[logging.StreamHandler(sys.stdout)],
)
except ValueError:
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
format=logging_format,
handlers=[logging.StreamHandler(sys.stdout)],
)
config.init_config("build")
Expand Down

0 comments on commit f657678

Please sign in to comment.