def add_ansi(self, sequence, filter_resets = False):

        values = iter(sequence)
        try:
            while True:
                value = next(values)
                if value == 38 or value == 48:
                    fg = value == 38
                    value = next(values)
                    if value == 5:
                        value = next(values)
                        if fg:
                            self.fg = self.color_class.from_full(value)
                        else:
                            self.bg = self.color_class.from_full(value, fg=False)
                    elif value == 2:
                        r = next(values)
                        g = next(values)
                        b = next(values)
                        if fg:
                            self.fg = self.color_class(r, g, b)
                        else:
                            self.bg = self.color_class(r, g, b, fg=False)
                    else:
                        raise ColorNotFound("the value 5 or 2 should follow a 38 or 48")
                elif value==0:
                    if filter_resets is False:
                        self.isreset = True
                elif value in attributes_ansi.values():
                    for name in attributes_ansi:
                        if value == attributes_ansi[name]:
                            self.attributes[name] = True
                elif value in (20+n for n in attributes_ansi.values()):
                    if filter_resets is False:
                        for name in attributes_ansi:
                            if value == attributes_ansi[name] + 20:
                                self.attributes[name] = False
                elif 30 <= value <= 37:
                    self.fg = self.color_class.from_simple(value-30)
                elif 40 <= value <= 47:
                    self.bg = self.color_class.from_simple(value-40, fg=False)
                elif 90 <= value <= 97:
                    self.fg = self.color_class.from_simple(value-90+8)
                elif 100 <= value <= 107:
                    self.bg = self.color_class.from_simple(value-100+8, fg=False)
                elif value == 39:
                    if filter_resets is False:
                        self.fg = self.color_class()
                elif value == 49:
                    if filter_resets is False:
                        self.bg = self.color_class(fg=False)
                else:
                    raise ColorNotFound("The code {0} is not recognised".format(value))
        except StopIteration:
            return
Adds a sequence of ansi numbers to the class. Will ignore resets if filter_resets is True.
dataset/ETHPy150Open tomerfiliba/plumbum/plumbum/colorlib/styles.py/Style.add_ansi