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
This commit is contained in:
parent
bd66442cc9
commit
aa611907c4
1 changed files with 76 additions and 0 deletions
76
gestion/tools/liste_adh.py
Executable file
76
gestion/tools/liste_adh.py
Executable file
|
@ -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}"
|
Loading…
Add table
Add a link
Reference in a new issue