mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
renamed env key to FILESEQUENCE, added assertion of family in data, added convertion from json string to string, removed metadata from instance.data
This commit is contained in:
parent
83bf264f4a
commit
e475037f72
2 changed files with 22 additions and 12 deletions
|
|
@ -64,10 +64,10 @@ def collect(root,
|
||||||
return collections
|
return collections
|
||||||
|
|
||||||
|
|
||||||
class CollectImageSequences(pyblish.api.ContextPlugin):
|
class CollectFileSequences(pyblish.api.ContextPlugin):
|
||||||
"""Gather image sequences from working directory
|
"""Gather file sequences from working directory
|
||||||
|
|
||||||
When "IMAGESEQUENCES" environment variable is set these paths (folders or
|
When "FILESEQUENCE" environment variable is set these paths (folders or
|
||||||
.json files) are parsed for image sequences. Otherwise the current
|
.json files) are parsed for image sequences. Otherwise the current
|
||||||
working directory is searched for file sequences.
|
working directory is searched for file sequences.
|
||||||
|
|
||||||
|
|
@ -87,12 +87,12 @@ class CollectImageSequences(pyblish.api.ContextPlugin):
|
||||||
|
|
||||||
order = pyblish.api.CollectorOrder
|
order = pyblish.api.CollectorOrder
|
||||||
targets = ["imagesequence"]
|
targets = ["imagesequence"]
|
||||||
label = "Image Sequences"
|
label = "File Sequences"
|
||||||
|
|
||||||
def process(self, context):
|
def process(self, context):
|
||||||
|
|
||||||
if os.environ.get("IMAGESEQUENCES"):
|
if os.environ.get("FILESEQUENCE"):
|
||||||
paths = os.environ["IMAGESEQUENCES"].split(os.pathsep)
|
paths = os.environ["FILESEQUENCE"].split(os.pathsep)
|
||||||
else:
|
else:
|
||||||
cwd = context.get("workspaceDir", os.getcwd())
|
cwd = context.get("workspaceDir", os.getcwd())
|
||||||
paths = [cwd]
|
paths = [cwd]
|
||||||
|
|
@ -128,8 +128,14 @@ class CollectImageSequences(pyblish.api.ContextPlugin):
|
||||||
|
|
||||||
self.log.info("Collecting: {}".format(root))
|
self.log.info("Collecting: {}".format(root))
|
||||||
|
|
||||||
|
regex = data.get("regex")
|
||||||
|
if regex:
|
||||||
|
# ensure regex string is proper, json adds double slashes
|
||||||
|
regex = regex.replace("\\_", "_")
|
||||||
|
self.log.info("Decoded regex to: {}".format(regex))
|
||||||
|
|
||||||
collections = collect(root=root,
|
collections = collect(root=root,
|
||||||
regex=data.get("regex"),
|
regex=regex,
|
||||||
exclude_regex=data.get("exclude_regex"),
|
exclude_regex=data.get("exclude_regex"),
|
||||||
startFrame=data.get("startFrame"),
|
startFrame=data.get("startFrame"),
|
||||||
endFrame=data.get("endFrame"))
|
endFrame=data.get("endFrame"))
|
||||||
|
|
@ -144,6 +150,11 @@ class CollectImageSequences(pyblish.api.ContextPlugin):
|
||||||
"found sequence")
|
"found sequence")
|
||||||
raise RuntimeError("Invalid sequence")
|
raise RuntimeError("Invalid sequence")
|
||||||
|
|
||||||
|
# Get family from the data
|
||||||
|
families = data.get("families", ["colorbleed.imagesequence"])
|
||||||
|
assert isinstance(families, (list, tuple)), "Must be iterable"
|
||||||
|
assert families, "Must have at least a single family"
|
||||||
|
|
||||||
for collection in collections:
|
for collection in collections:
|
||||||
instance = context.create_instance(str(collection))
|
instance = context.create_instance(str(collection))
|
||||||
self.log.info("Collection: %s" % list(collection))
|
self.log.info("Collection: %s" % list(collection))
|
||||||
|
|
@ -161,15 +172,14 @@ class CollectImageSequences(pyblish.api.ContextPlugin):
|
||||||
|
|
||||||
instance.data.update({
|
instance.data.update({
|
||||||
"name": str(collection),
|
"name": str(collection),
|
||||||
"family": "colorbleed.imagesequence",
|
"family": families[0], # backwards compatibility / pyblish
|
||||||
"families": ["colorbleed.imagesequence"],
|
"families": list(families),
|
||||||
"subset": subset,
|
"subset": subset,
|
||||||
"asset": data.get("asset", api.Session["AVALON_ASSET"]),
|
"asset": data.get("asset", api.Session["AVALON_ASSET"]),
|
||||||
"stagingDir": root,
|
"stagingDir": root,
|
||||||
"files": [list(collection)],
|
"files": [list(collection)],
|
||||||
"startFrame": start,
|
"startFrame": start,
|
||||||
"endFrame": end,
|
"endFrame": end
|
||||||
"metadata": data.get("metadata")
|
|
||||||
})
|
})
|
||||||
instance.append(collection)
|
instance.append(collection)
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ def publish(paths, gui=False):
|
||||||
assert any(paths), "No paths found in the list"
|
assert any(paths), "No paths found in the list"
|
||||||
# Set the paths to publish for the collector if any provided
|
# Set the paths to publish for the collector if any provided
|
||||||
if paths:
|
if paths:
|
||||||
os.environ["IMAGESEQUENCES"] = os.pathsep.join(paths)
|
os.environ["FILESEQUENCE"] = os.pathsep.join(paths)
|
||||||
|
|
||||||
# Install Avalon with shell as current host
|
# Install Avalon with shell as current host
|
||||||
from avalon import api, shell
|
from avalon import api, shell
|
||||||
Loading…
Add table
Add a link
Reference in a new issue