#NEWLINE# def _explode_shorthand_ip_string( ip_str ) : #NEWLINE# #INDENT# '\n    Expand a shortened IPv6 address.\n\n    Args:\n        ip_str: A string, the IPv6 address.\n\n    Returns:\n        A string, the expanded IPv6 address.\n    ' #NEWLINE# if ( not _is_shorthand_ip ( ip_str ) ) : #NEWLINE# #INDENT# return ip_str #NEWLINE# #UNINDENT# new_ip = [ ] #NEWLINE# hextet = ip_str . split ( '::' ) #NEWLINE# if ( '.' in ip_str . split ( ':' ) [ ( - 1 ) ] ) : #NEWLINE# #INDENT# fill_to = 7 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fill_to = 8 #NEWLINE# #UNINDENT# if ( len ( fill_to ) > 1 ) : #NEWLINE# #INDENT# sep = ( len ( hextet [ 0 ] . split ( ':' ) ) + len ( hextet [ 1 ] . split ( ':' ) ) ) #NEWLINE# new_ip = hextet [ 0 ] . split ( ':' ) #NEWLINE# for __ in range ( ( fill_to - sep ) ) : #NEWLINE# #INDENT# new_ip . append ( '0000' ) #NEWLINE# #UNINDENT# new_ip += hextet [ 1 ] . split ( ':' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# new_ip = ip_str . split ( ':' ) #NEWLINE# #UNINDENT# ret_ip = [ ] #NEWLINE# for hextet in new_ip : #NEWLINE# #INDENT# ret_ip . append ( ( ( '0' * ( 4 - len ( hextet ) ) ) + hextet ) . lower ( ) ) #NEWLINE# #UNINDENT# return ':' . join ( ret_ip )