Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1214 from pypeclub/bugfix/profile_regex_fix
Browse files Browse the repository at this point in the history
Fix regex checks in profiles filtering
  • Loading branch information
mkolar authored Mar 30, 2021
2 parents 26eed32 + a51c8f0 commit e4b8510
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pype/lib/profiles_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,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.
Expand Down Expand Up @@ -105,7 +113,11 @@ 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 hasattr(regex, "fullmatch"):
result = regex.fullmatch(value)
else:
result = fullmatch(regex, value)
if result:
return 1
return -1

Expand Down

0 comments on commit e4b8510

Please sign in to comment.