Initial formatting run with Black. Integration tests and unit tests pass before and after this change.

This commit is contained in:
Pim van Pelt
2022-04-22 13:05:55 +00:00
parent b375ddb433
commit baaaaa67b5
22 changed files with 1757 additions and 1178 deletions

View File

@ -14,33 +14,37 @@
import logging
import netaddr
def is_valid(mac):
""" Return True if the string given in `mac` is a valid (6-byte) MAC address,
as defined by netaddr.EUI """
"""Return True if the string given in `mac` is a valid (6-byte) MAC address,
as defined by netaddr.EUI"""
try:
addr = netaddr.EUI(mac)
except:
return False
return True
def is_local(mac):
""" Return True if a MAC address is a valid locally administered one. """
"""Return True if a MAC address is a valid locally administered one."""
try:
addr = netaddr.EUI(mac)
except:
return False
return bool(addr.words[0] & 0b10)
def is_multicast(mac):
""" Return True if a MAC address is a valid multicast one. """
"""Return True if a MAC address is a valid multicast one."""
try:
addr = netaddr.EUI(mac)
except:
return False
return bool(addr.words[0] & 0b01)
def is_unicast(mac):
""" Return True if a MAC address is a valid unicast one. """
"""Return True if a MAC address is a valid unicast one."""
try:
addr = netaddr.EUI(mac)
except: