From b0238cba5ccbd516cc2597572ca9126016aaf904 Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Thu, 12 Dec 2024 17:38:49 +0100 Subject: [PATCH] :bug: 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 --- client/ayon_core/pipeline/traits/content.py | 4 ++-- client/ayon_core/pipeline/traits/time.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/pipeline/traits/content.py b/client/ayon_core/pipeline/traits/content.py index 0ca0cbb3e1..4d198813c1 100644 --- a/client/ayon_core/pipeline/traits/content.py +++ b/client/ayon_core/pipeline/traits/content.py @@ -140,7 +140,7 @@ class FileLocations(TraitBase): Optional[FileLocation]: File location for the frame. """ - frame_regex = r"\.(?P(?P0*)\d+)\.\D+\d?$" + frame_regex = r"\.(?P(?P0*)\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 diff --git a/client/ayon_core/pipeline/traits/time.py b/client/ayon_core/pipeline/traits/time.py index 74da6ef570..7687a023da 100644 --- a/client/ayon_core/pipeline/traits/time.py +++ b/client/ayon_core/pipeline/traits/time.py @@ -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" not in v: - msg = "Frame regex must include 'frame' named group" + if v and any(s not in v for s in ["?P", "?P"]): + msg = "Frame regex must include 'index' and `padding named groups" raise ValueError(msg) return v