def check_net_address(addr, family):
 if (enum and PY3):
  assert isinstance(family, enum.IntEnum), family
 if (family == AF_INET):
  octs = [int(x) for x in addr.split('.')]
  assert (len(octs) == 4), addr
  for num in octs:
   assert (0 <= num <= 255), addr
  if (not PY3):
   addr = unicode(addr)
  ipaddress.IPv4Address(addr)
 elif (family == AF_INET6):
  assert isinstance(addr, str), addr
  if (not PY3):
   addr = unicode(addr)
  ipaddress.IPv6Address(addr)
 elif (family == psutil.AF_LINK):
  assert (re.match('([a-fA-F0-9]{2}[:|\\-]?){6}', addr) is not None), addr
 else:
  raise ValueError('unknown family %r', family)

def check_net_address ( addr , family ) : if ( enum and PY3 ) : assert isinstance ( family , enum . IntEnum ) , family if ( family == AF_INET ) : octs = [ int ( x ) for x in addr . split ( '.' ) ] assert ( len ( octs ) == 4 ) , addr for num in octs : assert ( 0 <= num <= 255 ) , addr if ( not PY3 ) : addr = unicode ( addr ) ipaddress . IPv4Address ( addr ) elif ( family == AF_INET6 ) : assert isinstance ( addr , str ) , addr if ( not PY3 ) : addr = unicode ( addr ) ipaddress . IPv6Address ( addr ) elif ( family == psutil . AF_LINK ) : assert ( re . match ( '([a-fA-F0-9]{2}[:|\\-]?){6}' , addr ) is not None ) , addr else : raise ValueError ( 'unknown family %r' , family )
check a net address validity .