Skip to content

Commit

Permalink
Merge pull request #45 from quadproduction/release/1.8.0
Browse files Browse the repository at this point in the history
Release/1.8.0
  • Loading branch information
BenSouchet authored Mar 26, 2024
2 parents da95e93 + be4c915 commit e3e8a0f
Show file tree
Hide file tree
Showing 13 changed files with 508 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pyblish.api


class CollectAssetFramesData(pyblish.api.ContextPlugin):
"""Collect asset frames data into context."""

order = pyblish.api.CollectorOrder - 0.099
label = "Collect Asset Frames Data"

def process(self, context):
asset_entity = context.data["assetEntity"]

if asset_entity['type'] != 'asset':
self.log.info("Given entity is not of type asset. Frames values will not be overridden.")
return

asset_entity_data = asset_entity['data']

metadata_in = asset_entity_data.get('in', None)
if metadata_in is not None:
self.log.info("'In' value found for given asset in asset entity metadatas. Will replace default frameStart value.")
context.data['frameStart'] = int(metadata_in)

metadata_out = asset_entity_data.get('out')
if metadata_out is not None:
self.log.info("'Out' value found for given asset in asset entity metadatas. Will replace default frameEnd value.")
context.data['frameEnd'] = int(metadata_out)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import bpy

import pyblish.api

import openpype.hosts.blender.api.action
from openpype.pipeline.publish import ValidateContentsOrder
from openpype.pipeline import (
PublishXmlValidationError,
OptionalPyblishPluginMixin,
)


class ValidateFrameStart(
OptionalPyblishPluginMixin,
pyblish.api.ContextPlugin):
"""Ensure frameStart is equal to the value wanted by OpenPype."""

order = ValidateContentsOrder
hosts = ["blender"]
families = ["*"]
label = "Frame Start"
actions = [openpype.hosts.blender.api.action.SelectInvalidAction]
optional = True

def process(self, context):
registered_frame_start = context.data.get('frameStart', None)
if registered_frame_start is None:
raise RuntimeError(
"Can't retrieve frame start information from OpenPype."
)
scene_frame_start = bpy.context.scene.frame_start
if registered_frame_start != scene_frame_start:
raise RuntimeError(
f"Frame start for scene ({scene_frame_start}) if different from OpenPype's frame start ({registered_frame_start}).)"
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,34 @@ def process(self, instance):
"Comment not created, review not pushed to preview."
)
return

# Skip if Publish Sequence option hasn't been enabled from creator subset.
if not instance.data.get("creator_attributes") or \
not instance.data["creator_attributes"].get("publish_sequence"):
not instance.data["creator_attributes"].get("publish_sequence"):
self.log.debug(
"Integrate Kitsu Sequence has not been enabled."
)
return

# Add review representations as preview of comment
task_id = instance.data["kitsu_task"]["id"]

for representation in instance.data.get("representations", []):
# Skip if Extract Sequence has interpreted image generation
# as review (before video concatenation) instead of a simple sequence.
if "sequence" not in representation.get("tags", []):
continue

filesnames = representation.get("files")
filenames = representation.get("files")

#if only one frame is publish, transform representation["files"] into a list qith a single element
if type(filesnames) != list:
filesnames = [filesnames]
# If only one frame force a list
if type(filenames) != list:
filenames = [filenames]

if not filesnames:
if not filenames:
self.log.warning("No files found following sequence extract.")
raise IndexError
raise IndexError

extension = representation.get("ext")
if not extension:
self.log.warning("No extension found in representation.")
Expand All @@ -57,15 +57,19 @@ def process(self, instance):
if not published_path:
self.log.warning("No publish path found in representation.")
raise IndexError

for filename in filesnames:
image_filepath = _generate_files_paths(published_path, extension, filename)

if "burnin" in representation.get("tags", []):
filenames = ["{:04d}.{}".format(index + 1, extension) for index, file in enumerate(filenames)]

for filename in filenames:
image_filepath = _rename_output_filepath(published_path, extension, filename)
gazu.task.add_preview(
task_id, comment_id, image_filepath, normalize_movie=True
)

self.log.info("{} images has been uploaded to Kitsu.".format(len(filesnames)))
self.log.info("{} images has been uploaded to Kitsu.".format(len(filenames)))


