rename 'get_current_asset_name' to 'get_current_folder_path'

This commit is contained in:
Jakub Trllo 2024-02-29 18:11:19 +01:00
parent 505691b9ad
commit 0664da2a5e
41 changed files with 85 additions and 88 deletions

View file

@ -108,7 +108,7 @@ class HostBase(object):
return os.environ.get("AYON_PROJECT_NAME")
def get_current_asset_name(self):
def get_current_folder_path(self):
"""
Returns:
Union[str, None]: Current asset name.
@ -139,7 +139,7 @@ class HostBase(object):
return {
"project_name": self.get_current_project_name(),
"folder_path": self.get_current_asset_name(),
"folder_path": self.get_current_folder_path(),
"task_name": self.get_current_task_name()
}

View file

@ -39,7 +39,7 @@ class AEWorkfileCreator(AutoCreator):
context = self.create_context
project_name = context.get_current_project_name()
asset_name = context.get_current_asset_name()
asset_name = context.get_current_folder_path()
task_name = context.get_current_task_name()
host_name = context.host_name

View file

@ -1,6 +1,6 @@
import pyblish.api
from ayon_core.pipeline import get_current_asset_name
from ayon_core.pipeline import get_current_folder_path
from ayon_core.pipeline.publish import (
ValidateContentsOrder,
PublishXmlValidationError,
@ -30,7 +30,7 @@ class ValidateInstanceAssetRepair(pyblish.api.Action):
for instance in instances:
data = stub.read(instance[0])
data["folderPath"] = get_current_asset_name()
data["folderPath"] = get_current_folder_path()
stub.imprint(instance[0].instance_id, data)
@ -54,7 +54,7 @@ class ValidateInstanceAsset(pyblish.api.InstancePlugin):
def process(self, instance):
instance_asset = instance.data["folderPath"]
current_asset = get_current_asset_name()
current_asset = get_current_folder_path()
msg = (
f"Instance asset {instance_asset} is not the same "
f"as current context {current_asset}."

View file

@ -16,7 +16,7 @@ import bpy
import bpy.utils.previews
from ayon_core import style
from ayon_core.pipeline import get_current_asset_name, get_current_task_name
from ayon_core.pipeline import get_current_folder_path, get_current_task_name
from ayon_core.tools.utils import host_tools
from .workio import OpenFileCacher
@ -388,7 +388,7 @@ class TOPBAR_MT_avalon(bpy.types.Menu):
else:
pyblish_menu_icon_id = 0
asset = get_current_asset_name()
asset = get_current_folder_path()
task = get_current_task_name()
context_label = f"{asset}, {task}"
context_label_item = layout.row()

View file

@ -20,7 +20,7 @@ from ayon_core.client import get_asset_by_name
from ayon_core.pipeline import (
schema,
get_current_project_name,
get_current_asset_name,
get_current_folder_path,
register_loader_plugin_path,
register_creator_plugin_path,
deregister_loader_plugin_path,
@ -223,7 +223,7 @@ def message_window(title, message):
def get_asset_data():
project_name = get_current_project_name()
asset_name = get_current_asset_name()
asset_name = get_current_folder_path()
asset_doc = get_asset_by_name(project_name, asset_name)
return asset_doc.get("data")

View file

@ -33,7 +33,7 @@ class CreateWorkfile(BaseCreator, AutoCreator):
)
project_name = self.project_name
asset_name = self.create_context.get_current_asset_name()
asset_name = self.create_context.get_current_folder_path()
task_name = self.create_context.get_current_task_name()
host_name = self.create_context.host_name

View file

@ -13,7 +13,7 @@ from ayon_core.hosts.fusion.api.lib import (
set_asset_framerange,
set_asset_resolution,
)
from ayon_core.pipeline import get_current_asset_name
from ayon_core.pipeline import get_current_folder_path
from ayon_core.resources import get_ayon_icon_filepath
from ayon_core.tools.utils import get_qt_app
@ -131,7 +131,7 @@ class OpenPypeMenu(QtWidgets.QWidget):
def on_task_changed(self):
# Update current context label
label = get_current_asset_name()
label = get_current_folder_path()
self.asset_label.setText(label)
def register_callback(self, name, fn):

View file

@ -67,7 +67,7 @@ class FusionWorkfileCreator(AutoCreator):
break
project_name = self.create_context.get_current_project_name()
asset_name = self.create_context.get_current_asset_name()
asset_name = self.create_context.get_current_folder_path()
task_name = self.create_context.get_current_task_name()
host_name = self.create_context.host_name

View file

@ -1,7 +1,7 @@
import pyblish.api
import ayon_core.hosts.harmony.api as harmony
from ayon_core.pipeline import get_current_asset_name
from ayon_core.pipeline import get_current_folder_path
from ayon_core.pipeline.publish import (
ValidateContentsOrder,
PublishXmlValidationError,
@ -27,7 +27,7 @@ class ValidateInstanceRepair(pyblish.api.Action):
# Apply pyblish.logic to get the instances for the plug-in
instances = pyblish.api.instances_by_plugin(failed, plugin)
folder_path = get_current_asset_name()
folder_path = get_current_folder_path()
for instance in instances:
data = harmony.read(instance.data["setMembers"][0])
data["folderPath"] = folder_path
@ -44,7 +44,7 @@ class ValidateInstance(pyblish.api.InstancePlugin):
def process(self, instance):
instance_asset = instance.data["folderPath"]
current_asset = get_current_asset_name()
current_asset = get_current_folder_path()
msg = (
"Instance asset is not the same as current asset:"
f"\nInstance: {instance_asset}\nCurrent: {current_asset}"

View file

@ -11,7 +11,7 @@ from ayon_core.tools.utils import host_tools
from ayon_core.settings import get_project_settings
from ayon_core.pipeline import (
get_current_project_name,
get_current_asset_name,
get_current_folder_path,
get_current_task_name
)
@ -25,7 +25,7 @@ self._change_context_menu = None
def get_context_label():
return "{}, {}".format(
get_current_asset_name(),
get_current_folder_path(),
get_current_task_name()
)

View file

@ -94,7 +94,7 @@ def create_interactive(creator_identifier, **kwargs):
project_name=context.get_current_project_name(),
asset_doc=get_asset_by_name(
project_name=context.get_current_project_name(),
asset_name=context.get_current_asset_name()
asset_name=context.get_current_folder_path()
),
task_name=context.get_current_task_name(),
variant=variant,

View file

@ -17,7 +17,7 @@ from ayon_core.settings import get_current_project_settings
from ayon_core.pipeline import (
Anatomy,
get_current_project_name,
get_current_asset_name,
get_current_folder_path,
registered_host,
get_current_context,
get_current_host_name,
@ -97,7 +97,7 @@ def generate_ids(nodes, asset_id=None):
if asset_id is None:
project_name = get_current_project_name()
asset_name = get_current_asset_name()
asset_name = get_current_folder_path()
# Get the asset ID from the database for the asset of current context
asset_doc = get_asset_by_name(project_name, asset_name, fields=["_id"])
@ -531,7 +531,7 @@ def reset_framerange():
# Get asset data
project_name = get_current_project_name()
asset_name = get_current_asset_name()
asset_name = get_current_folder_path()
# Get the asset ID from the database for the asset of current context
asset_doc = get_asset_by_name(project_name, asset_name)
asset_data = asset_doc["data"]

View file

@ -26,7 +26,7 @@ class CreateWorkfile(plugin.HoudiniCreatorBase, AutoCreator):
), None)
project_name = self.project_name
asset_name = self.create_context.get_current_asset_name()
asset_name = self.create_context.get_current_folder_path()
task_name = self.create_context.get_current_task_name()
host_name = self.host_name

View file

@ -8,8 +8,8 @@ return os.environ.get("AYON_MENU_LABEL") or "AYON"
]]></labelExpression>
<actionItem id="asset_name">
<labelExpression><![CDATA[
from ayon_core.pipeline import get_current_asset_name, get_current_task_name
label = "{}, {}".format(get_current_asset_name(), get_current_task_name())
from ayon_core.pipeline import get_current_folder_path, get_current_task_name
label = "{}, {}".format(get_current_folder_path(), get_current_task_name())
return label
]]></labelExpression>
</actionItem>

View file

@ -24,7 +24,7 @@ class CreateWorkfile(plugin.MaxCreatorBase, AutoCreator):
if instance.creator_identifier == self.identifier
), None)
project_name = self.project_name
asset_name = self.create_context.get_current_asset_name()
asset_name = self.create_context.get_current_folder_path()
task_name = self.create_context.get_current_task_name()
host_name = self.create_context.host_name

View file

@ -5,7 +5,7 @@ from maya import cmds
from ayon_api import get_project
from ayon_core.client import get_asset_by_name
from ayon_core.pipeline import get_current_project_name, get_current_asset_name
from ayon_core.pipeline import get_current_project_name, get_current_folder_path
class ToolWindows:
@ -75,7 +75,7 @@ def reset_resolution():
# Get resolution from asset
project_name = get_current_project_name()
asset_name = get_current_asset_name()
asset_name = get_current_folder_path()
asset_doc = get_asset_by_name(project_name, asset_name)
resolution = _resolution_from_document(asset_doc)
# Try get resolution from project

View file

@ -31,7 +31,7 @@ from ayon_core.client import (
from ayon_core.settings import get_project_settings
from ayon_core.pipeline import (
get_current_project_name,
get_current_asset_name,
get_current_folder_path,
get_current_task_name,
discover_loader_plugins,
loaders_from_representation,
@ -1668,7 +1668,7 @@ def generate_ids(nodes, asset_id=None):
if asset_id is None:
# Get the asset ID from the database for the asset of current context
project_name = get_current_project_name()
asset_name = get_current_asset_name()
asset_name = get_current_folder_path()
asset_doc = get_asset_by_name(project_name, asset_name, fields=["_id"])
assert asset_doc, "No current asset found in Session"
asset_id = asset_doc['_id']
@ -2499,7 +2499,7 @@ def get_fps_for_current_context():
"""
project_name = get_current_project_name()
asset_name = get_current_asset_name()
asset_name = get_current_folder_path()
asset_doc = get_asset_by_name(
project_name, asset_name, fields=["data.fps"]
) or {}
@ -2531,7 +2531,7 @@ def get_frame_range(include_animation_range=False):
# Set frame start/end
project_name = get_current_project_name()
asset_name = get_current_asset_name()
asset_name = get_current_folder_path()
asset = get_asset_by_name(project_name, asset_name)
frame_start = asset["data"].get("frameStart")

View file

@ -8,7 +8,7 @@ import maya.utils
import maya.cmds as cmds
from ayon_core.pipeline import (
get_current_asset_name,
get_current_folder_path,
get_current_task_name,
registered_host
)
@ -43,7 +43,7 @@ def _get_menu(menu_name=None):
def get_context_label():
return "{}, {}".format(
get_current_asset_name(),
get_current_folder_path(),
get_current_task_name()
)

View file

@ -454,7 +454,7 @@ class RenderlayerCreator(NewCreator, MayaCreatorBase):
# this instance will not have the `instance_node` data yet
# until it's been saved/persisted at least once.
project_name = self.create_context.get_current_project_name()
asset_name = self.create_context.get_current_asset_name()
asset_name = self.create_context.get_current_folder_path()
instance_data = {
"folderPath": asset_name,
"task": self.create_context.get_current_task_name(),

View file

@ -4,7 +4,7 @@ from maya import cmds
from ayon_core.pipeline import (
registered_host,
get_current_asset_name,
get_current_folder_path,
AYON_INSTANCE_ID,
AVALON_INSTANCE_ID,
)
@ -74,7 +74,7 @@ class MayaTemplateBuilder(AbstractTemplateBuilder):
return True
# update imported sets information
asset_name = get_current_asset_name()
asset_name = get_current_folder_path()
for node in imported_sets:
if not cmds.attributeQuery("id", node=node, exists=True):
continue

View file

@ -10,7 +10,7 @@ from ayon_core.hosts.maya.api import plugin
from ayon_core.lib import BoolDef, EnumDef, TextDef
from ayon_core.pipeline import (
Creator,
get_current_asset_name,
get_current_folder_path,
get_current_project_name,
)
from ayon_core.pipeline.create import CreatorError
@ -45,7 +45,7 @@ class CreateMultishotLayout(plugin.MayaCreator):
"""
project_name = get_current_project_name()
folder_path = get_current_asset_name()
folder_path = get_current_folder_path()
if "/" in folder_path:
current_folder = get_folder_by_path(project_name, folder_path)
else:

View file

@ -25,7 +25,7 @@ class CreateWorkfile(plugin.MayaCreatorBase, AutoCreator):
), None)
project_name = self.project_name
asset_name = self.create_context.get_current_asset_name()
asset_name = self.create_context.get_current_folder_path()
task_name = self.create_context.get_current_task_name()
host_name = self.create_context.host_name

View file

@ -44,7 +44,7 @@ from ayon_core.pipeline import (
Anatomy,
get_current_host_name,
get_current_project_name,
get_current_asset_name,
get_current_folder_path,
AYON_INSTANCE_ID,
AVALON_INSTANCE_ID,
)
@ -1462,7 +1462,7 @@ class WorkfileSettings(object):
Context._project_entity = project_entity
self._project_name = project_name
self._asset = get_current_asset_name()
self._asset = get_current_folder_path()
self._asset_entity = get_asset_by_name(project_name, self._asset)
self._root_node = root_node or nuke.root()
self._nodes = self.get_nodes(nodes=nodes)
@ -2108,7 +2108,7 @@ Reopening Nuke should synchronize these paths and resolve any discrepancies.
from .utils import set_context_favorites
work_dir = os.getenv("AYON_WORKDIR")
asset = get_current_asset_name()
asset = get_current_folder_path()
favorite_items = OrderedDict()
# project

View file

@ -21,7 +21,7 @@ from ayon_core.pipeline import (
AYON_INSTANCE_ID,
AVALON_INSTANCE_ID,
AVALON_CONTAINER_ID,
get_current_asset_name,
get_current_folder_path,
get_current_task_name,
registered_host,
)
@ -224,7 +224,7 @@ def _show_workfiles():
def get_context_label():
return "{0}, {1}".format(
get_current_asset_name(),
get_current_folder_path(),
get_current_task_name()
)

View file

@ -27,7 +27,7 @@ class WorkfileCreator(AutoCreator):
)
project_name = self.create_context.get_current_project_name()
asset_name = self.create_context.get_current_asset_name()
asset_name = self.create_context.get_current_folder_path()
task_name = self.create_context.get_current_task_name()
host_name = self.create_context.host_name

View file

@ -40,7 +40,7 @@ class PSAutoCreator(AutoCreator):
context = self.create_context
project_name = context.get_current_project_name()
asset_name = context.get_current_asset_name()
asset_name = context.get_current_folder_path()
task_name = context.get_current_task_name()
host_name = context.host_name

View file

@ -32,7 +32,7 @@ class AutoImageCreator(PSAutoCreator):
context = self.create_context
project_name = context.get_current_project_name()
asset_name = context.get_current_asset_name()
asset_name = context.get_current_folder_path()
task_name = context.get_current_task_name()
host_name = context.host_name
asset_doc = get_asset_by_name(project_name, asset_name)

View file

@ -1,6 +1,6 @@
import pyblish.api
from ayon_core.pipeline import get_current_asset_name
from ayon_core.pipeline import get_current_folder_path
from ayon_core.pipeline.publish import (
ValidateContentsOrder,
PublishXmlValidationError,
@ -28,7 +28,7 @@ class ValidateInstanceAssetRepair(pyblish.api.Action):
# Apply pyblish.logic to get the instances for the plug-in
instances = pyblish.api.instances_by_plugin(failed, plugin)
stub = photoshop.stub()
current_asset_name = get_current_asset_name()
current_asset_name = get_current_folder_path()
for instance in instances:
data = stub.read(instance[0])
data["folderPath"] = current_asset_name
@ -55,7 +55,7 @@ class ValidateInstanceAsset(OptionalPyblishPluginMixin,
def process(self, instance):
instance_asset = instance.data["folderPath"]
current_asset = get_current_asset_name()
current_asset = get_current_folder_path()
if instance_asset != current_asset:
msg = (

View file

@ -1,7 +1,7 @@
import pyblish.api
from pprint import pformat
from ayon_core.pipeline import get_current_asset_name
from ayon_core.pipeline import get_current_folder_path
from ayon_core.hosts.resolve import api as rapi
from ayon_core.hosts.resolve.otio import davinci_export
@ -14,7 +14,7 @@ class PrecollectWorkfile(pyblish.api.ContextPlugin):
order = pyblish.api.CollectorOrder - 0.5
def process(self, context):
current_asset_name = get_current_asset_name()
current_asset_name = get_current_folder_path()
asset_name = current_asset_name.split("/")[-1]
product_name = "workfileMain"

View file

@ -250,8 +250,8 @@ class SubstanceHost(HostBase, IWorkfileHost, ILoadHost, IPublishHost):
has_formatting_entries = any("{" in item["value"] for item in shelves)
if has_formatting_entries:
project_name = self.get_current_project_name()
asset_name = self.get_current_asset_name()
task_name = self.get_current_asset_name()
asset_name = self.get_current_folder_path()
task_name = self.get_current_task_name()
project_settings = get_project_settings(project_name)
formatting_data = get_template_data_with_names(
project_name, asset_name, task_name, project_settings

View file

@ -1069,7 +1069,7 @@ class TVPaintSceneRenderCreator(TVPaintAutoCreator):
create_context = self.create_context
host_name = create_context.host_name
project_name = create_context.get_current_project_name()
asset_name = create_context.get_current_asset_name()
asset_name = create_context.get_current_folder_path()
task_name = create_context.get_current_task_name()
asset_doc = get_asset_by_name(project_name, asset_name)
@ -1118,7 +1118,7 @@ class TVPaintSceneRenderCreator(TVPaintAutoCreator):
create_context = self.create_context
host_name = create_context.host_name
project_name = create_context.get_current_project_name()
asset_name = create_context.get_current_asset_name()
asset_name = create_context.get_current_folder_path()
task_name = create_context.get_current_task_name()
existing_name = existing_instance.get("folderPath")

View file

@ -94,7 +94,7 @@ from .context_tools import (
get_current_context,
get_current_host_name,
get_current_project_name,
get_current_asset_name,
get_current_folder_path,
get_current_task_name
)
install = install_host
@ -195,7 +195,7 @@ __all__ = (
"get_current_context",
"get_current_host_name",
"get_current_project_name",
"get_current_asset_name",
"get_current_folder_path",
"get_current_task_name",
# Backwards compatible function names

View file

@ -385,10 +385,10 @@ def get_current_project_name():
return get_global_context()["project_name"]
def get_current_asset_name():
def get_current_folder_path():
host = registered_host()
if isinstance(host, HostBase):
return host.get_current_asset_name()
return host.get_current_folder_path()
return get_global_context()["folder_path"]
@ -439,7 +439,7 @@ def get_current_project_asset(asset_name=None, asset_id=None, fields=None):
return get_asset_by_id(project_name, asset_id, fields=fields)
if not asset_name:
asset_name = get_current_asset_name()
asset_name = get_current_folder_path()
# Skip if is not set even on context
if not asset_name:
return None

View file

@ -1402,7 +1402,7 @@ class CreateContext:
).format(joined_methods))
self._current_project_name = None
self._current_asset_name = None
self._current_folder_path = None
self._current_task_name = None
self._current_workfile_path = None
@ -1557,14 +1557,14 @@ class CreateContext:
return self._current_project_name
def get_current_asset_name(self):
def get_current_folder_path(self):
"""Asset name which was used as current context on context reset.
Returns:
Union[str, None]: Asset name.
"""
return self._current_asset_name
return self._current_folder_path
def get_current_task_name(self):
"""Task name which was used as current context on context reset.
@ -1612,7 +1612,7 @@ class CreateContext:
)
return (
self._current_project_name != project_name
or self._current_asset_name != asset_name
or self._current_folder_path != asset_name
or self._current_task_name != task_name
or self._current_workfile_path != workfile_path
)
@ -1718,7 +1718,7 @@ class CreateContext:
)
self._current_project_name = project_name
self._current_asset_name = asset_name
self._current_folder_path = asset_name
self._current_task_name = task_name
self._current_workfile_path = workfile_path

