[printing] Possibilité de spécifier la largeur des tableaux ascii
This commit is contained in:
parent
df23c50e23
commit
937aefb3ec
1 changed files with 33 additions and 14 deletions
|
@ -117,16 +117,17 @@ def machine(machine, params):
|
||||||
return template().get_template("machine").render(params)
|
return template().get_template("machine").render(params)
|
||||||
|
|
||||||
|
|
||||||
def list_machines(machines):
|
def list_machines(machines, width=None):
|
||||||
return tableau([
|
return tableau([
|
||||||
[m['mid'][0], m['rid'][0] , str(m['objectClass'][0])[7:], str(m['host'][0]).split('.')[0],
|
[m['mid'][0], m['rid'][0] , str(m['objectClass'][0])[7:], str(m['host'][0]).split('.')[0],
|
||||||
m['ipHostNumber'][0] if m.get('ipHostNumber',[]) else '-', m['macAddress'][0],
|
m['ipHostNumber'][0] if m.get('ipHostNumber',[]) else '-', m['macAddress'][0],
|
||||||
m.blacklist_actif()[0] if m.blacklist_actif() else '-'] for m in machines],
|
m.blacklist_actif()[0] if m.blacklist_actif() else '-'] for m in machines],
|
||||||
titre = [u'mid', u'rid', u'Type', u'Nom de machine', u'Adresse IP', u'Adresse MAC', u'Limitation'],
|
titre = [u'mid', u'rid', u'Type', u'Nom de machine', u'Adresse IP', u'Adresse MAC', u'Limitation'],
|
||||||
largeur = [5, 5, 6, '*', 15, 17, 10],
|
largeur = [5, 5, 6, '*', 15, 17, 10],
|
||||||
alignement = ['d', 'd', 'c', 'c', 'c', 'c', 'c'])
|
alignement = ['d', 'd', 'c', 'c', 'c', 'c', 'c'],
|
||||||
|
width=width)
|
||||||
|
|
||||||
def list_factures(factures):
|
def list_factures(factures, width=None):
|
||||||
return tableau([
|
return tableau([
|
||||||
[f['fid'][0], f['modePaiement'][0],
|
[f['fid'][0], f['modePaiement'][0],
|
||||||
coul("OK", "vert") if f.get('recuPaiement', []) else coul("NON", "rouge"),
|
coul("OK", "vert") if f.get('recuPaiement', []) else coul("NON", "rouge"),
|
||||||
|
@ -135,9 +136,10 @@ def list_factures(factures):
|
||||||
] for f in factures],
|
] for f in factures],
|
||||||
titre = [u'fid', u'Mode de paiement', u'Payé', u'Articles', u"Total"],
|
titre = [u'fid', u'Mode de paiement', u'Payé', u'Articles', u"Total"],
|
||||||
largeur = [5, 16, 6, '*', 8],
|
largeur = [5, 16, 6, '*', 8],
|
||||||
alignement = ['d', 'g', 'c', 'g', 'd'])
|
alignement = ['d', 'g', 'c', 'g', 'd'],
|
||||||
|
width=width)
|
||||||
|
|
||||||
def list_adherents(adherents):
|
def list_adherents(adherents, width=None):
|
||||||
return tableau([
|
return tableau([
|
||||||
[a['aid'][0],
|
[a['aid'][0],
|
||||||
u' '.join(unicode(i) for i in a['prenom'] + a['nom']),
|
u' '.join(unicode(i) for i in a['prenom'] + a['nom']),
|
||||||
|
@ -147,7 +149,20 @@ def list_adherents(adherents):
|
||||||
] for a in adherents ],
|
] for a in adherents ],
|
||||||
titre = [u'aid', u'Prénom Nom', u'Chbre', u'P', u'C', u'Machines'],
|
titre = [u'aid', u'Prénom Nom', u'Chbre', u'P', u'C', u'Machines'],
|
||||||
largeur = [5, 35, 5, 1, 1, '*'],
|
largeur = [5, 35, 5, 1, 1, '*'],
|
||||||
alignement = ['d', 'c', 'c', 'c', 'c', 'g'])
|
alignement = ['d', 'c', 'c', 'c', 'c', 'g'],
|
||||||
|
width=width)
|
||||||
|
|
||||||
|
def list_clubs(clubs, width=None):
|
||||||
|
return tableau([
|
||||||
|
[a['cid'][0],
|
||||||
|
u' '.join(unicode(i) for i in a['nom']),
|
||||||
|
a['chbre'][0], coul('o', 'vert') if a.paiement_ok() else coul('n', 'rouge'),
|
||||||
|
u', '.join(unicode(m['host'][0]).split('.',1)[0] for m in a.machines())
|
||||||
|
] for a in clubs ],
|
||||||
|
titre = [u'cid', u'Nom', u'Chbre', u'P', u'Machines'],
|
||||||
|
largeur = [5, 35, 5, 1, '*'],
|
||||||
|
alignement = ['d', 'c', 'c', 'c', 'g'],
|
||||||
|
width=width)
|
||||||
|
|
||||||
def proprio(proprio, params):
|
def proprio(proprio, params):
|
||||||
params['o']=proprio
|
params['o']=proprio
|
||||||
|
@ -196,27 +211,31 @@ def sprint(object, limit=5):
|
||||||
return club(object, params)
|
return club(object, params)
|
||||||
elif isinstance(object, objets.facture):
|
elif isinstance(object, objets.facture):
|
||||||
return facture(object, params)
|
return facture(object, params)
|
||||||
|
elif isinstance(object, attributs.blacklist):
|
||||||
|
return blacklist(object, params)
|
||||||
else:
|
else:
|
||||||
return str(object)
|
return str(object)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def sprint_list(list):
|
def sprint_list(list, width=None):
|
||||||
from lc_ldap import objets
|
from lc_ldap import objets
|
||||||
mlist={}
|
mlist={}
|
||||||
ret=[]
|
ret=[]
|
||||||
for o in list:
|
for o in list:
|
||||||
mlist[o.__class__] = mlist.get(o.__class__, []) + [o]
|
mlist[o.__class__] = mlist.get(o.__class__, []) + [o]
|
||||||
|
classes = mlist.keys()
|
||||||
for classe, list in mlist.items():
|
classes.sort()
|
||||||
|
for classe in classes:
|
||||||
|
list = mlist[classe]
|
||||||
if issubclass(classe, objets.machine):
|
if issubclass(classe, objets.machine):
|
||||||
ret.append(list_machines(list))
|
ret.append(list_machines(list, width))
|
||||||
elif issubclass(classe, objets.adherent):
|
elif issubclass(classe, objets.adherent):
|
||||||
ret.append(list_adherents(list))
|
ret.append(list_adherents(list, width))
|
||||||
#elif issubclass(classe, objets.club):
|
elif issubclass(classe, objets.club):
|
||||||
# ret.append(list_clubs(list))
|
ret.append(list_clubs(list, width))
|
||||||
elif issubclass(classe, objets.facture):
|
elif issubclass(classe, objets.facture):
|
||||||
ret.append(list_factures(list))
|
ret.append(list_factures(list, width))
|
||||||
else:
|
else:
|
||||||
ret.append("Listes d'objets de classe %s non affichage" % classe.__name__)
|
ret.append("Listes d'objets de classe %s non affichage" % classe.__name__)
|
||||||
return '\n'.join(ret)
|
return '\n'.join(ret)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue