From bc09f31ddb96eec8fc754ff2aa57ae329a8d9e64 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 30 Mar 2021 10:48:31 +0200 Subject: [PATCH 1/2] check for full match instead of simple match --- pype/lib/profiles_filtering.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pype/lib/profiles_filtering.py b/pype/lib/profiles_filtering.py index 32c17cbd12..455bb4cdd5 100644 --- a/pype/lib/profiles_filtering.py +++ b/pype/lib/profiles_filtering.py @@ -87,7 +87,7 @@ def validate_value_by_regexes(value, in_list): regexes = compile_list_of_regexes(in_list) for regex in regexes: - if re.match(regex, value): + if re.fullmatch(regex, value): return 1 return -1 From def94529b4b68f2bd1e2480d79907af5b3d93c31 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 30 Mar 2021 14:04:24 +0200 Subject: [PATCH 2/2] aded python 2 compatibility for fullmatch --- pype/lib/profiles_filtering.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pype/lib/profiles_filtering.py b/pype/lib/profiles_filtering.py index 455bb4cdd5..c4410204dd 100644 --- a/pype/lib/profiles_filtering.py +++ b/pype/lib/profiles_filtering.py @@ -59,6 +59,14 @@ def _profile_exclusion(matching_profiles, logger): return matching_profiles[0][0] +def fullmatch(regex, string, flags=0): + """Emulate python-3.4 re.fullmatch().""" + matched = re.match(regex, string, flags=flags) + if matched and matched.span()[1] == len(string): + return matched + return None + + def validate_value_by_regexes(value, in_list): """Validates in any regex from list match entered value. @@ -87,7 +95,11 @@ def validate_value_by_regexes(value, in_list): regexes = compile_list_of_regexes(in_list) for regex in regexes: - if re.fullmatch(regex, value): + if hasattr(regex, "fullmatch"): + result = regex.fullmatch(value) + else: + result = fullmatch(regex, value) + if result: return 1 return -1