INNER CODE UNIT · Python

ensure_list

O-X-L/ansible-opnsense · plugins/module_utils/helper/main.py:25

def ensure_list(data: (int, str, list, None)) -> list:
    """
        Normalizes input to ensure it is always returned as a list.

        :param data: Input data (scalar, list, or None).
        :return: A list containing the input or an empty list if input was None.
    """
    # if user supplied a string instead of a list => convert it to match our expectations
    if isinstance(data, list):
        return data

    if data is None:
        return []

    return [data]


def is_true(data: (str, int, bool)) -> bool:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…