"""Support required by the Carbonite extension loader"""
import omni.ext

from ..bindings._omni_graph_io import acquire_interface as _acquire_interface  # noqa: PLE0402
from ..bindings._omni_graph_io import release_interface as _release_interface  # noqa: PLE0402


class _PublicExtension(omni.ext.IExt):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.__interface = None
        try:
            import omni.graph.ui as ogu

            ogu.ComputeNodeWidget.get_instance().add_template_path(__file__)
        except ImportError:
            pass

    def on_startup(self, ext_id):
        self.__interface = _acquire_interface()

    def on_shutdown(self):
        if self.__interface is not None:
            _release_interface(self.__interface)
            self.__interface = None
