diff --git a/attributs.py b/attributs.py index 66fe752..d1d58d4 100644 --- a/attributs.py +++ b/attributs.py @@ -384,12 +384,32 @@ class portAttr(Attr): optional = True def parse_value(self, port, ldif): - if int(port) <0 or int(port)> 65535: - raise ValueError("Port invalide: %s" % port) - self.value = int(port) + if ":" in port: + a,b = port.split(":", 1) + if a: + if int(a) <0 or int(a)> 65535: + raise ValueError("Port invalide: %s" % port) + else: + a = 0 + if b: + if int(a) <0 or int(a)> 65535: + raise ValueError("Port invalide: %s" % port) + else: + b = 65535 + self.value = [int(a), int(b)] + else: + if int(port) <0 or int(port)> 65535: + raise ValueError("Port invalide: %s" % port) + self.value = [int(port)] def __unicode__(self): - return unicode(self.value) + if len(self.value) > 1: + a, b = self.value + a = '' if a == 0 else str(a) + b = '' if b == 65535 else str(b) + return unicode('%s:%s' % (a, b)) + else: + return unicode(self.value[0]) class portTCPout(portAttr):