From fe70c29c48a14e6c6732d7f02e6e2edc299bc487 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sat, 6 Mar 2021 17:08:28 -0800 Subject: [PATCH] Incorporate `black` suggestions & rearrange imports slightly This isn't really necessary, but it makes the file look nicer to my eyes. Let me know if you want me to remove this commit. --- share/tools/web_config/webconfig.py | 34 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index cfddf73f4..d7ad6ec73 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -23,7 +23,7 @@ from itertools import chain COMMON_WSL_CMD_PATHS = ( "/mnt/c/Windows/System32", "/windir/c/Windows/System32", - "/c/Windows/System32" + "/c/Windows/System32", ) FISH_BIN_PATH = False # will be set later IS_PY2 = sys.version_info[0] == 2 @@ -37,6 +37,21 @@ else: import socketserver as SocketServer from urllib.parse import parse_qs +try: + import json +except ImportError: + import simplejson as json + + +# Disable CLI web browsers +term = os.environ.pop("TERM", None) +# This import must be done with an empty $TERM, otherwise a command-line browser may be started +# which will block the whole process - see https://docs.python.org/3/library/webbrowser.html +import webbrowser + +if term: + os.environ["TERM"] = term + def find_executable(exe, paths=()): final_path = os.environ["PATH"].split(os.pathsep) @@ -81,21 +96,6 @@ def is_chromeos_garcon(): return "garcon-url-handler" in webbrowser.get().name -# Disable CLI web browsers -term = os.environ.pop("TERM", None) -# This import must be done with an empty $TERM, otherwise a command-line browser may be started -# which will block the whole process - see https://docs.python.org/3/library/webbrowser.html -import webbrowser - -if term: - os.environ["TERM"] = term - -try: - import json -except ImportError: - import simplejson as json - - def run_fish_cmd(text): # Ensure that fish is using UTF-8. ctype = os.environ.get("LC_ALL", os.environ.get("LC_CTYPE", os.environ.get("LANG"))) @@ -992,7 +992,7 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): vars[name].exported = True # Do not return history as a variable, it may be so large the browser hangs. - vars.pop('history', None) + vars.pop("history", None) return [ vars[key].get_json_obj()