mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
add % check on the fhead in the lib.py
This commit is contained in:
parent
0c62e195dd
commit
0595afe8a3
1 changed files with 13 additions and 5 deletions
|
|
@ -3432,19 +3432,27 @@ def get_head_filename_without_hashes(original_path, name):
|
|||
|
||||
Args:
|
||||
original_path (str): the filename with frame hashes
|
||||
e.g. "renderAssetMain.####.exr"
|
||||
e.g. "renderCompositingMain.####.exr"
|
||||
name (str): the name of the tags
|
||||
e.g. "baking"
|
||||
|
||||
Returns:
|
||||
filename: the renamed filename with the tag
|
||||
e.g. "renderAssetMain.baking.####.exr"
|
||||
e.g. "renderCompositingMain.baking.####.exr"
|
||||
"""
|
||||
filename = os.path.basename(original_path)
|
||||
fhead = os.path.splitext(filename)[0].strip(".")
|
||||
tmp_fhead = re.sub(r"\d", "#", fhead)
|
||||
if "#" in tmp_fhead:
|
||||
fhead = tmp_fhead.replace("#", "").rstrip(".")
|
||||
if "#" in fhead:
|
||||
fhead = re.sub("#+", "", fhead).rstrip(".")
|
||||
elif "%" in fhead:
|
||||
# use regex to convert %04d to {:0>4}
|
||||
padding = re.search("%(\\d)+d", fhead)
|
||||
padding = padding.group(1) if padding else 1
|
||||
fhead = re.sub(
|
||||
"%.*d",
|
||||
"{{:0>{}}}".format(padding),
|
||||
fhead
|
||||
).rstip(".")
|
||||
new_fhead = "{}.{}".format(fhead, name)
|
||||
filename = filename.replace(fhead, new_fhead)
|
||||
return filename
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue