Improvement

Cleaner way to resolve <MAYA_RESOURCES> in path.
This commit is contained in:
Toke Stuart Jepsen 2023-01-19 09:30:11 +00:00
parent 3279634dac
commit 7a7f87e861
2 changed files with 4 additions and 13 deletions

View file

@ -3474,13 +3474,10 @@ def get_color_management_preferences():
query=True, configFilePath=True
)
# Resolve environment variables in config path. "MAYA_RESOURCES" are in the
# path by default.
def _subst_with_env_value(match):
key = match.group(1)
return os.environ.get(key, "")
path = re.sub(r'<([^>]+)>', _subst_with_env_value, path)
# The OCIO config supports a custom <MAYA_RESOURCES> token.
maya_resources_token = "<MAYA_RESOURCES>"
maya_resources_path = om.MGlobal.getAbsolutePathToResources()
path = path.replace(maya_resources_token, maya_resources_path)
data["config"] = path

View file

@ -4,12 +4,6 @@ from openpype.pipeline import install_host
from openpype.hosts.maya.api import MayaHost
from maya import cmds
# MAYA_RESOURCES enviornment variable is referenced in default OCIO path but
# it's not part of the environment. Patching this so it works as expected.
if "MAYA_RESOURCES" not in os.environ:
os.environ["MAYA_RESOURCES"] = os.path.join(
os.environ["MAYA_LOCATION"], "resources"
).replace("\\", "/")
host = MayaHost()
install_host(host)