refactored common logic for printing the outcome; incl. case where nothing needs to be done

This commit is contained in:
2020-11-03 17:56:22 +01:00
parent 0e95be7d2d
commit a69953c75c
3 changed files with 19 additions and 14 deletions

View File

@ -1,6 +1,20 @@
from .consts import SYM_GOOD, SYM_BAD
from .consts import SYM_NOTHING, SYM_GOOD, SYM_BAD
from .seq import is_empty
def print_outcome(state, units):
if is_empty(state):
print_nothing("nothing to do")
elif all(state):
print_good(f"all {units}")
else:
ntotal = len(state)
ngood = count_true(state)
print_bad(f"only {ngood}/{ntotal} {units}")
def print_nothing(*args, **kwargs):
return print(SYM_NOTHING, *args, **kwargs)
def print_good(*args, **kwargs):
return print(SYM_GOOD, *args, **kwargs)