transform the files with frame hashes to the list of filenames when publishing

This commit is contained in:
Kayla Man 2023-09-26 00:41:04 +08:00
parent 0595afe8a3
commit 65bfe023c7
2 changed files with 30 additions and 1 deletions

View file

@ -3456,3 +3456,27 @@ def get_head_filename_without_hashes(original_path, name):
new_fhead = "{}.{}".format(fhead, name)
filename = filename.replace(fhead, new_fhead)
return filename
def get_filenames_without_hash(filename, frame_start, frame_end):
"""Get filenames without frame hash
i.e. "renderCompositingMain.baking.0001.exr"
Args:
filename (str): filename with frame hash
frame_start (str): start of the frame
frame_end (str): end of the frame
Returns:
filenames(list): list of filename
"""
filenames = []
for frame in range(int(frame_start), (int(frame_end) + 1)):
if "#" in filename:
# use regex to convert #### to {:0>4}
def replace(match):
return "{{:0>{}}}".format(len(match.group()))
filename_without_hashes = re.sub("#+", replace, filename)
new_filename = filename_without_hashes.format(frame)
filenames.append(new_filename)
return filenames

View file

@ -39,7 +39,8 @@ from .lib import (
get_view_process_node,
get_viewer_config_from_string,
deprecated,
get_head_filename_without_hashes
get_head_filename_without_hashes,
get_filenames_without_hash
)
from .pipeline import (
list_instances,
@ -638,6 +639,10 @@ class ExporterReview(object):
"frameStart": self.first_frame,
"frameEnd": self.last_frame,
})
if ".{}".format(self.ext) not in VIDEO_EXTENSIONS:
filenames = get_filenames_without_hash(
self.file, self.first_frame, self.last_frame)
repre["files"] = filenames
if self.multiple_presets:
repre["outputName"] = self.name