From 3f3595acb4e121aa2408912c411fd792f3548727 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sun, 29 Jan 2023 18:21:04 -0500 Subject: [PATCH] Sort config.json in alphabetical order --- app/classes/shared/helpers.py | 2 +- app/classes/shared/main_controller.py | 11 +++++++++-- app/classes/web/panel_handler.py | 5 ++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index 7dcbdeef..691a25f1 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -411,7 +411,7 @@ class Helpers: "virtual_terminal_lines": 70, "max_log_lines": 700, "max_audit_entries": 300, - "disabled_language_files": ["lol_EN.json", ""], + "disabled_language_files": [], "stream_size_GB": 1, "keywords": ["help", "chunk"], "allow_nsfw_profile_pictures": False, diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index 31b9c314..3bbe05f8 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -251,7 +251,11 @@ class Controller: except: # Call helper to set updated config. Console.warning("No Config found. Setting Default Config.json") - self.helper.set_settings(master_config) + user_config = master_config + keys = list(user_config.keys()) + keys.sort() + sorted_data = {i: user_config[i] for i in keys} + self.helper.set_settings(user_config) return items_to_del = [] @@ -270,7 +274,10 @@ class Controller: if key not in user_config.keys(): user_config[key] = value # Call helper to set updated config. - self.helper.set_settings(user_config) + keys = list(user_config.keys()) + keys.sort() + sorted_data = {i: user_config[i] for i in keys} + self.helper.set_settings(sorted_data) def send_log_status(self): try: diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index bf56c3e0..74c93b88 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -1774,8 +1774,11 @@ class PanelHandler(BaseHandler): data[key] = False else: data[key] = arg_data + keys = list(data.keys()) + keys.sort() + sorted_data = {i: data[i] for i in keys} with open(self.helper.settings_file, "w", encoding="utf-8") as f: - json.dump(data, f, indent=4) + json.dump(sorted_data, f, indent=4) except Exception as e: logger.critical( "Config File Error: Unable to read "