Update regexes to work around Python 3.11 changes (#231)

pull/233/head
Kate Case 2022-12-05 13:32:45 -05:00 committed by GitHub
parent 57904bed64
commit f407bbdb92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -0,0 +1,3 @@
---
bugfixes:
- mac - reorganize regexes to work around 3.11 regex changes. (https://github.com/ansible-collections/ansible.utils/pull/231)

View File

@ -112,12 +112,12 @@ def _mac(mac):
_validate_args("mac", DOCUMENTATION, params)
# IEEE EUI-48 upper and lower, commom unix
re1 = r"^(?i)([0-9a-f]{2}[:-]){5}[0-9a-f]{2}$"
re1 = r"^([0-9a-f]{2}[:-]){5}[0-9a-f]{2}$"
# Cisco triple hextex
re2 = r"^(?i)([0-9a-f]{4}\.[0-9a-f]{4}\.[0-9a-f]{4})$"
re2 = r"^([0-9a-f]{4}\.[0-9a-f]{4}\.[0-9a-f]{4})$"
# Bare
re3 = r"^(?i)[0-9a-f]{12}$"
regex = "{re1}|{re2}|{re3}".format(re1=re1, re2=re2, re3=re3)
re3 = r"^[0-9a-f]{12}$"
regex = "(?i){re1}|{re2}|{re3}".format(re1=re1, re2=re2, re3=re3)
return bool(re.match(regex, mac))