2025-07-01
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
"""
|
||||
Copyright (C) 2023 Adobe.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
# file: sbsar/manager.py
|
||||
# brief: Substance operations manager
|
||||
# author Adobe - 3D & Immersive
|
||||
# copyright 2023 Adobe Inc. All rights reserved.
|
||||
|
||||
|
||||
import traceback
|
||||
|
||||
from ..factory.sbsar import SUBSTANCE_SbsarFactory
|
||||
from ..common import Code_Response
|
||||
from ..utils import SUBSTANCE_Utils
|
||||
|
||||
|
||||
class SUBSTANCE_SbsarManager():
|
||||
def __init__(self):
|
||||
self.sbsars = {}
|
||||
|
||||
def get(self, uuid):
|
||||
if uuid not in self.sbsars:
|
||||
return None
|
||||
return self.sbsars[uuid]
|
||||
|
||||
def register(self, sbsar):
|
||||
self.sbsars[sbsar.uuid] = sbsar
|
||||
_result = SUBSTANCE_SbsarFactory.register_class(sbsar)
|
||||
return _result
|
||||
|
||||
def unregister(self, uuid):
|
||||
try:
|
||||
if uuid in self.sbsars:
|
||||
_sbsar = self.sbsars[uuid]
|
||||
for _graph in _sbsar.graphs:
|
||||
SUBSTANCE_SbsarFactory.unregister_class(_graph.inputs_class_name)
|
||||
del self.sbsars[uuid]
|
||||
return (Code_Response.success, None)
|
||||
else:
|
||||
return (Code_Response.sbsar_remove_not_found_error, None)
|
||||
except Exception:
|
||||
SUBSTANCE_Utils.log_data("ERROR", "Exception - Substance removal error:")
|
||||
SUBSTANCE_Utils.log_traceback(traceback.format_exc())
|
||||
return (Code_Response.sbsar_factory_unregister_error, None)
|
||||
Reference in New Issue
Block a user