def __init__(self, *attrs, **kwargs):
        self.codes = [codes[attr.lower()] for attr in attrs if isinstance(attr, str)]

        if kwargs.get('reset', True):
            self.codes[:0] = [codes['reset']]

        def qualify_int(i):
            if isinstance(i, int):
                return i % 256  # set i to base element of its equivalence class

        def qualify_triple_int(t):
            if isinstance(t, (list, tuple)) and len(t) == 3:
                return qualify_int(t[0]), qualify_int(t[1]), qualify_int(t[2])

        if kwargs.get('x', None) is not None:
            self.codes.extend((codes['extended'], '5', qualify_int(kwargs['x'])))
        elif kwargs.get('rgb', None) is not None:
            self.codes.extend((codes['extended'], '2'))
            self.codes.extend(*qualify_triple_int(kwargs['rgb']))

        if kwargs.get('bg_x', None) is not None:
            self.codes.extend((codes['extended'], '5', qualify_int(kwargs['bg_x'])))
        elif kwargs.get('bg_rgb', None) is not None:
            self.codes.extend((codes['extended'], '2'))
            self.codes.extend(*qualify_triple_int(kwargs['bg_rgb']))

        self.sequence = '%s%s%s' % (graph_prefix,  # pylint: disable=E1321
                                    ';'.join(self.codes),
                                    graph_suffix)
Validate DocType before saving.
dataset/ETHPy150Open saltstack/salt/salt/textformat.py/TextFormat.__init__--crossover with--dataset/ETHPy150Open frappe/frappe/frappe/core/doctype/doctype/doctype.py/DocType.validate