mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
added helper function to get staging dir even outside 'Extractor' plugin
This commit is contained in:
parent
dc9971fd72
commit
5203814b0e
3 changed files with 36 additions and 10 deletions
|
|
@ -21,7 +21,9 @@ from .lib import (
|
|||
get_errored_instances_from_context,
|
||||
get_errored_plugins_from_context,
|
||||
|
||||
filter_instances_for_context_plugin,
|
||||
context_plugin_should_run,
|
||||
get_instance_staging_dir,
|
||||
)
|
||||
|
||||
from .abstract_expected_files import ExpectedFiles
|
||||
|
|
@ -52,7 +54,9 @@ __all__ = (
|
|||
"get_errored_instances_from_context",
|
||||
"get_errored_plugins_from_context",
|
||||
|
||||
"filter_instances_for_context_plugin",
|
||||
"context_plugin_should_run",
|
||||
"get_instance_staging_dir",
|
||||
|
||||
"ExpectedFiles",
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import os
|
|||
import sys
|
||||
import types
|
||||
import inspect
|
||||
import tempfile
|
||||
import xml.etree.ElementTree
|
||||
|
||||
import six
|
||||
|
|
@ -420,3 +421,30 @@ def context_plugin_should_run(plugin, context):
|
|||
for instance in filter_instances_for_context_plugin(plugin, context):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def get_instance_staging_dir(instance):
|
||||
"""Unified way how staging dir is stored and created on instances.
|
||||
|
||||
First check if 'stagingDir' is already set in instance data. If there is
|
||||
not create new in tempdir.
|
||||
|
||||
Note:
|
||||
Staging dir does not have to be necessarily in tempdir so be carefull
|
||||
about it's usage.
|
||||
|
||||
Args:
|
||||
instance (pyblish.lib.Instance): Instance for which we want to get
|
||||
staging dir.
|
||||
|
||||
Returns:
|
||||
str: Path to staging dir of instance.
|
||||
"""
|
||||
|
||||
staging_dir = instance.data.get("stagingDir")
|
||||
if not staging_dir:
|
||||
instance.data["stagingDir"] = os.path.normpath(
|
||||
tempfile.mkdtemp(prefix="pyblish_tmp_")
|
||||
)
|
||||
|
||||
return staging_dir
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import tempfile
|
||||
import os
|
||||
import pyblish.api
|
||||
|
||||
ValidatePipelineOrder = pyblish.api.ValidatorOrder + 0.05
|
||||
|
|
@ -18,7 +16,8 @@ class InstancePlugin(pyblish.api.InstancePlugin):
|
|||
super(InstancePlugin, cls).process(cls, *args, **kwargs)
|
||||
|
||||
|
||||
class Extractor(InstancePlugin):
|
||||
# NOTE: This class is used on so many places I gave up moving it
|
||||
class Extractor(pyblish.api.InstancePlugin):
|
||||
"""Extractor base class.
|
||||
|
||||
The extractor base class implements a "staging_dir" function used to
|
||||
|
|
@ -36,15 +35,10 @@ class Extractor(InstancePlugin):
|
|||
Upon calling this method the staging directory is stored inside
|
||||
the instance.data['stagingDir']
|
||||
"""
|
||||
staging_dir = instance.data.get('stagingDir', None)
|
||||
|
||||
if not staging_dir:
|
||||
staging_dir = os.path.normpath(
|
||||
tempfile.mkdtemp(prefix="pyblish_tmp_")
|
||||
)
|
||||
instance.data['stagingDir'] = staging_dir
|
||||
from openpype.pipeline.publish import get_instance_staging_dir
|
||||
|
||||
return staging_dir
|
||||
return get_instance_staging_dir(instance)
|
||||
|
||||
|
||||
def contextplugin_should_run(plugin, context):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue