mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
🐛 fix regex named group for frame list
this is needed to align with named groups in `clique`. Frame is IMO more descriptive but aligning it simplify the code
This commit is contained in:
parent
6d9c73dae7
commit
b0238cba5c
2 changed files with 6 additions and 5 deletions
|
|
@ -140,7 +140,7 @@ class FileLocations(TraitBase):
|
|||
Optional[FileLocation]: File location for the frame.
|
||||
|
||||
"""
|
||||
frame_regex = r"\.(?P<frame>(?P<padding>0*)\d+)\.\D+\d?$"
|
||||
frame_regex = r"\.(?P<index>(?P<padding>0*)\d+)\.\D+\d?$"
|
||||
if sequence_trait and sequence_trait.frame_regex:
|
||||
frame_regex = sequence_trait.frame_regex
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ class FileLocations(TraitBase):
|
|||
for location in self.file_paths:
|
||||
result = re.search(frame_regex, location.file_path.name)
|
||||
if result:
|
||||
frame_index = int(result.group("frame"))
|
||||
frame_index = int(result.group("index"))
|
||||
if frame_index == frame:
|
||||
return location
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -118,7 +118,8 @@ class Sequence(TraitBase):
|
|||
sequence.
|
||||
frame_padding (int): Frame padding.
|
||||
frame_regex (str): Frame regex - regular expression to match
|
||||
frame numbers. Must include 'frame' named group.
|
||||
frame numbers. Must include 'index' named group and 'padding'
|
||||
named group.
|
||||
frame_spec (str): Frame list specification of frames. This takes
|
||||
string like "1-10,20-30,40-50" etc.
|
||||
|
||||
|
|
@ -136,8 +137,8 @@ class Sequence(TraitBase):
|
|||
@classmethod
|
||||
def validate_frame_regex(cls, v: Optional[str]) -> str:
|
||||
"""Validate frame regex."""
|
||||
if v is not None and "?P<frame>" not in v:
|
||||
msg = "Frame regex must include 'frame' named group"
|
||||
if v and any(s not in v for s in ["?P<index>", "?P<padding>"]):
|
||||
msg = "Frame regex must include 'index' and `padding named groups"
|
||||
raise ValueError(msg)
|
||||
return v
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue