mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
♻️ move splitext to lib
This commit is contained in:
parent
71caefe449
commit
df2f68db97
2 changed files with 30 additions and 14 deletions
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import os
|
||||
import uuid
|
||||
import logging
|
||||
from contextlib import contextmanager
|
||||
|
|
@ -556,4 +557,24 @@ def get_frame_data(node):
|
|||
data["frameEnd"] = node.evalParm("f2")
|
||||
data["steps"] = node.evalParm("f3")
|
||||
|
||||
return data
|
||||
return data
|
||||
|
||||
|
||||
def splitext(name, allowed_multidot_extensions):
|
||||
# type: (str, list) -> tuple
|
||||
"""Split file name to name and extension.
|
||||
|
||||
Args:
|
||||
name (str): File name to split.
|
||||
allowed_multidot_extensions (list of str): List of allowed multidot
|
||||
extensions.
|
||||
|
||||
Returns:
|
||||
tuple: Name and extension.
|
||||
"""
|
||||
|
||||
for ext in allowed_multidot_extensions:
|
||||
if name.endswith(ext):
|
||||
return name[:-len(ext)], ext
|
||||
|
||||
return os.path.splitext(name)
|
||||
|
|
|
|||
|
|
@ -1,19 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Collector plugin for frames data on ROP instances."""
|
||||
import os
|
||||
import re
|
||||
|
||||
import hou
|
||||
import hou # noqa
|
||||
import pyblish.api
|
||||
from openpype.hosts.houdini.api import lib
|
||||
|
||||
|
||||
def splitext(name, allowed_multidot_extensions):
|
||||
|
||||
for ext in allowed_multidot_extensions:
|
||||
if name.endswith(ext):
|
||||
return name[:-len(ext)], ext
|
||||
|
||||
return os.path.splitext(name)
|
||||
|
||||
|
||||
class CollectFrames(pyblish.api.InstancePlugin):
|
||||
"""Collect all frames which would be saved from the ROP nodes"""
|
||||
|
|
@ -40,13 +34,13 @@ class CollectFrames(pyblish.api.InstancePlugin):
|
|||
self.log.warning("Using current frame: {}".format(hou.frame()))
|
||||
output = output_parm.eval()
|
||||
|
||||
_, ext = splitext(output,
|
||||
_, ext = lib.splitext(output,
|
||||
allowed_multidot_extensions=[".ass.gz"])
|
||||
file_name = os.path.basename(output)
|
||||
result = file_name
|
||||
|
||||
# Get the filename pattern match from the output
|
||||
# path so we can compute all frames that would
|
||||
# path, so we can compute all frames that would
|
||||
# come out from rendering the ROP node if there
|
||||
# is a frame pattern in the name
|
||||
pattern = r"\w+\.(\d+)" + re.escape(ext)
|
||||
|
|
@ -65,8 +59,9 @@ class CollectFrames(pyblish.api.InstancePlugin):
|
|||
# for a custom frame list. So this should be refactored.
|
||||
instance.data.update({"frames": result})
|
||||
|
||||
def create_file_list(self, match, start_frame, end_frame):
|
||||
"""Collect files based on frame range and regex.match
|
||||
@staticmethod
|
||||
def create_file_list(match, start_frame, end_frame):
|
||||
"""Collect files based on frame range and `regex.match`
|
||||
|
||||
Args:
|
||||
match(re.match): match object
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue