From faaff2754bf0ae3f436641bd973ce2a38846f834 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 27 Nov 2025 06:53:12 +0100 Subject: [PATCH] webconfig.py: fix stale return type This function returns a heterogeneous list (containing dicts/lists) by accident. Fix that and reduce code duplication. Fixes c018bfdb4d0 (Initial work to add support for angularjs, 2013-08-17). --- share/tools/web_config/webconfig.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index 90ca0a279..49d2e5ea8 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -761,9 +761,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): def do_get_colors(self, path=None): """Read the colors from a .theme file in path, or the current shell if no path has been given""" - # Looks for fish_color_*. - # Returns an array of lists [color_name, color_description, color_value] - result = [] # Make sure we return at least these remaining = set( @@ -820,7 +817,16 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): else: with open(path) as f: out = f.read() + info = {} + colors = [] + + def add_color(color_name, color_value): + color_desc = descriptions.get(color_name, "") + data = {"name": color_name, "description": color_desc} + data.update(parse_color(color_value)) + colors.append(data) + for line in out.split("\n"): # Ignore empty lines if not line: @@ -844,22 +850,17 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): color_name, color_value = [x.strip() for x in match.group(2, 3)] if match.group(1): color_name = "fish_pager_color_" + color_name - color_desc = descriptions.get(color_name, "") - data = {"name": color_name, "description": color_desc} - data.update(parse_color(color_value)) - result.append(data) + add_color(color_name, color_value) remaining.discard(color_name) - # Sort our result (by their keys) - result.sort(key=operator.itemgetter("name")) + colors.sort(key=operator.itemgetter("name")) # Ensure that we have all the color names we know about, so that if the # user deletes one he can still set it again via the web interface for color_name in remaining: - color_desc = descriptions.get(color_name, "") - result.append([color_name, color_desc, parse_color("")]) + add_color(color_name, "") - info["colors"] = result + info["colors"] = colors return info def do_get_functions(self):