mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
OP-2813 - changed logic of parsing frames from names
Adhering to clique standard FRAMES patter, eg pattern is separated by . It seems that this is most widely used (according to Discord).
This commit is contained in:
parent
5d25de8997
commit
c83202a023
2 changed files with 32 additions and 16 deletions
|
|
@ -4,7 +4,6 @@ import shutil
|
|||
import glob
|
||||
import clique
|
||||
import collections
|
||||
import re
|
||||
|
||||
|
||||
def collect_frames(files):
|
||||
|
|
@ -14,31 +13,24 @@ def collect_frames(files):
|
|||
Uses clique as most precise solution, used when anatomy template that
|
||||
created files is not known.
|
||||
|
||||
Depends that version substring starts with 'v' with any number of
|
||||
numeric characters after.
|
||||
Assumption is that frames are separated by '.', negative frames are not
|
||||
allowed.
|
||||
|
||||
Args:
|
||||
files(list) or (set with single value): list of source paths
|
||||
Returns:
|
||||
(dict): {'/asset/subset_v001.0001.png': '0001', ....}
|
||||
"""
|
||||
collections, remainder = clique.assemble(files, minimum_items=1)
|
||||
patterns = [clique.PATTERNS["frames"]]
|
||||
collections, remainder = clique.assemble(files, minimum_items=1,
|
||||
patterns=patterns)
|
||||
|
||||
real_file_name = None
|
||||
sources_and_frames = {}
|
||||
if len(files) == 1:
|
||||
real_file_name = list(files)[0]
|
||||
sources_and_frames[real_file_name] = None
|
||||
|
||||
if collections:
|
||||
for collection in collections:
|
||||
src_head = collection.head
|
||||
src_tail = collection.tail
|
||||
|
||||
# version recognized as a collection
|
||||
if re.match(".*([a-zA-Z0-9]%[0-9]+d).*", collection.format()):
|
||||
continue
|
||||
|
||||
for index in collection.indexes:
|
||||
src_frame = collection.format("{padding}") % index
|
||||
src_file_name = "{}{}{}".format(src_head, src_frame,
|
||||
|
|
|
|||
|
|
@ -47,6 +47,18 @@ def test_collect_frames_single_sequence():
|
|||
assert ret == expected, "Not matching"
|
||||
|
||||
|
||||
def test_collect_frames_single_sequence_negative():
|
||||
files = ["Asset_renderCompositingMain_v001.-0000.png"]
|
||||
ret = collect_frames(files)
|
||||
|
||||
expected = {
|
||||
"Asset_renderCompositingMain_v001.-0000.png": None
|
||||
}
|
||||
|
||||
print(ret)
|
||||
assert ret == expected, "Not matching"
|
||||
|
||||
|
||||
def test_collect_frames_single_sequence_shot():
|
||||
files = ["testing_sh010_workfileCompositing_v001.aep"]
|
||||
ret = collect_frames(files)
|
||||
|
|
@ -59,12 +71,24 @@ def test_collect_frames_single_sequence_shot():
|
|||
assert ret == expected, "Not matching"
|
||||
|
||||
|
||||
def test_collect_frames_single_sequence_numbers():
|
||||
files = ["PRJ_204_430_0005_renderLayoutMain_v001.0001.exr"]
|
||||
ret = collect_frames(files)
|
||||
|
||||
expected = {
|
||||
"PRJ_204_430_0005_renderLayoutMain_v001.0001.exr": "0001"
|
||||
}
|
||||
|
||||
print(ret)
|
||||
assert ret == expected, "Not matching"
|
||||
|
||||
|
||||
def test_collect_frames_single_sequence_shot_with_frame():
|
||||
files = ["testing_sh010_workfileCompositing_000_v001.aep"]
|
||||
ret = collect_frames(files)
|
||||
|
||||
expected = {
|
||||
"testing_sh010_workfileCompositing_000_v001.aep": "000"
|
||||
"testing_sh010_workfileCompositing_000_v001.aep": None
|
||||
}
|
||||
|
||||
print(ret)
|
||||
|
|
@ -88,7 +112,7 @@ def test_collect_frames_single_sequence_different_format():
|
|||
ret = collect_frames(files)
|
||||
|
||||
expected = {
|
||||
"Asset.v001.renderCompositingMain_0000.png": "0000"
|
||||
"Asset.v001.renderCompositingMain_0000.png": None
|
||||
}
|
||||
|
||||
print(ret)
|
||||
|
|
@ -100,7 +124,7 @@ def test_collect_frames_single_sequence_withhout_version():
|
|||
ret = collect_frames(files)
|
||||
|
||||
expected = {
|
||||
"pngv001.renderCompositingMain_0000.png": "0000"
|
||||
"pngv001.renderCompositingMain_0000.png": None
|
||||
}
|
||||
|
||||
print(ret)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue