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():