def _sanitize_ipv4_mapping(ip_str):
 if (not ip_str.lower().startswith('0000:0000:0000:0000:0000:ffff:')):
  return ip_str
 hextets = ip_str.split(':')
 if ('.' in hextets[(-1)]):
  return ip_str
 ipv4_address = ('%d.%d.%d.%d' % (int(hextets[6][0:2], 16), int(hextets[6][2:4], 16), int(hextets[7][0:2], 16), int(hextets[7][2:4], 16)))
 result = ':'.join(hextets[0:6])
 result += (':' + ipv4_address)
 return result

def _sanitize_ipv4_mapping ( ip_str ) : if ( not ip_str . lower ( ) . startswith ( '0000:0000:0000:0000:0000:ffff:' ) ) : return ip_str hextets = ip_str . split ( ':' ) if ( '.' in hextets [ ( - 1 ) ] ) : return ip_str ipv4_address = ( '%d.%d.%d.%d' % ( int ( hextets [ 6 ] [ 0 : 2 ] , 16 ) , int ( hextets [ 6 ] [ 2 : 4 ] , 16 ) , int ( hextets [ 7 ] [ 0 : 2 ] , 16 ) , int ( hextets [ 7 ] [ 2 : 4 ] , 16 ) ) ) result = ':' . join ( hextets [ 0 : 6 ] ) result += ( ':' + ipv4_address ) return result
sanitize ipv4 mapping in a expanded ipv6 address .