mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +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 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
import logging
|
import logging
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
@ -556,4 +557,24 @@ def get_frame_data(node):
|
||||||
data["frameEnd"] = node.evalParm("f2")
|
data["frameEnd"] = node.evalParm("f2")
|
||||||
data["steps"] = node.evalParm("f3")
|
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 os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import hou
|
import hou # noqa
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
from openpype.hosts.houdini.api import lib
|
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):
|
class CollectFrames(pyblish.api.InstancePlugin):
|
||||||
"""Collect all frames which would be saved from the ROP nodes"""
|
"""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()))
|
self.log.warning("Using current frame: {}".format(hou.frame()))
|
||||||
output = output_parm.eval()
|
output = output_parm.eval()
|
||||||
|
|
||||||
_, ext = splitext(output,
|
_, ext = lib.splitext(output,
|
||||||
allowed_multidot_extensions=[".ass.gz"])
|
allowed_multidot_extensions=[".ass.gz"])
|
||||||
file_name = os.path.basename(output)
|
file_name = os.path.basename(output)
|
||||||
result = file_name
|
result = file_name
|
||||||
|
|
||||||
# Get the filename pattern match from the output
|
# 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
|
# come out from rendering the ROP node if there
|
||||||
# is a frame pattern in the name
|
# is a frame pattern in the name
|
||||||
pattern = r"\w+\.(\d+)" + re.escape(ext)
|
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.
|
# for a custom frame list. So this should be refactored.
|
||||||
instance.data.update({"frames": result})
|
instance.data.update({"frames": result})
|
||||||
|
|
||||||
def create_file_list(self, match, start_frame, end_frame):
|
@staticmethod
|
||||||
"""Collect files based on frame range and regex.match
|
def create_file_list(match, start_frame, end_frame):
|
||||||
|
"""Collect files based on frame range and `regex.match`
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
match(re.match): match object
|
match(re.match): match object
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue