mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
added image sequence collector
This commit is contained in:
parent
25d60b8562
commit
84ef2926ae
2 changed files with 71 additions and 0 deletions
57
colorbleed/plugins/publish/collect_imagesequences.py
Normal file
57
colorbleed/plugins/publish/collect_imagesequences.py
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import pyblish.api
|
||||
|
||||
|
||||
class CollectMindbenderImageSequences(pyblish.api.ContextPlugin):
|
||||
"""Gather image sequnences from working directory"""
|
||||
|
||||
order = pyblish.api.CollectorOrder
|
||||
hosts = ["shell"]
|
||||
label = "Image Sequences"
|
||||
|
||||
def process(self, context):
|
||||
import os
|
||||
import json
|
||||
from avalon.vendor import clique
|
||||
|
||||
workspace = context.data["workspaceDir"]
|
||||
|
||||
base, dirs, _ = next(os.walk(workspace))
|
||||
for renderlayer in dirs:
|
||||
abspath = os.path.join(base, renderlayer)
|
||||
files = os.listdir(abspath)
|
||||
collections, remainder = clique.assemble(files, minimum_items=1)
|
||||
assert not remainder, (
|
||||
"There shouldn't have been a remainder for '%s': "
|
||||
"%s" % (renderlayer, remainder))
|
||||
|
||||
# Maya 2017 compatibility, it inexplicably prefixes layers
|
||||
# with "rs_" without warning.
|
||||
compatpath = os.path.join(base, renderlayer.split("rs_", 1)[-1])
|
||||
|
||||
for fname in (abspath, compatpath):
|
||||
try:
|
||||
with open(fname + ".json") as f:
|
||||
metadata = json.load(f)
|
||||
break
|
||||
|
||||
except OSError:
|
||||
continue
|
||||
|
||||
else:
|
||||
raise Exception("%s was not published correctly "
|
||||
"(missing metadata)" % renderlayer)
|
||||
|
||||
for collection in collections:
|
||||
instance = context.create_instance(str(collection))
|
||||
|
||||
data = dict(metadata["instance"], **{
|
||||
"name": instance.name,
|
||||
"family": "Image Sequences",
|
||||
"families": ["colorbleed.imagesequence"],
|
||||
"subset": collection.head[:-1],
|
||||
"stagingDir": os.path.join(workspace, renderlayer),
|
||||
"files": [list(collection)],
|
||||
"metadata": metadata
|
||||
})
|
||||
|
||||
instance.data.update(data)
|
||||
14
colorbleed/plugins/publish/collect_shell_workspace.py
Normal file
14
colorbleed/plugins/publish/collect_shell_workspace.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import os
|
||||
import pyblish.api
|
||||
|
||||
|
||||
class CollectShellWorkspace(pyblish.api.ContextPlugin):
|
||||
"""Inject the current workspace into context"""
|
||||
|
||||
order = pyblish.api.CollectorOrder - 0.5
|
||||
label = "Shell Workspace"
|
||||
|
||||
hosts = ["shell"]
|
||||
|
||||
def process(self, context):
|
||||
context.data["workspaceDir"] = os.getcwd()
|
||||
Loading…
Add table
Add a link
Reference in a new issue