def _explode_shorthand_ip_string(ip_str):
 if (not _is_shorthand_ip(ip_str)):
  return ip_str
 new_ip = []
 hextet = ip_str.split('::')
 if ('.' in ip_str.split(':')[(-1)]):
  fill_to = 7
 else:
  fill_to = 8
 if (len(hextet) > 1):
  sep = (len(hextet[0].split(':')) + len(hextet[1].split(':')))
  new_ip = hextet[0].split(':')
  for _ in xrange((fill_to - sep)):
   new_ip.append('0000')
  new_ip += hextet[1].split(':')
 else:
  new_ip = ip_str.split(':')
 ret_ip = []
 for hextet in new_ip:
  ret_ip.append((('0' * (4 - len(hextet))) + hextet).lower())
 return ':'.join(ret_ip)

def _explode_shorthand_ip_string ( ip_str ) : if ( not _is_shorthand_ip ( ip_str ) ) : return ip_str new_ip = [ ] hextet = ip_str . split ( '::' ) if ( '.' in ip_str . split ( ':' ) [ ( - 1 ) ] ) : fill_to = 7 else : fill_to = 8 if ( len ( hextet ) > 1 ) : sep = ( len ( hextet [ 0 ] . split ( ':' ) ) + len ( hextet [ 1 ] . split ( ':' ) ) ) new_ip = hextet [ 0 ] . split ( ':' ) for _ in xrange ( ( fill_to - sep ) ) : new_ip . append ( '0000' ) new_ip += hextet [ 1 ] . split ( ':' ) else : new_ip = ip_str . split ( ':' ) ret_ip = [ ] for hextet in new_ip : ret_ip . append ( ( ( '0' * ( 4 - len ( hextet ) ) ) + hextet ) . lower ( ) ) return ':' . join ( ret_ip )
expand a shortened ipv6 address .