@classmethod<EOL><INDENT>def _ip_int_from_string(cls, ip_str):<DEDENT>
if not ip_str:<EOL><INDENT>raise AddressValueError('<STR_LIT>')<EOL><DEDENT>parts = ip_str.split('<STR_LIT::>')<EOL>_min_parts = <NUM_LIT:3><EOL>if len(parts) < _min_parts:<EOL><INDENT>msg = "<STR_LIT>" % (_min_parts, ip_str)<EOL>raise AddressValueError(msg)<EOL><DEDENT>if '<STR_LIT:.>' in parts[-<NUM_LIT:1>]:<EOL><INDENT>try:<EOL><INDENT>ipv4_int = IPv4Address(parts.pop())._ip<EOL><DEDENT>except AddressValueError as exc:<EOL><INDENT>raise AddressValueError("<STR_LIT>" % (exc, ip_str))<EOL><DEDENT>parts.append('<STR_LIT>' % ((ipv4_int >> <NUM_LIT:16>) & <NUM_LIT>))<EOL>parts.append('<STR_LIT>' % (ipv4_int & <NUM_LIT>))<EOL><DEDENT>_max_parts = cls._HEXTET_COUNT + <NUM_LIT:1><EOL>if len(parts) > _max_parts:<EOL><INDENT>msg = "<STR_LIT>" % (<EOL>_max_parts - <NUM_LIT:1>, ip_str)<EOL>raise AddressValueError(msg)<EOL><DEDENT>skip_index = None<EOL>for i in _compat_range(<NUM_LIT:1>, len(parts) - <NUM_LIT:1>):<EOL><INDENT>if not parts[i]:<EOL><INDENT>if skip_index is not None:<EOL><INDENT>msg = "<STR_LIT>" % ip_str<EOL>raise AddressValueError(msg)<EOL><DEDENT>skip_index = i<EOL><DEDENT><DEDENT>if skip_index is not None:<EOL><INDENT>parts_hi = skip_index<EOL>parts_lo = len(parts) - skip_index - <NUM_LIT:1><EOL>if not parts[<NUM_LIT:0>]:<EOL><INDENT>parts_hi -= <NUM_LIT:1><EOL>if parts_hi:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise AddressValueError(msg % ip_str)  <EOL><DEDENT><DEDENT>if not parts[-<NUM_LIT:1>]:<EOL><INDENT>parts_lo -= <NUM_LIT:1><EOL>if parts_lo:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise AddressValueError(msg % ip_str)  <EOL><DEDENT><DEDENT>parts_skipped = cls._HEXTET_COUNT - (parts_hi + parts_lo)<EOL>if parts_skipped < <NUM_LIT:1>:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise AddressValueError(msg % (cls._HEXTET_COUNT - <NUM_LIT:1>, ip_str))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if len(parts) != cls._HEXTET_COUNT:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise AddressValueError(msg % (cls._HEXTET_COUNT, ip_str))<EOL><DEDENT>if not parts[<NUM_LIT:0>]:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise AddressValueError(msg % ip_str)  <EOL><DEDENT>if not parts[-<NUM_LIT:1>]:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise AddressValueError(msg % ip_str)  <EOL><DEDENT>parts_hi = len(parts)<EOL>parts_lo = <NUM_LIT:0><EOL>parts_skipped = <NUM_LIT:0><EOL><DEDENT>try:<EOL><INDENT>ip_int = <NUM_LIT:0><EOL>for i in range(parts_hi):<EOL><INDENT>ip_int <<= <NUM_LIT:16><EOL>ip_int |= cls._parse_hextet(parts[i])<EOL><DEDENT>ip_int <<= <NUM_LIT:16> * parts_skipped<EOL>for i in range(-parts_lo, <NUM_LIT:0>):<EOL><INDENT>ip_int <<= <NUM_LIT:16><EOL>ip_int |= cls._parse_hextet(parts[i])<EOL><DEDENT>return ip_int<EOL><DEDENT>except ValueError as exc:<EOL><INDENT>raise AddressValueError("<STR_LIT>" % (exc, ip_str))<EOL><DEDENT>
Turn an IPv6 ip_str into an integer.

        Args:
            ip_str: A string, the IPv6 ip_str.

        Returns:
            An int, the IPv6 address

        Raises:
            AddressValueError: if ip_str isn't a valid IPv6 Address.