'Check if two IP address ranges overlap.
Returns 0 if the two ranges don\'t overlap, 1 if the given
range overlaps at the end and -1 if it does at the beginning.
>>> IP(\'192.168.0.0/23\').overlaps(\'192.168.1.0/24\')
1
>>> IP(\'192.168.0.0/23\').overlaps(\'192.168.1.255\')
1
>>> IP(\'192.168.0.0/23\').overlaps(\'192.168.2.0\')
0
>>> IP(\'192.168.1.0/24\').overlaps(\'192.168.0.0/23\')
-1'

def overlaps(self, item):

    if (not isinstance(item, IP)):
        item = IP(item)
    if ((item.ip >= self.ip) and (item.ip < (self.ip + self.len()))):
        return 1
    elif ((self.ip >= item.ip) and (self.ip < (item.ip + item.len()))):
        return (-1)
    else:
        return 0
