def __init__( self, name: str, domain: Domain, color: Optional[Color] = None, hotkey: str = "", creation_date: Optional[datetime.datetime] = None, is_empty: bool = False, id: Optional[ID] = None, ): id = ID() if id is None else id color = Color.random() if color is None else color creation_date = now() if creation_date is None else creation_date if not hotkey and is_empty: hotkey = "ctrl+0" self._name = name self._color = color self._hotkey = hotkey self._domain = domain self._is_empty = is_empty self._creation_date = creation_date self._id = id
def new_label_by_name(self, name: str) -> LabelEntity: label = LabelEntity(name=name, color=Color.random(), domain=self.label_domain) label.id = generate_unique_id() return label