def InetPtoN(protocol, addr_string):
 if (protocol == socket.AF_INET):
  return socket.inet_aton(addr_string)
 if (protocol != socket.AF_INET6):
  raise socket.error('Unsupported protocol')
 if (not addr_string):
  raise socket.error('Empty address string')
 if BAD_SINGLE_COLON.match(addr_string):
  raise socket.error('Start or ends with single colon')
 if (addr_string == '::'):
  return ('0' * 32).decode('hex_codec')
 addr_string = _RemoveV4Ending(addr_string)
 addr_string = _StripLeadingOrTrailingDoubleColons(addr_string)
 addr_string = _ZeroPad(addr_string)
 try:
  return addr_string.decode('hex_codec')
 except TypeError:
  raise socket.error(('Error decoding: %s' % addr_string))

def InetPtoN ( protocol , addr_string ) : if ( protocol == socket . AF_INET ) : return socket . inet_aton ( addr_string ) if ( protocol != socket . AF_INET6 ) : raise socket . error ( 'Unsupported protocol' ) if ( not addr_string ) : raise socket . error ( 'Empty address string' ) if BAD_SINGLE_COLON . match ( addr_string ) : raise socket . error ( 'Start or ends with single colon' ) if ( addr_string == '::' ) : return ( '0' * 32 ) . decode ( 'hex_codec' ) addr_string = _RemoveV4Ending ( addr_string ) addr_string = _StripLeadingOrTrailingDoubleColons ( addr_string ) addr_string = _ZeroPad ( addr_string ) try : return addr_string . decode ( 'hex_codec' ) except TypeError : raise socket . error ( ( 'Error decoding: %s' % addr_string ) )
convert ipv6 string to packed bytes .