From 0f7db69eb5ce55a3d160e78b0261d4dc253c0da4 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Mon, 4 Mar 2024 22:41:35 +0200 Subject: [PATCH] move create_file_list to Houdini's lib --- client/ayon_core/hosts/houdini/api/lib.py | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/client/ayon_core/hosts/houdini/api/lib.py b/client/ayon_core/hosts/houdini/api/lib.py index da1b21ad95..cca19cbcf5 100644 --- a/client/ayon_core/hosts/houdini/api/lib.py +++ b/client/ayon_core/hosts/houdini/api/lib.py @@ -1156,3 +1156,39 @@ def prompt_reset_context(): update_content_on_context_change() dialog.deleteLater() + + +def create_file_list(match, start_frame, end_frame): + """Collect files based on frame range and `regex.match` + + Args: + match(re.match): match object + start_frame(int): start of the animation + end_frame(int): end of the animation + + Returns: + list + + """ + + # Get the padding length + frame = match.group(1) + padding = len(frame) + + # Get the parts of the filename surrounding the frame number, + # so we can put our own frame numbers in. + span = match.span(1) + prefix = match.string[: span[0]] + suffix = match.string[span[1]:] + + # Generate filenames for all frames + result = [] + for i in range(start_frame, end_frame + 1): + + # Format frame number by the padding amount + str_frame = "{number:0{width}d}".format(number=i, width=padding) + + file_name = prefix + str_frame + suffix + result.append(file_name) + + return result