From a164767101e8669c64828f210135a5dacc51db3d Mon Sep 17 00:00:00 2001 From: bernat Date: Thu, 14 Jul 2005 20:07:04 +0200 Subject: [PATCH] =?UTF-8?q?Encore=20plus=20g=C3=A9n=C3=A9ral...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit darcs-hash:20050714180704-d1718-2ed13fbbb2e840278b0b4c802eae3deff008d360.gz --- gestion/ldap_crans.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gestion/ldap_crans.py b/gestion/ldap_crans.py index 99da146c..fff13859 100755 --- a/gestion/ldap_crans.py +++ b/gestion/ldap_crans.py @@ -157,14 +157,13 @@ def format_mac(mac) : Retourne la mac formatée. """ l, mac = preattr(mac) - mac = mac.strip() - if mac.count(":") + mac.count("-") == 5: + mac = mac.strip().replace("-",":") + if mac.count(":") == 5: # On a une adresse de la forme 0:01:02:18:d1:90 # On va compléter s'il manque des 0 - for car in (":", "-"): - mac = car.join(map(lambda x: x.replace(' ', '0'), - map(lambda x: "%02s" % x, mac.split(car)))) - mac= mac.replace(':','').replace('-','').lower() + mac = ":".join(map(lambda x: x.replace(' ', '0'), + map(lambda x: "%02s" % x, mac.split(":")))) + mac= mac.replace(':','').lower() if len(mac)!=12 : raise ValueError(u'Longueur adresse mac incorrecte.') for c in mac[:] :