MACAddress

Formencode validator to check whether a string is a correct hardware (MAC) address.

Examples:

>>> mac = MACAddress()
>>> mac.to_python('aa:bb:cc:dd:ee:ff')
'aabbccddeeff'
>>> mac.to_python('aa:bb:cc:dd:ee:ff:e')
Traceback (most recent call last):
    ...
Invalid: A MAC address must contain 12 digits and A-F; the value you gave has 13 characters
>>> mac.to_python('aa:bb:cc:dd:ee:fx')
Traceback (most recent call last):
    ...
Invalid: MAC addresses may only contain 0-9 and A-F (and optionally :), not 'x'
>>> MACAddress(add_colons=True).to_python('aabbccddeeff')
'aa:bb:cc:dd:ee:ff'

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
bad_character:
MAC addresses may only contain 0-9 and A-F (and optionally :), not %(char)r
bad_length:
A MAC address must contain 12 digits and A-F; the value you gave has %(length)s characters
empty:
Please enter a value
noneType:
The input must be a string (not None)

Attributes

a add_colons

False

a gettextargs

{}

a strip

True

a use_builtins_gettext

True

a accept_python

True

a __singletonmethods__

('to_python', 'from_python', 'message', 'all_messages', 'subvalidators')

a declarative_count

44

a __unpackargs__

()

a compound

False

a not_empty

False

a __mutableattributes__

()

a repeating

False

a valid_characters

'0123456789abcdefABCDEF'

Methods

f __initargs__(self, new_attrs) ...

f __call__(self, *args, **kw) ...

f __classinit__(cls, new_attrs) ...

f __init__(self, *args, **kw) ...

f __sourcerepr__(self, source, binding=None) ...

f __classsourcerepr__(cls, source, binding=None) ...

See the source for more information.