crans_bcfg2/etc/genshi/utils.py
Jeremie Dimino c54f2669d8 Execfile plutot que import
On utilise execfile pour avoir acces a l'environmement, notamment a metadata.

darcs-hash:20071209024939-af139-376cff9921a7abca0f1d05e101fa21f6be9bee91.gz
2007-12-09 03:49:39 +01:00

47 lines
1.4 KiB
Python

# -*- mode: python; coding: utf-8 -*-
#
# utils.py
# --------
#
# Copyright (C) 2007 Jeremie Dimino <jeremie@dimino.org>
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
# Ce fichier contient des definitions de variables et fonctions qui
# peuvent etre utiles dans la plupart des templates du crans.
# Le nom d'hote court, la partie avant le premier '.'
hostname = metadata.hostname.split('.',1)[0]
# Le nom d'hote sur le vlan public
pubhostname = hostname + ".crans.org"
# Le nom d'hote sur le vlan
admhostname = hostname + ".adm.crans.org"
def has(group):
return group in metadata.groups
def yesno(b):
if b:
return "yes"
else:
return "no"
def onoff(b):
if b:
return "on"
else:
return "off"