Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class Mac(Regex):
"""MAC address validator"""
tag = 'mac'
def __init__(self, *args, **kwargs):
super(Mac, self).__init__(*args, **kwargs)
self.regexes = [
re.compile("[0-9a-fA-F]{2}([-:]?)[0-9a-fA-F]{2}(\\1[0-9a-fA-F]{2}){4}$"),
re.compile("[0-9a-fA-F]{4}([-:]?)[0-9a-fA-F]{4}(\\1[0-9a-fA-F]{4})$"),
]
DefaultValidators = {}
for v in util.get_subclasses(Validator):
# Allow validator nodes to contain either tags or actual name
DefaultValidators[v.tag] = v
DefaultValidators[v.__name__] = v
def __init__(self, data_dict, name=''):
flat_data = util.flatten(data_dict, keep_iter=True)
dict.__init__(self, flat_data)
self.name = name
self.dict = data_dict