Update regexes to work around Python 3.11 changes (#231)
parent
57904bed64
commit
f407bbdb92
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
bugfixes:
|
||||
- mac - reorganize regexes to work around 3.11 regex changes. (https://github.com/ansible-collections/ansible.utils/pull/231)
|
|
@ -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))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue