diff --git a/gestion/annuaires.py b/gestion/annuaires.py index 239fdb15..57e8ab7a 100755 --- a/gestion/annuaires.py +++ b/gestion/annuaires.py @@ -1,5 +1,10 @@ #!/usr/bin/python -# -*- coding: iso8859-15 -*- +# -*- coding: iso-8859-15 -*- + +from types import * + +# Liste des switchs +bat_switchs = [ 'b', 'c' , 'h' , 'i' , 'g' , 'j' ] aide={ 'g' : "appart du RDC=G901" , @@ -487,6 +492,29 @@ def reverse(bat) : else : reverse[prise] = [ chbre ] return reverse + +def all_switchs(bat=None): + """Retourne la liste des switchs pour un batiment. + + Si bat est donné, seulement pour le bâtiment demandé, sinon pour + tous les bâtiments. bat peut être une liste aussi. Le backbone n'est + pas pris en compte. La convention est batx-y sauf si y=0 et on a donc + simplement batx""" + if bat == None: + bat = bat_switchs + if not(type(bat) is TupleType or type(bat) is ListType): + bat = [bat] + switchs = [] + for b in map(lambda x: x.lower(), bat): + dup = map(lambda x: x[1], reverse(b).keys()) + # dup contient des elements en double + for n in list(dict(zip(dup,[None]*len(dup)))): + if int(n) == 0: + switchs.append("bat%s" % b) + else: + switchs.append("bat%s-%s" % (b, n)) + return switchs + # Locaux clubs : lecture dans chbre_prises et ajout des locaux dans les bats non # manageables