fixed palette extraction for unsupported types

This commit is contained in:
Ondřej Samohel 2020-10-30 16:27:53 +01:00
parent 2f65dda892
commit 32f76e3068
No known key found for this signature in database
GPG key ID: 8A29C663C672C2B7

View file

@ -22,19 +22,28 @@ class ExtractPalette(pype.api.Extractor):
self_name = self.__class__.__name__
result = harmony.send(
{
"function": f"PypeHarmony.Publish.{self_name}",
"function": f"PypeHarmony.Publish.{self_name}.getPalette",
"args": instance.data["id"]
})["result"]
if not isinstance(result, list):
self.log.error(f"Invalid reply: {result}")
raise AssertionError("Invalid reply from server.")
palette_name = result[0]
palette_file = result[1]
self.log.info(f"Got palette named {palette_name} "
f"and file {palette_file}.")
tmp_thumb_path = os.path.join(os.path.dirname(palette_file),
os.path.basename(palette_file)
.split(".plt")[0] + "_swatches.png"
)
self.log.info(f"Temporary humbnail path {tmp_thumb_path}")
palette_version = str(instance.data.get("version")).zfill(3)
self.log.info(f"Palette version {palette_version}")
thumbnail_path = self.create_palette_thumbnail(palette_name,
palette_version,
palette_file,
@ -82,7 +91,10 @@ class ExtractPalette(pype.api.Extractor):
continue
while ("" in line):
line.remove("")
print(line)
# self.log.debug(line)
if line[0] not in ["Solid"]:
self.log.error("Unsupported palette type.")
break
color_name = line[1].strip('"')
colors[color_name] = {"type": line[0],
"uuid": line[2],