🐛 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:
Ondrej Samohel 2024-12-12 17:38:49 +01:00
parent 6d9c73dae7
commit b0238cba5c
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
2 changed files with 6 additions and 5 deletions

View file

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

View file

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