[attributs] les ports sont un peu plus que juste un entier.
This commit is contained in:
parent
7f098bb45a
commit
454ea3e6e1
1 changed files with 24 additions and 4 deletions
24
attributs.py
24
attributs.py
|
@ -384,12 +384,32 @@ class portAttr(Attr):
|
|||
optional = True
|
||||
|
||||
def parse_value(self, port, ldif):
|
||||
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)
|
||||
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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue