mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
moved 'get_workdir_from_session' to context tools
This commit is contained in:
parent
02007784fa
commit
bf463afc41
5 changed files with 43 additions and 25 deletions
|
|
@ -15,7 +15,7 @@ from openpype.pipeline import (
|
|||
from openpype.lib import version_up
|
||||
from openpype.hosts.fusion import api
|
||||
from openpype.hosts.fusion.api import lib
|
||||
from openpype.lib.avalon_context import get_workdir_from_session
|
||||
from openpype.pipeline.context_tools import get_workdir_from_session
|
||||
|
||||
log = logging.getLogger("Update Slap Comp")
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from openpype.pipeline import (
|
|||
legacy_io,
|
||||
)
|
||||
from openpype.hosts.fusion import api
|
||||
from openpype.lib.avalon_context import get_workdir_from_session
|
||||
from openpype.pipeline.context_tools import get_workdir_from_session
|
||||
|
||||
log = logging.getLogger("Fusion Switch Shot")
|
||||
|
||||
|
|
|
|||
|
|
@ -554,6 +554,8 @@ def compute_session_changes(
|
|||
dict: The required changes in the Session dictionary.
|
||||
"""
|
||||
|
||||
from openpype.pipeline.context_tools import get_workdir_from_session
|
||||
|
||||
changes = dict()
|
||||
|
||||
# If no changes, return directly
|
||||
|
|
@ -600,30 +602,11 @@ def compute_session_changes(
|
|||
return changes
|
||||
|
||||
|
||||
@with_pipeline_io
|
||||
@deprecated("openpype.pipeline.context_tools.get_workdir_from_session")
|
||||
def get_workdir_from_session(session=None, template_key=None):
|
||||
from openpype.pipeline import Anatomy
|
||||
from openpype.pipeline.context_tools import get_template_data_from_session
|
||||
from openpype.pipeline.context_tools import get_workdir_from_session
|
||||
|
||||
if session is None:
|
||||
session = legacy_io.Session
|
||||
project_name = session["AVALON_PROJECT"]
|
||||
host_name = session["AVALON_APP"]
|
||||
anatomy = Anatomy(project_name)
|
||||
template_data = get_template_data_from_session(session)
|
||||
anatomy_filled = anatomy.format(template_data)
|
||||
|
||||
if not template_key:
|
||||
task_type = template_data["task"]["type"]
|
||||
template_key = get_workfile_template_key(
|
||||
task_type,
|
||||
host_name,
|
||||
project_name=project_name
|
||||
)
|
||||
path = anatomy_filled[template_key]["folder"]
|
||||
if path:
|
||||
path = os.path.normpath(path)
|
||||
return path
|
||||
return get_workdir_from_session(session, template_key)
|
||||
|
||||
|
||||
@with_pipeline_io
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ from openpype.settings import get_project_settings
|
|||
from .publish.lib import filter_pyblish_plugins
|
||||
from .anatomy import Anatomy
|
||||
from .template_data import get_template_data_with_names
|
||||
from .workfile import get_workfile_template_key
|
||||
from . import (
|
||||
legacy_io,
|
||||
register_loader_plugin_path,
|
||||
|
|
@ -377,3 +378,37 @@ def get_template_data_from_session(session=None, system_settings=None):
|
|||
return get_template_data_with_names(
|
||||
project_name, asset_name, task_name, host_name, system_settings
|
||||
)
|
||||
|
||||
|
||||
def get_workdir_from_session(session=None, template_key=None):
|
||||
"""Template data for template fill from session keys.
|
||||
|
||||
Args:
|
||||
session (Union[Dict[str, str], None]): The Session to use. If not
|
||||
provided use the currently active global Session.
|
||||
template_key (str): Prepared template key from which workdir is
|
||||
calculated.
|
||||
|
||||
Returns:
|
||||
str: Workdir path.
|
||||
"""
|
||||
|
||||
if session is None:
|
||||
session = legacy_io.Session
|
||||
project_name = session["AVALON_PROJECT"]
|
||||
host_name = session["AVALON_APP"]
|
||||
anatomy = Anatomy(project_name)
|
||||
template_data = get_template_data_from_session(session)
|
||||
anatomy_filled = anatomy.format(template_data)
|
||||
|
||||
if not template_key:
|
||||
task_type = template_data["task"]["type"]
|
||||
template_key = get_workfile_template_key(
|
||||
task_type,
|
||||
host_name,
|
||||
project_name=project_name
|
||||
)
|
||||
path = anatomy_filled[template_key]["folder"]
|
||||
if path:
|
||||
path = os.path.normpath(path)
|
||||
return path
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ from openpype.pipeline import (
|
|||
legacy_io,
|
||||
)
|
||||
|
||||
from openpype.lib.avalon_context import get_workdir_from_session
|
||||
from openpype.pipeline.context_tools import get_workdir_from_session
|
||||
|
||||
log = logging.getLogger("Update Slap Comp")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue