♻️ move splitext to lib

This commit is contained in:
Ondrej Samohel 2022-09-20 19:06:56 +02:00
parent 71caefe449
commit df2f68db97
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
2 changed files with 30 additions and 14 deletions

View file

@ -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)