(self, other)
Emulate numeric objects through network aggregation
Emulate numeric objects through network aggregation
Emulate numeric objects through network aggregation
def __add__(self, other):
        """Emulate numeric objects through network aggregation"""
        if self.prefixlen() != other.prefixlen():
            raise ValueError(
                "Only networks with the same prefixlen can be added.")
        if self.prefixlen < 1:
            raise ValueError(
                "Networks with a prefixlen longer than /1 can't be added.")
        if self.version() != other.version():
            raise ValueError(
                "Only networks with the same IP version can be added.")
        if self > other:
            # fixed by Skinny Puppy <skin_pup-IPy@happypoo.com>
            return other.__add__(self)
        else:
            ret = IP(self.int())
            ret._prefixlen = self.prefixlen() - 1
            return ret
def __add__ ( self , other ) : if self . prefixlen ( ) != other . prefixlen ( ) : raise ValueError ( "Only networks with the same prefixlen can be added." ) if self . prefixlen < 1 : raise ValueError ( "Networks with a prefixlen longer than /1 can't be added." ) if self . version ( ) != other . version ( ) : raise ValueError ( "Only networks with the same IP version can be added." ) if self > other : # fixed by Skinny Puppy <skin_pup-IPy@happypoo.com> return other . __add__ ( self ) else : ret = IP ( self . int ( ) ) ret . _prefixlen = self . prefixlen ( ) - 1 return ret