def expand_ipv6_address(address):
 if (not is_valid_ipv6_address(address)):
  raise ValueError(("'%s' isn't a valid IPv6 address" % address))
 if ('::' in address):
  missing_groups = (7 - address.count(':'))
  address = address.replace('::', ('::' + (':' * missing_groups)))
 for index in range(8):
  start = (index * 5)
  end = (address.index(':', start) if (index != 7) else len(address))
  missing_zeros = (4 - (end - start))
  if (missing_zeros > 0):
   address = ((address[:start] + ('0' * missing_zeros)) + address[start:])
 return address

def expand_ipv6_address ( address ) : if ( not is_valid_ipv6_address ( address ) ) : raise ValueError ( ( "'%s' isn't a valid IPv6 address" % address ) ) if ( '::' in address ) : missing_groups = ( 7 - address . count ( ':' ) ) address = address . replace ( '::' , ( '::' + ( ':' * missing_groups ) ) ) for index in range ( 8 ) : start = ( index * 5 ) end = ( address . index ( ':' , start ) if ( index != 7 ) else len ( address ) ) missing_zeros = ( 4 - ( end - start ) ) if ( missing_zeros > 0 ) : address = ( ( address [ : start ] + ( '0' * missing_zeros ) ) + address [ start : ] ) return address
expands abbreviated ipv6 addresses to their full colon separated hex format .