def get_instance(kind, sample=None, color='red'):
    """Get either a string, non-color ColorStr, or color ColorStr instance.

    :param str kind: Type of string to test.
    :param iter sample: Input test to derive instances from.
    :param str color: Color tags to use. Default is red.

    :return: Instance.
    """
    # First determine which class/type to use.
    if kind.startswith('ColorStr'):
        cls = ColorStr
    elif kind.startswith('Color'):
        cls = Color
    else:
        cls = PARENT_CLASS

    # Next handle NoneType samples.
    if sample is None:
        return cls()

    # Finally handle non-None samples.
    if kind.endswith('plain'):
        return cls(sample)
    elif kind.endswith('color'):
        tags = '{%s}' % color, '{/%s}' % color
        return cls(tags[0] + sample + tags[1])
    return sample
dataset/ETHPy150Open Robpol86/colorclass/tests/conftest.py/get_instance/original