From 6121964dcff54eec7f7e5edc413135c005213853 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Mon, 2 Sep 2024 16:16:43 +0300 Subject: [PATCH] move houdini specific code to a method --- .../plugins/publish/extract_last_published.py | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/client/ayon_houdini/plugins/publish/extract_last_published.py b/client/ayon_houdini/plugins/publish/extract_last_published.py index 19c3658363..6c22bc7802 100644 --- a/client/ayon_houdini/plugins/publish/extract_last_published.py +++ b/client/ayon_houdini/plugins/publish/extract_last_published.py @@ -40,28 +40,7 @@ def process(self, instance): "last version published files.") return - expected_filenames = [] - staging_dir = instance.data.get("stagingDir") - expectedFiles = instance.data.get("expectedFiles", []) - - # 'expectedFiles' are preferred over 'frames' - if expectedFiles: - # Products with expected files - # This can be Render products or submitted cache to farm. - for expected in expectedFiles: - # expected.values() is a list of lists - expected_filenames.extend(sum(expected.values(), [])) - else: - # Products with frames or single file. - frames = instance.data.get("frames", "") - if isinstance(frames, str): - # single file. - expected_filenames.append("{}/{}".format(staging_dir, frames)) - else: - # list of frame. - expected_filenames.extend( - ["{}/{}".format(staging_dir, f) for f in frames] - ) + staging_dir, expected_filenames = self.get_expected_files_and_staging_dir(instance) os.makedirs(staging_dir, exist_ok=True) @@ -87,3 +66,34 @@ def process(self, instance): if frame and frame not in frames_to_fix: self.log.debug("Copying '{}' -> '{}'".format(file_path, out_path)) shutil.copy(file_path, out_path) + + + def get_expected_files_and_staging_dir(self, instance): + """ Get expected file names or frames. + + This method includes Houdini specific code. + """ + expected_filenames = [] + staging_dir = instance.data.get("stagingDir") + expectedFiles = instance.data.get("expectedFiles", []) + + # 'expectedFiles' are preferred over 'frames' + if expectedFiles: + # Products with expected files + # This can be Render products or submitted cache to farm. + for expected in expectedFiles: + # expected.values() is a list of lists + expected_filenames.extend(sum(expected.values(), [])) + else: + # Products with frames or single file. + frames = instance.data.get("frames", "") + if isinstance(frames, str): + # single file. + expected_filenames.append("{}/{}".format(staging_dir, frames)) + else: + # list of frame. + expected_filenames.extend( + ["{}/{}".format(staging_dir, f) for f in frames] + ) + + return staging_dir, expected_filenames \ No newline at end of file