Ajout -e a stats_cableurs
Ajout du switch '-e' au script stats_cableurs, ce switch permet de compter aussi les mois de Novembre et Decembre dans le decompte ... darcs-hash:20071210095914-af6e7-89596b5ab75caf0f6002556fa25710f6b397032c.gz
This commit is contained in:
parent
73bab99bcc
commit
a2aaafca9b
1 changed files with 22 additions and 12 deletions
|
@ -7,7 +7,8 @@
|
||||||
# -----------------
|
# -----------------
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 François Bobot <bobot@crans.org>,
|
# Copyright (C) 2007 François Bobot <bobot@crans.org>,
|
||||||
# Jeremie Dimino <jeremie@dimino.org>
|
# Jeremie Dimino <jeremie@dimino.org>,
|
||||||
|
# Michel Blockelet <blockelet@crans.org
|
||||||
#
|
#
|
||||||
# This file is free software; you can redistribute it and/or modify
|
# This file is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -34,7 +35,7 @@ db = crans_ldap()
|
||||||
date_debut_ann_scol = time.mktime((ann_scol, 8, 1, 0, 0, 0, 0, 0, 0))
|
date_debut_ann_scol = time.mktime((ann_scol, 8, 1, 0, 0, 0, 0, 0, 0))
|
||||||
paiement_ann_scol = "paiement+%d" % ann_scol
|
paiement_ann_scol = "paiement+%d" % ann_scol
|
||||||
|
|
||||||
def donne_cableur(adherent):
|
def donne_cableur(mois,adherent):
|
||||||
u""" Cherche le cableur qui a inscrit ou réinscrit un adhérent. """
|
u""" Cherche le cableur qui a inscrit ou réinscrit un adhérent. """
|
||||||
|
|
||||||
cableur = None
|
cableur = None
|
||||||
|
@ -51,14 +52,14 @@ def donne_cableur(adherent):
|
||||||
champ = hist.replace(',', '').replace(': ', '').split(' ')
|
champ = hist.replace(',', '').replace(': ', '').split(' ')
|
||||||
# On inspecte la date
|
# On inspecte la date
|
||||||
date = champ[0].split('/')
|
date = champ[0].split('/')
|
||||||
if int(date[1]) in [8, 9, 10] and int(date[2]) == ann_scol:
|
if int(date[1]) in mois and int(date[2]) == ann_scol:
|
||||||
# Maintenant on regarde si l'action recherchee est ici
|
# Maintenant on regarde si l'action recherchee est ici
|
||||||
if action_filtre in champ[3:]:
|
if action_filtre in champ[3:]:
|
||||||
return action, champ[2]
|
return action, champ[2]
|
||||||
|
|
||||||
return action, None
|
return action, None
|
||||||
|
|
||||||
def calcul_score():
|
def calcul_score(mois):
|
||||||
u""" Calcul le score de tous les cableurs ayant inscrit ou
|
u""" Calcul le score de tous les cableurs ayant inscrit ou
|
||||||
réinscrit quelqu'un pour l'année en cours. """
|
réinscrit quelqu'un pour l'année en cours. """
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ def calcul_score():
|
||||||
|
|
||||||
score = {}
|
score = {}
|
||||||
for adherent in liste:
|
for adherent in liste:
|
||||||
action, cableur = donne_cableur(adherent)
|
action, cableur = donne_cableur(mois,adherent)
|
||||||
if cableur:
|
if cableur:
|
||||||
if not score.has_key(cableur):
|
if not score.has_key(cableur):
|
||||||
score[cableur] = { 'inscription': 0,
|
score[cableur] = { 'inscription': 0,
|
||||||
|
@ -86,15 +87,24 @@ def classe(score={}):
|
||||||
return cableurs
|
return cableurs
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
score = calcul_score()
|
|
||||||
classement = classe(score)
|
|
||||||
|
|
||||||
nb_affiche = 10
|
nb_affiche = 10
|
||||||
|
mois = [8,9,10]
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
try:
|
if sys.argv[1] == '-e':
|
||||||
nb_affiche = int(sys.argv[1])
|
mois = [8,9,10,11]
|
||||||
except:
|
if len(sys.argv) > 2:
|
||||||
nb_affiche = 10
|
try:
|
||||||
|
nb_affiche = int(sys.argv[2])
|
||||||
|
except:
|
||||||
|
nb_affiche = 10
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
nb_affiche = int(sys.argv[1])
|
||||||
|
except:
|
||||||
|
nb_affiche = 10
|
||||||
|
|
||||||
|
score = calcul_score(mois)
|
||||||
|
classement = classe(score)
|
||||||
|
|
||||||
if nb_affiche > 0:
|
if nb_affiche > 0:
|
||||||
classement = classement[0:nb_affiche]
|
classement = classement[0:nb_affiche]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue