write json file and store path per instance

This commit is contained in:
aardschok 2018-02-15 15:55:25 +01:00
parent e475037f72
commit c550d41f60

View file

@ -1,3 +1,7 @@
import json
import os
import re
import pyblish.api
@ -26,3 +30,32 @@ class ExtractImageSequence(pyblish.api.Extractor):
result = current_comp.Render()
if not result:
raise RuntimeError("Comp render failed")
# Write metadata json file per Saver instance
instances = [i for i in context[:] if i[0].ID == "Saver"]
for instance in instances:
subset = instance.data["subset"]
ext = instance.data["ext"]
# Regex to match resulting renders
regex = "^{subset}.*[0-9]+.{ext}+$".format(subset=re.escape(subset)
, ext=re.escape(ext))
# The instance has most of the information already stored
metadata = {
"regex": regex,
"startFrame": context.data["startFrame"],
"endFrame": context.data["endFrame"],
"families": ["colorbleed.imagesequence"],
}
# Write metadata and store the path in the instance
output_directory = instance.data["outputDir"]
path = os.path.join(output_directory,
"{}_metadata.json".format(subset))
with open(path, "w") as f:
json.dump(metadata, f)
# Store json path in instance
instance.data["jsonpath"] = path