deprecated_constant_object
- omni.graph.tools.deprecated_constant_object(constant: any, deprecation_message: str, deprecation_level: Optional[DeprecationLevel] = None)
Class that lets you show a warning or error when attempting to use a deprecated constant object.
It only works for objects as it relies on overriding the __getattr__ function, which simple values like integers and floats do not have.
- Parameters
constant – The actual value of the constant as it was before deprecation
deprecation_message – Additional message to provide the user with information of how to avoid using the constant
deprecation_level – Optional ability to hardcode the deprecation level of this particular constant
Usage:
> # Original usage of a constant > RE_FIND_HOMER = re.compile(".*D'oh") > print(RE_FIND_HOMER.match("Don't have a cow man")) None > # Deprecation declaration > RE_FIND_HOMER = deprecated_constant(re.compile(".*D'oh"), "Please delete references to it.") > print(RE_FIND_HOMER.match("Don't have a cow man")) WARNING: Constant 'RE_FIND_HOMER' is deprecated. Please delete references to it. None