From aa611907c4a7409cad9d4703c92ab8560ae7e474 Mon Sep 17 00:00:00 2001 From: chove Date: Thu, 21 Apr 2005 10:53:16 +0200 Subject: [PATCH] petit script qui fnre la liste des adhrents (il retourne les fichier .tex sur l'entre std) syntaxe : liste_adh.py > file.tex && latex file.tex && dvips file.dvi darcs-hash:20050421085316-4ec08-ee298ce7e9d1115abb20539847dff6dc8f90f3d8.gz --- gestion/tools/liste_adh.py | 76 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 gestion/tools/liste_adh.py diff --git a/gestion/tools/liste_adh.py b/gestion/tools/liste_adh.py new file mode 100755 index 00000000..dc119424 --- /dev/null +++ b/gestion/tools/liste_adh.py @@ -0,0 +1,76 @@ +#! /usr/bin/env python +# -*- coding: iso-8859-15 -*- + +import sys +sys.path.append('/usr/scripts/gestion') +from ldap_crans import crans_ldap, decode +db = crans_ldap() + +bats = 'ABCGHIJMP' + +def titre (bat) : + if bat == 'P' : + return 'Pavillon des jardins' + elif bat == '?' : + return 'Autres (extérieurs et chambres invalides)' + else : + return 'Bâtiment %s' % bat + +# création de la liste vide +########################### + +liste = {} +for bat in bats + '?' : + liste[bat] = [] + +# remplissage de la liste +######################### + +# les batiments +for bat in bats : + adhs = db.search( 'chbre=%s*&paiement=ok' % bat )['adherent'] + for adh in adhs : + liste[bat].append( u'%s %s' % ( adh.nom(), adh.prenom() ) ) + +# les extérieurs +adhs = db.search( 'paiement=ok' )['adherent'] +for adh in adhs : + if not adh.chbre()[0] in bats : + liste['?'].append( u'%s %s' % ( adh.nom(), adh.prenom() ) ) + +# création du fichier tex +######################### + +print """\\documentclass[a4paper,11pt]{article} +\\usepackage[T1]{fontenc} +\\usepackage[francais]{babel} +\\usepackage{longtable} +\\usepackage{geometry} +\\usepackage{fancyheadings} +\\geometry{ hmargin=2cm, vmargin=4cm } + +\\begin{document} +\\lhead{A.G.O. du CR@NS} +\\rhead{21 avril 2005} +\\pagestyle{fancy} +""" + +for bat in bats + '?' : + # entete du batiment + print """\\section{%(bat)s}\n +\\chead{\emph{%(bat)s}} +\\begin{longtable}{| p{2.5in} | p{1.5in} |} +\\hline +\\textbf{Nom Prenom} & \\textbf{Signature} \\\\ +\\hline +\\endhead""" % {'bat' : titre(bat) } + + # ajout des adhérents + liste[bat].sort() + for adh in liste[bat] : + print (u'%s& \\\\\n\\hline' % adh).encode('iso 8859-15') + + # fin du batiment + print "\\end{longtable}\n" + +print "\\end{document}"