From 98b87d4f72113224ba56aec7fff72103155c17e8 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 20 Jan 2023 17:14:30 +0100 Subject: [PATCH] update_app_levels: autosort keys --- update_app_levels/update_app_levels.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/update_app_levels/update_app_levels.py b/update_app_levels/update_app_levels.py index 0770440..12713de 100644 --- a/update_app_levels/update_app_levels.py +++ b/update_app_levels/update_app_levels.py @@ -5,6 +5,7 @@ import tempfile import os import sys import json +from collections import OrderedDict token = open(".github_token").read().strip() @@ -16,7 +17,8 @@ os.system(f"git -C {tmpdir} checkout -b update_app_levels") catalog = toml.load(open(f"{tmpdir}/apps.toml")) # Fetch results from the CI -ci_results = requests.get("https://ci-apps.yunohost.org/ci/logs/list_level_stable_amd64.json").json() +CI_RESULTS_URL = "https://ci-apps.yunohost.org/ci/logs/list_level_stable_amd64.json" +ci_results = requests.get(CI_RESULTS_URL).json() comment = { "major_regressions": [], @@ -55,6 +57,11 @@ for app, infos in catalog.items(): infos["level"] = ci_level +# Also re-sort the catalog keys / subkeys +for app, infos in catalog.items(): + catalog[app] = OrderedDict(sorted(infos.items())) +catalog = OrderedDict(sorted(catalog.items())) + updated_catalog = toml.dumps(catalog) updated_catalog = updated_catalog.replace(",]", " ]") open(f"{tmpdir}/apps.toml", "w").write(updated_catalog)