def _generate_files_paths(published_path, extension, filename):
return re.sub("\d{4}."+extension, filename, published_path)
def _rename_output_filepath(published_path, extension, filename):
# Replace frame number + extension in given filepath with new filename
return re.sub(rf"\d{4}.{extension}", filename, published_path)
Empty file.
9 changes: 9 additions & 0 deletions quad_pyblish_module/plugins/photoshop/publish/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from enum import Enum


class ColorMatches(Enum):
REF = 'grain'
UTIL = 'yellowColor'
BG = 'blue'
CH = 'red'
PNG = "violet"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>BlendMode Error</title>
<description>
## Invalid blendMode on layer or group

Layer must be in Normal blend and Groups in PassThrought.

### How to repair?

You can fix this with "repair" button on the right and press Refresh publishing button at the bottom right.
</description>
</error>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Layer Organization</title>
<description>
## Invalid Organization

Layers aren't properly organized:

- Layers must all be in ONE group
- No groups are allowed in groups

Or you have color problem of your layers, only the following are authorized:

- REF = Green
- UTIL = Yellow
- BG = Blue
- CH = Red
- PNG = Violet

### How to repair?

You can select the default layers with the "Select Layers" button on the right and correct them.
</description>

</error>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Subset name</title>
<description>
## Invalid Nomenclature

Layer name doesn't has the correct name, based on the following recommendations :
- Green layers corresponds to 'REF' and should be named :
- 'XX_REF' for groups
- 'XX_REF_[layer name]' for layers
- Yellow layers corresponds to 'UTIL' and should be named :
- 'XX_UTIL' for groups
- 'XX_UTIL_[layer name]' for layers
- Blue layers corresponds to 'BG' and should be named :
- '[layer number]_BG' for groups
- '[layer number]_BG _[layer name]' for layers
- Red layers corresponds to 'CH' and should be named :
- '[layer number]_CH' for groups
- '[layer number]_CH _[layer name]' for layers


{msg}

### How to repair?

You can fix this with "repair" button on the right and press Refresh publishing button at the bottom right.
</description>

</error>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import pyblish.api
from openpype.pipeline.publish import (
ValidateContentsOrder,
PublishXmlValidationError,
OptionalPyblishPluginMixin
)
from openpype.hosts.photoshop import api as photoshop


class ValidateBlendModeRepair(pyblish.api.Action):
"""Repair the instance asset."""

label = "Repair"
icon = "wrench"
on = "failed"

def process(self, context, plugin):

stub = photoshop.stub()
failed = context.data['transientData'][ValidateBlendMode.__name__]

for layer, info in failed.items():
stub.set_blendmode(layer_name=layer, blendMode_name=info["defaultBlendMode"])


class ValidateBlendMode(
OptionalPyblishPluginMixin,
pyblish.api.ContextPlugin
):
"""Validate if the blendMode is set properly on Layers, NORMAL, and Groups, PASSTHROUGH
"""

label = "Validate BlendMode"
hosts = ["photoshop"]
order = ValidateContentsOrder
families = ["image"]
actions = [ValidateBlendModeRepair]
optional = True
active = False

def process(self, context):

if not self.is_active(context.data):
return

PASSTHROUGH = "passThrough"
NORMAL = "normal"
returnDict = {}
msg = ""

stub = photoshop.stub()
layers = stub.get_layers()

for layer in layers:
layerDict = {}
if (layer.group and layer.blendMode != PASSTHROUGH) or (not layer.group and layer.blendMode != NORMAL):
layerDict["actualBlendMode"] = layer.blendMode
layerDict["defaultBlendMode"] = PASSTHROUGH if layer.group else NORMAL
returnDict[layer.name] = layerDict

typeStr = "Group" if layer.group else "Layer"
msg = "{}\n\n The {} {} is set to {}.".format(msg, typeStr, layer.name, layer.blendMode)

else:
continue

if returnDict:
if not context.data.get('transientData'):
context.data['transientData'] = dict()

context.data['transientData'][self.__class__.__name__] = returnDict

raise PublishXmlValidationError(self, msg)
Loading

0 comments on commit e3e8a0f

Please sign in to comment.