diff --git a/colorbleed/plugins/publish/collect_imagesequences.py b/colorbleed/plugins/publish/collect_filesequences.py similarity index 84% rename from colorbleed/plugins/publish/collect_imagesequences.py rename to colorbleed/plugins/publish/collect_filesequences.py index ad08a03a54..9430dbdc92 100644 --- a/colorbleed/plugins/publish/collect_imagesequences.py +++ b/colorbleed/plugins/publish/collect_filesequences.py @@ -64,10 +64,10 @@ def collect(root, return collections -class CollectImageSequences(pyblish.api.ContextPlugin): - """Gather image sequences from working directory +class CollectFileSequences(pyblish.api.ContextPlugin): + """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 working directory is searched for file sequences. @@ -87,12 +87,12 @@ class CollectImageSequences(pyblish.api.ContextPlugin): order = pyblish.api.CollectorOrder targets = ["imagesequence"] - label = "Image Sequences" + label = "File Sequences" def process(self, context): - if os.environ.get("IMAGESEQUENCES"): - paths = os.environ["IMAGESEQUENCES"].split(os.pathsep) + if os.environ.get("FILESEQUENCE"): + paths = os.environ["FILESEQUENCE"].split(os.pathsep) else: cwd = context.get("workspaceDir", os.getcwd()) paths = [cwd] @@ -128,8 +128,14 @@ class CollectImageSequences(pyblish.api.ContextPlugin): 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, - regex=data.get("regex"), + regex=regex, exclude_regex=data.get("exclude_regex"), startFrame=data.get("startFrame"), endFrame=data.get("endFrame")) @@ -144,6 +150,11 @@ class CollectImageSequences(pyblish.api.ContextPlugin): "found 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: instance = context.create_instance(str(collection)) self.log.info("Collection: %s" % list(collection)) @@ -161,15 +172,14 @@ class CollectImageSequences(pyblish.api.ContextPlugin): instance.data.update({ "name": str(collection), - "family": "colorbleed.imagesequence", - "families": ["colorbleed.imagesequence"], + "family": families[0], # backwards compatibility / pyblish + "families": list(families), "subset": subset, "asset": data.get("asset", api.Session["AVALON_ASSET"]), "stagingDir": root, "files": [list(collection)], "startFrame": start, - "endFrame": end, - "metadata": data.get("metadata") + "endFrame": end }) instance.append(collection) diff --git a/colorbleed/scripts/publish_imagesequence.py b/colorbleed/scripts/publish_filesequence.py similarity index 97% rename from colorbleed/scripts/publish_imagesequence.py rename to colorbleed/scripts/publish_filesequence.py index a3e2b00a42..b793f3a4c8 100644 --- a/colorbleed/scripts/publish_imagesequence.py +++ b/colorbleed/scripts/publish_filesequence.py @@ -28,7 +28,7 @@ def publish(paths, gui=False): assert any(paths), "No paths found in the list" # Set the paths to publish for the collector if any provided if paths: - os.environ["IMAGESEQUENCES"] = os.pathsep.join(paths) + os.environ["FILESEQUENCE"] = os.pathsep.join(paths) # Install Avalon with shell as current host from avalon import api, shell