Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ keys:
choices:
cc: cc
ccc: ccc
cdl: cdl
default: cc
alias: extension

Expand Down
36 changes: 30 additions & 6 deletions hooks/tk-multi-publish2/ingest/ingest_cdl_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def read_cdl(self, item):
"""
This method will check for ccc or cc files only

ccc file:
ccc / cdl file:
Validation: Checks weather file has multiple "ColorCorrection" IDs exists or not. If exists then
function will return False else returns data required to write cc file
cc file:
Expand All @@ -172,6 +172,7 @@ def read_cdl(self, item):
cc_dict = {}
file_path = item.properties["path"]
xmldoc = minidom.parse(file_path)
default_tags = ['Slope', 'Offset', 'Power', 'Saturation']

if file_path.endswith('.ccc'):
tag = xmldoc.getElementsByTagName("ColorCorrectionCollection")[0]
Expand All @@ -181,26 +182,42 @@ def read_cdl(self, item):
if len(cc_tags) > 1:
return "CCC file is invalid, because it contains multiple CC IDs..."
cc_dict['description'] = str(tag.getElementsByTagName('ColorCorrection')[0].getAttribute('id'))


elif file_path.endswith('.cdl'):
tag = xmldoc.getElementsByTagName("ColorDecisionList")[0]
cd_tag = tag.getElementsByTagName('ColorDecision')[0]
cc_tags = cd_tag.getElementsByTagName('ColorCorrection')
if len(cc_tags) > 1:
return "CDL file is invalid, because it contains multiple CC IDs..."

# check id attribute for "ColorCorrection" tag if not exists then use file name as id value
cc_tag = cc_tags[0]
if cc_tag.attributes.has_key('id'):
cc_dict['description'] = str(tag.getElementsByTagName('ColorCorrection')[0].getAttribute('id'))
else:
cc_dict['description'] = os.path.basename(file_path).split('.')[0]

default_tags.append('GUIPrinterPointOffset')

else:
line = ''
tag = xmldoc.getElementsByTagName("ColorCorrection")[0]
for e_tag in ['Slope', 'Offset', 'Power', 'Saturation']:
for e_tag in default_tags:
tag_value = tag.getElementsByTagName(e_tag)[0].childNodes[0].data
if not tag_value:
line = line + '%s missing value' % e_tag + "\n"
if line:
return line
cc_dict['description'] = str(tag.getAttribute('id'))

# if ccc file has only one 'ColorCorrection' tag then return data
for e_tag in ['Slope', 'Offset', 'Power', 'Saturation']:
# get values for common tags
for e_tag in default_tags:
cc_dict[e_tag.lower()] = str(tag.getElementsByTagName(e_tag)[0].childNodes[0].data)

return cc_dict

@staticmethod
def write_cc(cc_path, description, slope, offset, power, saturation):
def write_cc(cc_path, description, slope, offset, power, saturation, guiprinterpointoffset=None):
"""
Export the CC file to cc_path.

Expand All @@ -210,6 +227,7 @@ def write_cc(cc_path, description, slope, offset, power, saturation):
:param offset:
:param power:
:param saturation:
:param guiprinterpointoffset:
:return:
"""

Expand Down Expand Up @@ -237,6 +255,12 @@ def write_cc(cc_path, description, slope, offset, power, saturation):
info_tag = doc.createTextNode(power)
Slope_tag.appendChild(info_tag)

if guiprinterpointoffset:
Slope_tag = doc.createElement("GUIPrinterPointOffset")
SOPNode_tag.appendChild(Slope_tag)
info_tag = doc.createTextNode(guiprinterpointoffset)
Slope_tag.appendChild(info_tag)

SatNode_tag = doc.createElement("SatNode")
root.appendChild(SatNode_tag)

Expand Down