View file

@ -102,7 +102,7 @@ class BuildWorkfile:
from ayon_core.pipeline.context_tools import (
get_current_project_name,
get_current_asset_name,
get_current_folder_path,
get_current_task_name,
)
@ -110,7 +110,7 @@ class BuildWorkfile:
# Get current asset name and entity
project_name = get_current_project_name()
current_folder_path = get_current_asset_name()
current_folder_path = get_current_folder_path()
current_asset_doc = get_asset_by_name(
project_name, current_folder_path
)

View file

@ -128,9 +128,9 @@ class AbstractTemplateBuilder(object):
return os.getenv("AYON_PROJECT_NAME")
@property
def current_asset_name(self):
def current_folder_path(self):
if isinstance(self._host, HostBase):
return self._host.get_current_asset_name()
return self._host.get_current_folder_path()
return os.getenv("AYON_FOLDER_PATH")
@property
@ -144,7 +144,7 @@ class AbstractTemplateBuilder(object):
return self._host.get_current_context()
return {
"project_name": self.project_name,
"folder_path": self.current_asset_name,
"folder_path": self.current_folder_path,
"task_name": self.current_task_name
}
@ -158,7 +158,7 @@ class AbstractTemplateBuilder(object):
def current_asset_doc(self):
if self._current_asset_doc is None:
self._current_asset_doc = get_asset_by_name(
self.project_name, self.current_asset_name
self.project_name, self.current_folder_path
)
return self._current_asset_doc

