From 5ddcc97c26cce6c70fec302a9aeb146dfbfa0800 Mon Sep 17 00:00:00 2001 From: glondu Date: Mon, 27 Mar 2006 16:26:21 +0200 Subject: [PATCH] On peut dsormais ajouter des intervalles de ports. darcs-hash:20060327142621-68412-58a80a281a257a0904db80763735b6e99afbef1f.gz --- gestion/ldap_crans.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gestion/ldap_crans.py b/gestion/ldap_crans.py index 51476c77..733c339e 100755 --- a/gestion/ldap_crans.py +++ b/gestion/ldap_crans.py @@ -2636,9 +2636,19 @@ class Machine(base_classes_crans): if ports == None: return self._data.get(champ, []) - ports = map(int, ports) + # Les ports doivent être de la forme [port][:[port]]. On met + # la spécification sous une forme qui donne un tri intéressant + def parse(x): + try: + liste = x.split(':') + assert(len(liste) == 1 or len(liste) == 2) + return map(lambda x: x and int(x) or '', liste) + except: + raise ValueError(u'Spécification de ports incorrecte : %s' % x) + + ports = map(parse, ports) ports.sort() - self._set(champ, map(str, ports)) + self._set(champ, map(lambda x: ':'.join(map(str, x)), ports)) class MachineFixe(Machine):