From f65767806eb856a545c9c334159944729ef7bd52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Thu, 30 May 2024 01:03:35 +0000 Subject: [PATCH] Sort schema keys with same indenting as .editorconfig --- .automation/build.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/.automation/build.py b/.automation/build.py index 363b569deca..fa0c7974102 100644 --- a/.automation/build.py +++ b/.automation/build.py @@ -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") @@ -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") @@ -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") @@ -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") @@ -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")