From 4cc3134aa1c13caa2a065b9c3f6bfb255b45c711 Mon Sep 17 00:00:00 2001 From: Dmitrii Golovanov Date: Wed, 18 Sep 2024 18:58:31 +0200 Subject: [PATCH] scripts: twister: Don't use match/case statements Don't use match/case syntax to allow twister to run with python3 versions < 3.10. Signed-off-by: Dmitrii Golovanov --- scripts/pylib/twister/twisterlib/statuses.py | 23 ++++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/scripts/pylib/twister/twisterlib/statuses.py b/scripts/pylib/twister/twisterlib/statuses.py index 2983917467f4f4..c5545b3fe28b89 100644 --- a/scripts/pylib/twister/twisterlib/statuses.py +++ b/scripts/pylib/twister/twisterlib/statuses.py @@ -23,18 +23,17 @@ def _missing_(cls, value): @staticmethod def get_color(status: TwisterStatus) -> str: - match(status): - case TwisterStatus.PASS: - color = Fore.GREEN - case TwisterStatus.SKIP | TwisterStatus.FILTER | TwisterStatus.BLOCK: - color = Fore.YELLOW - case TwisterStatus.FAIL | TwisterStatus.ERROR: - color = Fore.RED - case TwisterStatus.STARTED | TwisterStatus.NONE: - color = Fore.MAGENTA - case _: - color = Fore.RESET - return color + status2color = { + TwisterStatus.PASS: Fore.GREEN, + TwisterStatus.SKIP: Fore.YELLOW, + TwisterStatus.FILTER: Fore.YELLOW, + TwisterStatus.BLOCK: Fore.YELLOW, + TwisterStatus.FAIL: Fore.RED, + TwisterStatus.ERROR: Fore.RED, + TwisterStatus.STARTED: Fore.MAGENTA, + TwisterStatus.NONE: Fore.MAGENTA + } + return status2color[status] if status in status2color else Fore.RESET # All statuses below this comment can be used for TestCase BLOCK = 'blocked'