def get_mask_ipv6(bits):
 if ((bits > 128) or (bits < 0)):
  raise ValueError(('A mask can only be 0-128 bits, got %i' % bits))
 elif (bits == 128):
  return FULL_IPv6_MASK
 mask_bin = _get_binary(((2 ** bits) - 1), 128)[::(-1)]
 groupings = [mask_bin[(16 * i):(16 * (i + 1))] for i in range(8)]
 return ':'.join([('%04x' % int(group, 2)) for group in groupings]).upper()

def get_mask_ipv6 ( bits ) : if ( ( bits > 128 ) or ( bits < 0 ) ) : raise ValueError ( ( 'A mask can only be 0-128 bits, got %i' % bits ) ) elif ( bits == 128 ) : return FULL_IPv6_MASK mask_bin = _get_binary ( ( ( 2 ** bits ) - 1 ) , 128 ) [ : : ( - 1 ) ] groupings = [ mask_bin [ ( 16 * i ) : ( 16 * ( i + 1 ) ) ] for i in range ( 8 ) ] return ':' . join ( [ ( '%04x' % int ( group , 2 ) ) for group in groupings ] ) . upper ( )
provides the ipv6 mask for a given number of bits .