def add_label(self, name, color):
        """Add a new label. It's id will automatically be calculated."""
        color_upper = color.upper()
        if not self._color_re.match(color_upper):
            raise ValueError('Invalid color: {}'.format(color))

        labels_tag = self.root[0]
        last_id = int(labels_tag[-1].get('id'))
        new_id = str(last_id + 1)

        new_label = etree.Element('label', id=new_id, color=color_upper)
        new_label.text = name

        labels_tag.append(new_label)
def add_label ( self , name , color ) : color_upper = color . upper ( ) if not self . _color_re . match ( color_upper ) : raise ValueError ( 'Invalid color: {}' . format ( color ) ) labels_tag = self . root [ 0 ] last_id = int ( labels_tag [ - 1 ] . get ( 'id' ) ) new_id = str ( last_id + 1 ) new_label = etree . Element ( 'label' , id = new_id , color = color_upper ) new_label . text = name labels_tag . append ( new_label )
Add a new label. It's id will automatically be calculated.