def parse_color(text):
    value = [1, 1, 1, 1]
    if text.startswith('rgb'):
        res = re.match('rgba?\((.*)\)', text)
        if res:
            try:
                # default r/g/b values to 1 if greater than 255 else x/255
                value = [1 if int(x) > 255. else (int(x) / 255.)
                         for x in re.split(',\ ?', res.groups()[0])]
                if len(value) < 3:
                    # in case of invalid input like rgb()/rgb(r)/rgb(r, g)
                    raise ValueError
            except ValueError:
                return color_error('ColorParser: Invalid color for %r' % text)
            except AttributeError:
                return color_error('ColorParser: Invalid color for %r' % text)
        else:
            return color_error('ColorParser: Invalid color for %r' % text)
        if len(value) == 3:
            value.append(1.)
    elif len(text):
        res = text
        if text[0] == '#':
            res = text[1:]
        lres = len(res)
        if lres == 3 or lres == 4:
            res = ''.join([x + x for x in res])
        elif lres != 6 and lres != 8:
            # raise ColorException('Invalid color format for %r' % text)
            return color_error(
                'ColorParser: Invalid color format for %r' % text)
        try:
            value = [int(res[i:i + 2], 16) / 255.
                     for i in range(0, len(res), 2)]
        except ValueError:
            return color_error('ColorParser: Invalid color for %r' % text)
        if lres == 6 or lres == 3:
            value.append(1.)
    return value
fit the model subject to linear equality constraints
dataset/ETHPy150Open kivy/kivy/kivy/parser.py/parse_color--crossover with--dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/discrete/discrete_model.py/Poisson.fit_constrained