misc.is_multi_value(): Add function

Add a function that allows to test one expression if a value can be
iterated over without being a string or bytes.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-07-08 14:43:30 +02:00 • committed by janware DevOps
commit cb3ad84fda
Signed by: DevOps
SSH key fingerprint: SHA256:cZiw7ExG5q3KAVm7Jse3rGITowu0VjgUgNMPbifmY8g

View file

@ -195,6 +195,9 @@ def multi_regex_edit(spec, strings: Iterable[str]) -> list[str]: # export
raise Exception('Invalid command in multi_regex_edit(): {}'.format(str(cmd)))
return strings
def is_multi_value(obj: Any) -> bool: # export
return isinstance(obj, Iterable) and not isinstance(obj, (str, bytes))
def dump(prio: int, objects: Iterable, *args, **kwargs) -> None: # export
caller = log.get_caller_pos(kwargs = kwargs)
log.slog(prio, ",---------- {}".format(' '.join(args)), caller = caller)