CIDR represenation if IPAddr object is a network prefix

pull/1414/head
Alexander Koeppe 2016-05-06 16:04:21 +02:00 committed by sebres
parent 941a2b6c82
commit 1b21f21c22
1 changed files with 7 additions and 2 deletions

View File

@ -203,10 +203,15 @@ class IPAddr(object):
self._raw = ipstring
def __repr__(self):
if self.isIPv4 and self.plen < 32:
return "%s/%d" % (self.ntoa, self.plen)
elif self.isIPv6 and self.plen < 128:
return "%s/%d" % (self.ntoa, self.plen)
else:
return self.ntoa
def __str__(self):
return self.ntoa
return self.__repr__()
@property
def addr(self):