Skip to content

Commit

Permalink
Add plugin version to custom enum values
Browse files Browse the repository at this point in the history
CURA-10720
  • Loading branch information
casperlamboo committed Jul 25, 2023
1 parent 9acb2fa commit e48fc28
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions UM/Settings/SettingDefinition.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,19 @@ def __init__(self, key: str, container: Optional[DefinitionContainerInterface] =

self.__property_values = {} # type: Dict[str, Any]

def extend_category(self, value_id: str, value_display: str, plugin_id: Optional[str] = None) -> None:
def extend_category(self, value_id: str, value_display: str, plugin_id: Optional[str] = None,
plugin_version: Optional[str] = None) -> None:
"""Append a category to the setting.
:param value_id: :type{str} The id of the category.
:param value_display: :type{str} The display name of the category. If the display string needs to be translated, provide the translated string.
:param plugin_id: :type{Optional[str]} The id of the plugin that owns the category. Defaults to None.
:param plugin_version: :type{Optional[str]} The version of the plugin that owns the category. Defaults to None.
"""

value_id = f"{plugin_id}::{value_id}" if plugin_id else value_id
if plugin_id is not None and plugin_version is not None:
value_id = f"PLUGIN::{plugin_id}@{plugin_version}::{value_id}"
elif plugin_id is not None or plugin_version is not None:
raise ValueError("Both plugin_id and plugin_version must be provided if one of them is provided.")
self.options[value_id] = value_display

def __getattr__(self, name: str) -> Any:
Expand Down

0 comments on commit e48fc28

Please sign in to comment.