DeprecatedStringConstant#
- class omni.graph.tools.DeprecatedStringConstant(
- name: str,
- new_value: str | None,
- message: str,
- deprecation_level: DeprecationLevel = None,
Bases:
strClass that lets you show a warning or error when attempting to use a deprecated string constant value.
Usage:
> # Original usage of a boolean setting > MY_SETTING = "/persistent/omnigraph/mySetting" > print(f"Value of {MY_SETTING} is {carb.settings.get_settings().get(MY_SETTING)}") Value of /persistent/omnigraph/mySetting is True > # Deprecation declaration > MY_SETTING = DeprecatedStringConstant("MY_SETTING", "UNUSED", "Please delete references to it.") > print(f"Value of {MY_SETTING} is {carb.settings.get_settings().get(MY_SETTING)}") ERROR: String constant 'MY_SETTING' can no longer be used. Please delete references to it. Value of UNUSED is False
Note that the deprecation message only appears when the value is cast to a string, which is the majority of interesting cases. Any deprecation which needs to catch other manipulations of the string should use a different approach.
Methods
__init__(name, new_value, message[, ...])Construct a string constant that will print a message if it is used :param name: Name of the string constant.
- __init__(
- name: str,
- new_value: str | None,
- message: str,
- deprecation_level: DeprecationLevel = None,
Construct a string constant that will print a message if it is used :param name: Name of the string constant. Should match what was formerly exported as part of the API :param new_value: The value to return if the string is requested :param message: Message to emit if the string is used :param deprecation_level: How serious the deprecation message should be. None means use the default