def supports()

in core/src/klio_core/config/_io.py [0:0]


def supports(*type_directions):
    """Decorator for subclasses of KlioIOConfig to indicate what IO types and
    directions the Config supports.  In many cases the same config object can
    be used for configuring either input or output, and likewise event I/O and
    data I/O.  Adding respective `KlioIOType` and `KlioIODirection` values via
    this decorator will inform Klio about which class to use when parsing
    config.

    """

    def wrapper(cls):
        io_types = [t for t in type_directions if isinstance(t, KlioIOType)]
        io_directions = [
            t for t in type_directions if isinstance(t, KlioIODirection)
        ]
        # IMPORTANT - new lists must be created here, otherwise all subclasses
        # end up sharing the same lists
        cls.SUPPORTED_TYPES = [t for t in cls.SUPPORTED_TYPES]
        cls.SUPPORTED_DIRECTIONS = [d for d in cls.SUPPORTED_DIRECTIONS]
        for t in io_types:
            if t not in cls.SUPPORTED_TYPES:
                cls.SUPPORTED_TYPES.append(t)
        for d in io_directions:
            if d not in cls.SUPPORTED_DIRECTIONS:
                cls.SUPPORTED_DIRECTIONS.append(d)
        return cls

    return wrapper