Bases: Extractor
Extract the connected nodes to the composite instance.
Source code in client/ayon_harmony/plugins/publish/extract_template.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 | class ExtractTemplate(publish.Extractor):
"""Extract the connected nodes to the composite instance."""
label = "Extract Template"
hosts = ["harmony"]
families = ["harmony.template"]
def process(self, instance):
"""Plugin entry point."""
staging_dir = self.staging_dir(instance)
filepath = os.path.join(staging_dir, "harmony", f"{instance.name}.tpl")
self.log.info(f"Outputting template to {staging_dir}")
# Export template
self.log.info(f'{instance.data["setMembers"][0]}')
harmony.export_backdrop_as_template(
instance.data["setMembers"][0], filepath
)
# Prep representation.
os.chdir(staging_dir)
shutil.make_archive(
f"{instance.name}",
"zip",
os.path.join(staging_dir, "harmony"),
)
representation = {
"name": "tpl",
"ext": "zip",
"files": f"{instance.name}.zip",
"stagingDir": staging_dir
}
self.log.info(instance.data.get("representations"))
if instance.data.get("representations"):
instance.data["representations"].extend([representation])
else:
instance.data["representations"] = [representation]
instance.data["version_name"] = "{}_{}".format(
instance.data["productName"],
instance.context.data["task"]
)
|
Plugin entry point.
Source code in client/ayon_harmony/plugins/publish/extract_template.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 | def process(self, instance):
"""Plugin entry point."""
staging_dir = self.staging_dir(instance)
filepath = os.path.join(staging_dir, "harmony", f"{instance.name}.tpl")
self.log.info(f"Outputting template to {staging_dir}")
# Export template
self.log.info(f'{instance.data["setMembers"][0]}')
harmony.export_backdrop_as_template(
instance.data["setMembers"][0], filepath
)
# Prep representation.
os.chdir(staging_dir)
shutil.make_archive(
f"{instance.name}",
"zip",
os.path.join(staging_dir, "harmony"),
)
representation = {
"name": "tpl",
"ext": "zip",
"files": f"{instance.name}.zip",
"stagingDir": staging_dir
}
self.log.info(instance.data.get("representations"))
if instance.data.get("representations"):
instance.data["representations"].extend([representation])
else:
instance.data["representations"] = [representation]
instance.data["version_name"] = "{}_{}".format(
instance.data["productName"],
instance.context.data["task"]
)
|