mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
permit palette thumbnail creation to fail
This commit is contained in:
parent
32f76e3068
commit
d21e6541e9
1 changed files with 23 additions and 14 deletions
|
|
@ -44,17 +44,27 @@ class ExtractPalette(pype.api.Extractor):
|
||||||
|
|
||||||
self.log.info(f"Palette version {palette_version}")
|
self.log.info(f"Palette version {palette_version}")
|
||||||
|
|
||||||
thumbnail_path = self.create_palette_thumbnail(palette_name,
|
if not instance.data.get("representations"):
|
||||||
palette_version,
|
instance.data["representations"] = []
|
||||||
palette_file,
|
|
||||||
tmp_thumb_path)
|
try:
|
||||||
thumbnail = {
|
thumbnail_path = self.create_palette_thumbnail(palette_name,
|
||||||
"name": "thumbnail",
|
palette_version,
|
||||||
"ext": "png",
|
palette_file,
|
||||||
"files": os.path.basename(thumbnail_path),
|
tmp_thumb_path)
|
||||||
"stagingDir": os.path.dirname(thumbnail_path),
|
except ValueError:
|
||||||
"tags": ["thumbnail"]
|
self.log.error("Unsupported palette type for thumbnail.")
|
||||||
}
|
|
||||||
|
else:
|
||||||
|
thumbnail = {
|
||||||
|
"name": "thumbnail",
|
||||||
|
"ext": "png",
|
||||||
|
"files": os.path.basename(thumbnail_path),
|
||||||
|
"stagingDir": os.path.dirname(thumbnail_path),
|
||||||
|
"tags": ["thumbnail"]
|
||||||
|
}
|
||||||
|
|
||||||
|
instance.data["representations"].append(thumbnail)
|
||||||
|
|
||||||
representation = {
|
representation = {
|
||||||
"name": "plt",
|
"name": "plt",
|
||||||
|
|
@ -63,7 +73,7 @@ class ExtractPalette(pype.api.Extractor):
|
||||||
"stagingDir": os.path.dirname(palette_file)
|
"stagingDir": os.path.dirname(palette_file)
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.data["representations"] = [representation, thumbnail]
|
instance.data["representations"].append(representation)
|
||||||
|
|
||||||
def create_palette_thumbnail(self,
|
def create_palette_thumbnail(self,
|
||||||
palette_name,
|
palette_name,
|
||||||
|
|
@ -93,8 +103,7 @@ class ExtractPalette(pype.api.Extractor):
|
||||||
line.remove("")
|
line.remove("")
|
||||||
# self.log.debug(line)
|
# self.log.debug(line)
|
||||||
if line[0] not in ["Solid"]:
|
if line[0] not in ["Solid"]:
|
||||||
self.log.error("Unsupported palette type.")
|
raise ValueError("Unsupported palette type.")
|
||||||
break
|
|
||||||
color_name = line[1].strip('"')
|
color_name = line[1].strip('"')
|
||||||
colors[color_name] = {"type": line[0],
|
colors[color_name] = {"type": line[0],
|
||||||
"uuid": line[2],
|
"uuid": line[2],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue