From 81160e7e54f4bec96c0e0c9c3dfe4bdb0b6be503 Mon Sep 17 00:00:00 2001 From: raj_mathe Date: Sun, 24 Oct 2021 23:34:42 +0200 Subject: [PATCH] =?UTF-8?q?master=20>=20master:=20code=20-=20display=20weg?= =?UTF-8?q?en=20gr=C3=B6=C3=9Ferer=20Inputs=20=C3=BCberarbeitet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/setup/display.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/code/setup/display.py b/code/setup/display.py index df1520b..0f3d933 100644 --- a/code/setup/display.py +++ b/code/setup/display.py @@ -23,15 +23,32 @@ def DisplayHelpMessage(): # METHODS display case # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def DisplayStartOfCase(name: Any): +def DisplayStartOfCase(index: int, descr: Any): DisplayBar(80); - logPlain('\033[92;1mCASE {}\033[0m'.format(name)) + if not isinstance(descr, str) or descr == '': + logPlain('\033[92;1mCASE {index}\033[0m.'.format(index=index)); + else: + logPlain('\033[92;1mCASE {index}\033[0m (\033[1;2m{descr}\033[0m).'.format(index=index, descr=descr)); return; def DisplayEndOfCase(): DisplayBar(80); return; +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# METHODS display value +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +def RepresentValue(value: Any) -> Any: + if value is None or isinstance(value, (str, bool, int, float)): + return value; + elif isinstance(value, list): + if len(value) > 10: + value = value[:3] + [ '...' ] + value[-2:]; + # return '[{}, ..., {}]'.format(', '.join(value[:3]), ', '.join(value[-2:]) + return value; + return value; + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # METHODS display algorithm start/end # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -40,13 +57,13 @@ def DisplayStartOfAlgorithm(name: str, *_: Any, **inputs: Any): logPlain('Ausführung vom Algorithmus: \033[92;1m{}\033[0m'.format(name)); logPlain('INPUTS'); for varname, value in inputs.items(): - logPlain(' - {} = {}'.format(varname, value)) + logPlain(' - {} = {}'.format(varname, RepresentValue(value))) return; def DisplayEndOfAlgorithm(*_: Any, **outputs: Any): logPlain('OUTPUTS:') for varname, value in outputs.items(): - logPlain(' - {} = {}'.format(varname, value)) + logPlain(' - {} = {}'.format(varname, RepresentValue(value))) return; def DisplayMetrics():