def _ip_int_from_string(self, ip_str=None):
        if not ip_str:
            ip_str = str(self.ip)

        ip_int = 0

        # Do we have an IPv4 mapped (::ffff:a.b.c.d) or compact (::a.b.c.d)
        # ip_str?
        fields = ip_str.split(':')
        if fields[-1].count('.') == 3:
            ipv4_string = fields.pop()
            ipv4_int = IPv4Network(ipv4_string)._ip
            octets = []
            for _ in xrange(2):
                octets.append(hex(ipv4_int & 0xFFFF).lstrip('0x').rstrip('L'))
                ipv4_int >>= 16
            fields.extend(reversed(octets))
            ip_str = ':'.join(fields)

        fields = self._explode_shorthand_ip_string(ip_str).split(':')
        for field in fields:
            try:
                ip_int = (ip_int << 16) + int(field or '0', 16)
            except ValueError:
                raise AddressValueError(ip_str)

        return ip_int
Turn an IPv6 ip_str into an integer.
dataset/ETHPy150Open anandology/pyjamas/pyjs/src/pyjs/lib/ipaddr.py/_BaseV6._ip_int_from_string