emdbg.debug.utils

 1# Copyright (c) 2020-2022, Niklas Hauser
 2# Copyright (c) 2023, Auterion AG
 3# SPDX-License-Identifier: BSD-3-Clause
 4
 5
 6def _listify(obj):
 7    if obj is None:
 8        return list()
 9    if isinstance(obj, (list, tuple, set, range)):
10        return list(obj)
11    if hasattr(obj, "__iter__") and not hasattr(obj, "__getitem__"):
12        return list(obj)
13    return [obj, ]
14
15
16def listify(*objs):
17    """
18    Convert arguments to list if they are not already a list.
19    """
20    return [l for o in objs for l in _listify(o)]
21
22
23def listrify(*objs):
24    """
25    Convert arguments to list of strings.
26    """
27    return list(map(str, listify(*objs)))
def listify(*objs):
17def listify(*objs):
18    """
19    Convert arguments to list if they are not already a list.
20    """
21    return [l for o in objs for l in _listify(o)]

Convert arguments to list if they are not already a list.

def listrify(*objs):
24def listrify(*objs):
25    """
26    Convert arguments to list of strings.
27    """
28    return list(map(str, listify(*objs)))

Convert arguments to list of strings.