def parse_color(token):
    if token.type == 'IDENT':
        return COLOR_KEYWORDS.get(token.value.lower())
    elif token.type == 'HASH':
        for multiplier, regexp in HASH_REGEXPS:
            match = regexp(token.value)
            if match:
                r, g, b = [int(group * multiplier, 16) / 255
                           for group in match.groups()]
                return RGBA(r, g, b, 1.)
    elif token.type == 'FUNCTION':
        args = parse_comma_separated(token.content)
        if args:
            name = token.function_name.lower()
            if name == 'rgb':
                return parse_rgb(args, alpha=1.)
            elif name == 'rgba':
                alpha = parse_alpha(args[3:])
                if alpha is not None:
                    return parse_rgb(args[:3], alpha)
            elif name == 'hsl':
                return parse_hsl(args, alpha=1.)
            elif name == 'hsla':
                alpha = parse_alpha(args[3:])
                if alpha is not None:
                    return parse_hsl(args[:3], alpha)
Parse single token as a color value.
dataset/ETHPy150Open FichteFoll/CSScheme/tinycsscheme/tinycss/color3.py/parse_color