"""
This node generates compute() errors for testing purposes.
"""
import omni.graph.core as og


class OgnComputeErrorPy:
    @staticmethod
    def initialize(graph_context, node):
        attr = node.get_attribute("inputs:deprecatedInInit")

        # We would not normally deprecate an attribute this way. It would be done through the .ogn file.
        # This is just for testing purposes.
        og._internal.deprecate_attribute(attr, "Use 'dummyIn' instead.")  # noqa: PLW0212

    @staticmethod
    def compute(db) -> bool:
        db.outputs.dummyOut = db.inputs.dummyIn
        severity = db.inputs.severity

        if severity == "warning":
            db.log_warning(db.inputs.message)
        elif severity == "error":
            db.log_error(db.inputs.message)

        return not db.inputs.failCompute
