From 856a67a47424518d9372fd93c433f1a69f76bde3 Mon Sep 17 00:00:00 2001 From: Sebastian Espei Date: Fri, 13 May 2022 12:53:22 +0200 Subject: [PATCH] Add not found header after postprocessing The postprocessing method assumes that the sout data is always delivered in the same format. If the location is not found, the passed format deviates and this then leads to an incorrect behavior => incorrect return value. Close #729 Close #728 --- lib/view/wttr.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/view/wttr.py b/lib/view/wttr.py index 1c0b205..72222d3 100644 --- a/lib/view/wttr.py +++ b/lib/view/wttr.py @@ -31,6 +31,7 @@ def get_wetter(parsed_query): returncode = 0 if not location_not_found: stdout, stderr, returncode = _wego_wrapper(location, parsed_query) + first_line, stdout = _wego_postprocessing(location, parsed_query, stdout) if location_not_found or \ (returncode != 0 \ @@ -57,13 +58,8 @@ def get_wetter(parsed_query): not_found_footer = "\n".join("\033[48;5;91m " + x + " \033[0m" for x in not_found_footer.splitlines() if x) + "\n" - stdout = not_found_header + "\n----\n" + stdout + not_found_footer - - if "\n" in stdout: first_line, stdout = _wego_postprocessing(location, parsed_query, stdout) - else: - first_line = "" - + stdout = not_found_header + "\n----\n" + stdout + not_found_footer if html: return _htmlize(stdout, first_line, parsed_query)