def set_label_elements(self, wanted_label_elements):
        """
        Set one or more label elements based on
        at least one of the others
        """
        if isinstance(wanted_label_elements, str):
            wanted_label_elements = [wanted_label_elements]

        # Figure out which desired label elements are missing
        missing_elements = [e for e in wanted_label_elements if getattr(self, e) is None]

        contained_elements = [e for e in ann_label_fields if getattr(self, e )is not None]

        if not contained_elements:
            raise Exception('No annotation labels contained in object')

        for e in missing_elements:
            self.convert_label_attribute(contained_elements[0], e)

        unwanted_label_elements = list(set(ann_label_fields)
                                       - set(wanted_label_elements))

        self.rm_attributes(unwanted_label_elements)

        return
def set_label_elements ( self , wanted_label_elements ) : if isinstance ( wanted_label_elements , str ) : wanted_label_elements = [ wanted_label_elements ] missing_elements = [ e for e in wanted_label_elements if getattr ( self , e ) is None ] contained_elements = [ e for e in ann_label_fields if getattr ( self , e ) is not None ] if not contained_elements : raise Exception ( 'No annotation labels contained in object' ) for e in missing_elements : self . convert_label_attribute ( contained_elements [ 0 ] , e ) unwanted_label_elements = list ( set ( ann_label_fields ) - set ( wanted_label_elements ) ) self . rm_attributes ( unwanted_label_elements ) return
Set one or more label elements based on
        at least one of the others