def _to_color(num):
    if isinstance(num, int):
        return num
    if (isinstance(num, str) and (len(num) <= 3)):
        return (16 + int(num, 6))
    raise ValueError('Invalid color: {0!r}'.format(num))
def _to_color(num):
    if isinstance(num, int):
        return num
    if (isinstance(num, str) and (len(num) <= 3)):
        return (16 + int(num, 6))
    raise ValueError('Invalid color: {0!r}'.format(num))