

def _set_background(self, background):
    flags = 0
    if (background in ('', 'default')):
        color = 0
    elif (background in _BASIC_COLORS):
        color = _BASIC_COLORS.index(background)
        flags |= _BG_BASIC_COLOR
    elif (self._value & _HIGH_88_COLOR):
        color = _parse_color_88(background)
        flags |= _BG_HIGH_COLOR
    else:
        color = _parse_color_256(background)
        flags |= _BG_HIGH_COLOR
    if (color is None):
        raise AttrSpecError((('Unrecognised color specification ' + 'in background (%s)') % (repr(background),)))
    self._value = (((self._value & (~ _BG_MASK)) | (color << _BG_SHIFT)) | flags)

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