Prépare l'arrivée de macros dans whos_lc
This commit is contained in:
parent
6161a4bc32
commit
395db97395
1 changed files with 14 additions and 1 deletions
|
@ -20,6 +20,7 @@ ENCODING = encoding.in_encoding
|
||||||
def explore_db(args):
|
def explore_db(args):
|
||||||
"""Utilise le contenu de args pour décider comment explorer la base de données."""
|
"""Utilise le contenu de args pour décider comment explorer la base de données."""
|
||||||
data = search_ldap(args)
|
data = search_ldap(args)
|
||||||
|
data = macro_expand(data, args)
|
||||||
data = limits(data, args)
|
data = limits(data, args)
|
||||||
dataLen = sum([len(elem) for elem in data.itervalues()])
|
dataLen = sum([len(elem) for elem in data.itervalues()])
|
||||||
if dataLen:
|
if dataLen:
|
||||||
|
@ -54,10 +55,18 @@ def search_ldap(args):
|
||||||
if not data.has_key(elem.__class__.__name__):
|
if not data.has_key(elem.__class__.__name__):
|
||||||
data[elem.__class__.__name__] = [elem]
|
data[elem.__class__.__name__] = [elem]
|
||||||
else:
|
else:
|
||||||
|
if elem not in data[elem.__class__.__name__]:
|
||||||
data[elem.__class__.__name__].append(elem)
|
data[elem.__class__.__name__].append(elem)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def macro_expand(data, args):
|
||||||
|
"""Gère les macros spécifiques à whos_lc.
|
||||||
|
Permet de récupérer les propriétaires d'objets cherchés,
|
||||||
|
ou les factures ou les machines. De chercher par prise,
|
||||||
|
etc etc"""
|
||||||
|
return data
|
||||||
|
|
||||||
def limits(data, args):
|
def limits(data, args):
|
||||||
"""Applique les limitations dans la recherche.
|
"""Applique les limitations dans la recherche.
|
||||||
Les cas sont a priori conflictuels.
|
Les cas sont a priori conflictuels.
|
||||||
|
@ -66,6 +75,7 @@ def limits(data, args):
|
||||||
data_restricted = {}
|
data_restricted = {}
|
||||||
data_restricted.update(data)
|
data_restricted.update(data)
|
||||||
contentFilter = []
|
contentFilter = []
|
||||||
|
|
||||||
if args.adherent:
|
if args.adherent:
|
||||||
contentFilter = ["adherent"]
|
contentFilter = ["adherent"]
|
||||||
elif args.club:
|
elif args.club:
|
||||||
|
@ -127,7 +137,10 @@ if __name__ == "__main__":
|
||||||
type_group.add_argument('-b', '--borne', help="Limite l'affichage aux bornes.", action="store_true")
|
type_group.add_argument('-b', '--borne', help="Limite l'affichage aux bornes.", action="store_true")
|
||||||
type_group.add_argument('-c', '--club', help="Limite l'affichage aux clubs.", action="store_true")
|
type_group.add_argument('-c', '--club', help="Limite l'affichage aux clubs.", action="store_true")
|
||||||
type_group.add_argument('--crans', help="Limite l'affichage aux machines crans.", action="store_true")
|
type_group.add_argument('--crans', help="Limite l'affichage aux machines crans.", action="store_true")
|
||||||
|
type_group.add_argument('-F', '--factures', help="Récupère les factures de l'objet cherché.", action="store_true")
|
||||||
type_group.add_argument('-m', '--machine', help="Limite l'affichage aux machines.", action="store_true")
|
type_group.add_argument('-m', '--machine', help="Limite l'affichage aux machines.", action="store_true")
|
||||||
|
type_group.add_argument('-M', '--machines', help="Récupère les machines de l'objet cherché.", action="store_true")
|
||||||
|
type_group.add_argument('-P', '--proprietaire', help="Récupère le propriétaire de l'objet cherché.", action="store_true")
|
||||||
type_group.add_argument('--serveur', help="Limite l'affichage aux serveurs.", action="store_true")
|
type_group.add_argument('--serveur', help="Limite l'affichage aux serveurs.", action="store_true")
|
||||||
type_group.add_argument('--special', help="Limite l'affichage aux machines spéciales.", action="store_true")
|
type_group.add_argument('--special', help="Limite l'affichage aux machines spéciales.", action="store_true")
|
||||||
type_group.add_argument('--switch', help="Limite l'affichage aux switches (pas encore implémenté).", action="store_true")
|
type_group.add_argument('--switch', help="Limite l'affichage aux switches (pas encore implémenté).", action="store_true")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue