[printing] Support des couleurs dans dialog

This commit is contained in:
Valentin Samir 2014-03-03 10:54:33 +01:00
parent 3e9dc95268
commit 1394cfc867

View file

@ -34,6 +34,7 @@ def prise_etat(chbre):
# fonction prise_etat propre à lc_ldap, pour
# ne plus en avoir besoin ci-après.
gestion.whos = try_import(u"gestion.whos")
gestion.whos.coul = coul
if chbre=="????":
return coul("Chambre invalide", "violet")
return gestion.whos.prise_etat(chbre)[0]
@ -87,11 +88,15 @@ def const_of_mac(mac):
return mac
templateEnv=None
def template():
global templateEnv
def template(dialog=False):
global templateEnv, coul, tableau
if not templateEnv:
# un import paresseux, comme ça, pas la peine d'installer jinja2 sur les machines où il n'y en a pas besoin
import jinja2
oldcoul = coul
oldtableau = tableau
tableau = lambda *args,**kwargs: oldtableau(*args,dialog=dialog,**kwargs)
coul = lambda *args,**kwargs:oldcoul(*args,dialog=dialog,**kwargs)
template_path = '/usr/scripts/lc_ldap/printing/templates/'
templateLoader = jinja2.FileSystemLoader( searchpath=["/", template_path] )
templateEnv = jinja2.Environment( loader=templateLoader, trim_blocks=True )