View file

@ -53,7 +53,7 @@ class CollectFromCreateContext(pyblish.api.ContextPlugin):
context.data.update(create_context.context_data_to_store())
context.data["newPublishing"] = True
# Update context data
asset_name = create_context.get_current_asset_name()
asset_name = create_context.get_current_folder_path()
task_name = create_context.get_current_task_name()
for key, value in (
("AYON_PROJECT_NAME", project_name),

View file

@ -10,7 +10,7 @@ from ayon_core.settings import get_current_project_settings
from ayon_core.tools.utils.lib import qt_app_context
from ayon_core.pipeline import (
get_current_project_name,
get_current_asset_name,
get_current_folder_path,
get_current_task_name,
)
from ayon_core.pipeline.create import (
@ -372,7 +372,7 @@ class CreatorWindow(QtWidgets.QDialog):
self.setStyleSheet(style.load_stylesheet())
def refresh(self):
self._folder_path_input.setText(get_current_asset_name())
self._folder_path_input.setText(get_current_folder_path())
self._creators_model.reset()

View file

@ -1673,7 +1673,7 @@ class PublisherController(BasePublisherController):
Union[str, None]: Folder path or None if folder is not set.
"""
return self._create_context.get_current_asset_name()
return self._create_context.get_current_folder_path()
@property
def current_task_name(self):

View file

@ -521,7 +521,7 @@ class _AssetsWidget(QtWidgets.QWidget):
self._last_btns_height = None
self._current_asset_name = None
self._current_folder_path = None
self.model_selection = {}
@ -536,7 +536,7 @@ class _AssetsWidget(QtWidgets.QWidget):
self._model.set_project_name(project_name, refresh)
def set_current_asset_name(self, asset_name):
self._current_asset_name = asset_name
self._current_folder_path = asset_name
def _create_source_model(self):
model = _AssetModel(parent=self)
@ -560,8 +560,8 @@ class _AssetsWidget(QtWidgets.QWidget):
def stop_refresh(self):
self._model.stop_refresh()
def _get_current_asset_name(self):
return self._current_asset_name
def _get_current_folder_path(self):
return self._current_folder_path
def _on_current_asset_click(self):
"""Trigger change of asset to current context asset.
@ -572,7 +572,7 @@ class _AssetsWidget(QtWidgets.QWidget):
self.select_current_asset()
def select_current_asset(self):
asset_name = self._get_current_asset_name()
asset_name = self._get_current_folder_path()
if asset_name:
self.select_asset_by_name(asset_name)

View file

@ -7,12 +7,9 @@ import os
import pyblish.api
from ayon_core.host import IWorkfileHost, ILoadHost
from ayon_core.host import ILoadHost
from ayon_core.lib import Logger
from ayon_core.pipeline import (
registered_host,
get_current_asset_name,
)
from ayon_core.pipeline import registered_host
from .lib import qt_app_context