mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
context title taken from host implementation
This commit is contained in:
parent
51370baa09
commit
0ec8ab8f6e
4 changed files with 50 additions and 6 deletions
|
|
@ -10,7 +10,8 @@ from .pipeline import (
|
|||
update_instances,
|
||||
remove_instances,
|
||||
get_context_data,
|
||||
update_context_data
|
||||
update_context_data,
|
||||
get_context_title
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -36,6 +37,7 @@ __all__ = (
|
|||
"remove_instances",
|
||||
"get_context_data",
|
||||
"update_context_data",
|
||||
"get_context_title",
|
||||
|
||||
"install"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,33 @@ class HostContext:
|
|||
instances_json_path = None
|
||||
context_json_path = None
|
||||
|
||||
@classmethod
|
||||
def get_context_title(cls):
|
||||
project_name = os.environ.get("AVALON_PROJECT")
|
||||
if not project_name:
|
||||
return "TestHost"
|
||||
|
||||
asset_name = os.environ.get("AVALON_ASSET")
|
||||
if not asset_name:
|
||||
return project_name
|
||||
|
||||
from avalon import io
|
||||
|
||||
asset_doc = io.find_one(
|
||||
{"type": "asset", "name": asset_name},
|
||||
{"data.parents": 1}
|
||||
)
|
||||
parents = asset_doc.get("data", {}).get("parents") or []
|
||||
|
||||
hierarchy = [project_name]
|
||||
hierarchy.extend(parents)
|
||||
hierarchy.append("<b>{}</b>".format(asset_name))
|
||||
task_name = os.environ.get("AVALON_TASK")
|
||||
if task_name:
|
||||
hierarchy.append(task_name)
|
||||
|
||||
return "/".join(hierarchy)
|
||||
|
||||
@classmethod
|
||||
def get_current_dir_filepath(cls, filename):
|
||||
return os.path.join(
|
||||
|
|
@ -124,3 +151,7 @@ def get_context_data():
|
|||
|
||||
def update_context_data(data, changes):
|
||||
HostContext.save_context_data(data)
|
||||
|
||||
|
||||
def get_context_title():
|
||||
return HostContext.get_context_title()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue