

def _set_foreground(self, foreground):
    color = None
    flags = 0
    for part in foreground.split(','):
        part = part.strip()
        if (part in _ATTRIBUTES):
            if (flags & _ATTRIBUTES[part]):
                raise AttrSpecError((('Setting %s specified more than' + 'once in foreground (%s)') % (repr(part), repr(foreground))))
            flags |= _ATTRIBUTES[part]
            continue
        if (part in ('', 'default')):
            scolor = 0
        elif (part in _BASIC_COLORS):
            scolor = _BASIC_COLORS.index(part)
            flags |= _FG_BASIC_COLOR
        elif (self._value & _HIGH_88_COLOR):
            scolor = _parse_color_88(part)
            flags |= _FG_HIGH_COLOR
        else:
            scolor = _parse_color_256(part)
            flags |= _FG_HIGH_COLOR
        if (scolor is None):
            raise AttrSpecError((('Unrecognised color specification %s' + 'in foreground (%s)') % (repr(part), repr(foreground))))
        if (color is not None):
            raise AttrSpecError((('More than one color given for ' + 'foreground (%s)') % (repr(foreground),)))
        color = scolor
    if (color is None):
        color = 0
    self._value = (((self._value & (~ _FG_MASK)) | color) | flags)

dataset/ETHPy150Open AnyMesh/anyMesh-Python/example/urwid/display_common.py AttrSpec._set_foreground/original