Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

28: Fix publish of one image, not as a sequence #31

Merged
Next Next commit
ENFORCE file extensions to be stored in lowercase everywhere
  • Loading branch information
BenSouchet committed Jan 14, 2025
commit 1766ccdbe2987d36bb159379efa0d0c2f2f3b0f4
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ repos:
- id: check-yaml
- id: check-added-large-files
- id: no-commit-to-branch
args: [ '--pattern', '^(?!((release|enhancement|feature|bugfix|hotfix|documentation|tests|local|chore)\/[\w_.-]+)$).*' ]
args: [ '--pattern', '^(?!((release|enhancement|feature|bugfix|hotfix|documentation|tests|local|chore)\/[\w_.#-]+)$).*' ]
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def process(self, instance):
format = instance.data.get("format", None)
for file_number, file_name in enumerate(instance.data["file_names"]):
_, ext = os.path.splitext(os.path.basename(file_name))
ext = ext[1:]
ext = ext[1:].lower()

first_file_path = None
files = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def process(self, instance):
"handledEnd": context.data.get("handleEnd", 1),
"representations": [
{
"name": ext.lstrip("."),
"ext": ext.lstrip("."),
"name": ext.lstrip(".").lower(),
"ext": ext.lstrip(".").lower(),
"files": filepath.name,
"stagingDir": filepath.parent,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def process(self, instance):
anatomy_data.update({
"frame": f"%0{padding}d",
"family": "render",
"representation": self.output_extension,
"ext": self.output_extension
"representation": self.output_extension.lower(),
"ext": self.output_extension.lower()
})

anatomy_filled = anatomy.format(anatomy_data)
Expand Down
4 changes: 2 additions & 2 deletions src/quadpype/hosts/flame/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ def _separate_file_head(self, basename, extension):
"""
# in case sequence file
found = re.findall(
r"(.*)[._][\d]*(?=.{})".format(extension),
r"(.*)[._][\d]*(?=.{})".format(extension.lower()),
basename,
)
if found:
Expand All @@ -904,7 +904,7 @@ def _separate_file_head(self, basename, extension):
# in case single file
name, ext = os.path.splitext(basename)

if extension == ext[1:]:
if extension.lower() == ext[1:].lower():
return name

def _separate_number(self, basename, extension):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def process(self, instance):
continue

# get all presets attributes
extension = preset_config["ext"]
extension = preset_config["ext"].lower()
preset_file = preset_config["xml_preset_file"]
preset_dir = preset_config["xml_preset_dir"]
export_type = preset_config["export_type"]
Expand Down
2 changes: 1 addition & 1 deletion src/quadpype/hosts/fusion/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _configure_saver_tool(self, data, tool, subset):
frame_padding = self.project_anatomy.templates["frame_padding"]

# get output format
ext = data["creator_attributes"]["image_format"]
ext = data["creator_attributes"]["image_format"].lower()

# Subset change detected
workdir = os.path.normpath(legacy_io.Session["AVALON_WORKDIR"])
Expand Down
4 changes: 2 additions & 2 deletions src/quadpype/hosts/fusion/plugins/publish/collect_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ def _update_for_frames(self, instance):
_, padding, ext = get_frame_path(basename)

repre = {
"name": ext[1:],
"ext": ext[1:],
"name": ext[1:].lower(),
"ext": ext[1:].lower(),
"frameStart": f"%0{padding}d" % start,
"files": [os.path.basename(f) for f in expected_files],
"stagingDir": staging_dir,
Expand Down
4 changes: 2 additions & 2 deletions src/quadpype/hosts/fusion/plugins/publish/collect_workfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def process(self, instance):
filename, ext = os.path.splitext(file)

instance.data['representations'] = [{
'name': ext.lstrip("."),
'ext': ext.lstrip("."),
'name': ext.lstrip(".").lower(),
'ext': ext.lstrip(".").lower(),
'files': file,
"stagingDir": folder,
}]
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ def _add_representation(self, instance):
files = files[0]

repre = {
"name": ext[1:],
"ext": ext[1:],
"name": ext[1:].lower(),
"ext": ext[1:].lower(),
"frameStart": f"%0{padding}d" % start,
"files": files,
"stagingDir": staging_dir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def process(self, instance):
self.log.debug(output.decode("utf-8", errors="backslashreplace"))

# Generate representations.
extension = collection.tail[1:]
extension = collection.tail[1:].lower()
representation = {
"name": extension,
"ext": extension,
Expand Down
2 changes: 1 addition & 1 deletion src/quadpype/hosts/hiero/plugins/publish/extract_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def process(self, instance):
track_item.mapTimelineToSource(frame) +
track_item.source().mediaSource().startTime()
)
output_ext = instance.data["format"]
output_ext = instance.data["format"].lower()
output_path = output_template
output_path += ".{:04d}.{}".format(int(frame), output_ext)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def process(self, instance):
})

instance.data['representations'] = [{
'name': ext.lstrip("."),
'ext': ext.lstrip("."),
'name': ext.lstrip(".").lower(),
'ext': ext.lstrip(".").lower(),
'files': file,
"stagingDir": folder,
}]
Expand Down
2 changes: 1 addition & 1 deletion src/quadpype/hosts/houdini/plugins/publish/extract_bgeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def process(self, instance):

representation = {
"name": "bgeo",
"ext": ext.lstrip("."),
"ext": ext.lstrip(".").lower(),
"files": output,
"stagingDir": staging_dir,
"frameStart": instance.data["frameStartHandle"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def process(self, instance):

output = instance.data["frames"]
_, ext = splitext(output[0], [])
ext = ext.lstrip(".")
ext = ext.lstrip(".").lower()

if "representations" not in instance.data:
instance.data["representations"] = []
Expand Down
4 changes: 2 additions & 2 deletions src/quadpype/hosts/houdini/plugins/publish/extract_opengl.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def process(self, instance):
tags.append("delete")

representation = {
"name": instance.data["imageFormat"],
"ext": instance.data["imageFormat"],
"name": instance.data["imageFormat"].lower(),
"ext": instance.data["imageFormat"].lower(),
"files": output,
"stagingDir": staging_dir,
"frameStart": instance.data["frameStartHandle"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _compare_with_latest_publish(self, project_name, dependency, new_file):
return False

representation = get_representation_by_name(
project_name, ext.lstrip("."), version["_id"]
project_name, ext.lstrip(".").lower(), version["_id"]
)
if not representation:
self.log.debug("No existing representation..")
Expand Down
4 changes: 2 additions & 2 deletions src/quadpype/hosts/max/plugins/publish/collect_workfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def process(self, instance):
})

data['representations'] = [{
'name': ext.lstrip("."),
'ext': ext.lstrip("."),
'name': ext.lstrip(".").lower(),
'ext': ext.lstrip(".").lower(),
'files': file,
"stagingDir": folder,
}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def process(self, instance):
self.log.debug("Performing Extraction ...")

representation = {
"name": instance.data["imageFormat"],
"ext": instance.data["imageFormat"],
"name": instance.data["imageFormat"].lower(),
"ext": instance.data["imageFormat"].lower(),
"files": filenames,
"stagingDir": staging_dir,
"frameStart": instance.data["frameStartHandle"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ExtractThumbnail(publish.Extractor):
families = ["review"]

def process(self, instance):
ext = instance.data.get("imageFormat")
ext = instance.data.get("imageFormat").lower()
frame = int(instance.data["frameStart"])
staging_dir = self.staging_dir(instance)
filepath = os.path.join(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_invalid(cls, instance):
instance, beauty_name)
invalid.extend(invalid_filenames)
invalid_image_format = cls.get_invalid_image_format(
instance, ext.lstrip("."))
instance, ext.lstrip(".").lower())
invalid.extend(invalid_image_format)
renderer = instance.data["renderer"]
if renderer in [
Expand Down Expand Up @@ -169,7 +169,7 @@ def get_invalid_image_format(cls, instance, ext):
invalid = []
settings = instance.context.data["project_settings"].get("max")
image_format = settings["RenderSettings"]["image_format"]
ext = ext.lstrip(".")
ext = ext.lstrip(".").lower()
if ext != image_format:
msg = (
f"Invalid image format {ext} for render outputs.\n"
Expand Down
4 changes: 2 additions & 2 deletions src/quadpype/hosts/maya/plugins/publish/collect_workfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def process(self, instance):
}

data['representations'] = [{
'name': ext.lstrip("."),
'ext': ext.lstrip("."),
'name': ext.lstrip(".").lower(),
'ext': ext.lstrip(".").lower(),
'files': file,
"stagingDir": folder,
}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def process(self, instance):
instance.data["representations"] = []

ref_representation = {
"name": self.scene_type,
"ext": self.scene_type,
"name": self.scene_type.lower(),
"ext": self.scene_type.lower(),
"files": ref_scene_name,
"stagingDir": os.path.dirname(current_name),
"outputName": "imported"
Expand Down
8 changes: 4 additions & 4 deletions src/quadpype/hosts/maya/plugins/publish/extract_look.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,16 +550,16 @@ def process(self, instance):

instance.data["representations"].append(
{
"name": self.scene_type,
"ext": self.scene_type,
"name": self.scene_type.lower(),
"ext": self.scene_type.lower(),
"files": os.path.basename(maya_fname),
"stagingDir": os.path.dirname(maya_fname),
}
)
instance.data["representations"].append(
{
"name": self.look_data_type,
"ext": self.look_data_type,
"name": self.look_data_type.lower(),
"ext": self.look_data_type.lower(),
"files": os.path.basename(json_fname),
"stagingDir": os.path.dirname(json_fname),
}
Expand Down
4 changes: 2 additions & 2 deletions src/quadpype/hosts/maya/plugins/publish/extract_playblast.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ def process(self, instance):
instance.data["representations"] = []

representation = {
"name": capture_preset["Codec"]["compression"],
"ext": capture_preset["Codec"]["compression"],
"name": capture_preset["Codec"]["compression"].lower(),
"ext": capture_preset["Codec"]["compression"].lower(),
"files": collected_files,
"stagingDir": stagingdir,
"frameStart": int(start),
Expand Down
4 changes: 2 additions & 2 deletions src/quadpype/hosts/maya/plugins/publish/extract_xgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ def process(self, instance):
instance.data["representations"].append(representation)

representation = {
"name": self.scene_type,
"ext": self.scene_type,
"name": self.scene_type.lower(),
"ext": self.scene_type.lower(),
"files": maya_filename,
"stagingDir": staging_dir
}
Expand Down
2 changes: 1 addition & 1 deletion src/quadpype/hosts/nuke/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ def create_write_node(

data.update({
"imageio_writes": imageio_writes,
"ext": ext
"ext": ext.lower()
})
anatomy_filled = format_anatomy(data)

Expand Down
2 changes: 1 addition & 1 deletion src/quadpype/hosts/nuke/plugins/load/load_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def _get_node_name(self, representation):
"asset": repre_cont["asset"],
"subset": repre_cont["subset"],
"representation": representation["name"],
"ext": repre_cont["representation"],
"ext": repre_cont["representation"].lower(),
"id": representation["_id"],
"class_name": self.__class__.__name__
}
Expand Down
2 changes: 1 addition & 1 deletion src/quadpype/hosts/nuke/plugins/load/load_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def _get_node_name(self, representation):
"asset": repre_cont["asset"],
"subset": repre_cont["subset"],
"representation": representation["name"],
"ext": repre_cont["representation"],
"ext": repre_cont["representation"].lower(),
"id": representation["_id"],
"class_name": self.__class__.__name__
}
Expand Down
2 changes: 1 addition & 1 deletion src/quadpype/hosts/nuke/plugins/load/load_ociolook.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def _create_group_node(
node = nuke.createNode("OCIOFileTransform")

# file path from lut representation
extension = ocio_item["ext"]
extension = ocio_item["ext"].lower()
item_name = ocio_item["name"]

item_lut_file = next(
Expand Down
2 changes: 1 addition & 1 deletion src/quadpype/hosts/nuke/plugins/publish/collect_reads.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def process(self, instance):
if len(items) < 2:
raise ValueError

ext = items[-1]
ext = items[-1].lower()

# Get frame range
handle_start = instance.context.data["handleStart"]
Expand Down
6 changes: 3 additions & 3 deletions src/quadpype/hosts/nuke/plugins/publish/collect_writes.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _set_additional_instance_data(
"versionData": version_data,
"path": write_file_path,
"outputDir": output_dir,
"ext": ext,
"ext": ext.lower(),
"colorspace": colorspace
})

Expand Down Expand Up @@ -262,8 +262,8 @@ def _get_existing_frames_representation(
ext = write_node["file_type"].value()

representation = {
"name": ext,
"ext": ext,
"name": ext.lower(),
"ext": ext.lower(),
"stagingDir": output_dir,
"tags": []
}
Expand Down
2 changes: 2 additions & 0 deletions src/quadpype/hosts/nuke/plugins/publish/extract_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def process(self, instance):
"Bad config for extension in presets. "
"Talk to your supervisor or pipeline admin")

extension = extension.lower()

# create file name and path
filename = subset + ".{}".format(extension)
jsonname = "{0}.json".format(instance.name)
Expand Down
2 changes: 2 additions & 0 deletions src/quadpype/hosts/nuke/plugins/publish/extract_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def process(self, instance):
"Bad config for extension in presets. "
"Talk to your supervisor or pipeline admin")

extension = extension.lower()

# create file name and path
filename = subset + ".{}".format(extension)
file_path = os.path.join(staging_dir, filename).replace("\\", "/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ExtractReviewData(publish.Extractor):

def process(self, instance):
fpath = instance.data["path"]
ext = os.path.splitext(fpath)[-1][1:]
ext = os.path.splitext(fpath)[-1][1:].lower()

representations = instance.data.get("representations", [])

Expand Down
2 changes: 1 addition & 1 deletion src/quadpype/hosts/nuke/startup/custom_write_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def process(self):
"work": os.getenv("AVALON_WORKDIR"),
"subset": write_node["name"].value(),
"frame": "#" * frame_padding,
"ext": ext
"ext": ext.lower()
}
file_path = temp_rendering_path_template.format(**data)
file_path = file_path.replace("\\", "/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def build_context_from_sources(self):
filepath = source[0]
source, ext = os.path.splitext(filepath)
source = os.path.dirname(source)
ext = ext[1:]
ext = ext[1:].lower()

context = {}
context.update(get_current_context())
Expand Down
Loading