Did I find the right examples for you? yes no

All Samples(5)  |  Call(4)  |  Derive(0)  |  Import(1)
Apply the config variables to the supplied value

        def variable_template(value, variables=None):
    '''
    Apply the config variables to the supplied value
    '''
    if value:
        if not isinstance(value, basestring):
            return value

        if variables is None:
            variables = fab.env.config['variables']

        try:
            return value.format(**variables)
        except KeyError as exc:
            fab.abort('Undefined variable requested: {exc}\n'
                      'Original value we tried to parse: {value}'.format(
                          exc=exc,
                          value=value
                      ))
        


src/g/a/garment-0.5/garment/stages.py   garment(Download)
import fabric.api as fab
 
from .config import variable_template
 
 
                                                     ", ".join(roles)))
 
        prefix = variable_template(step.get('prefix'))
        cd = variable_template(step.get('cd'))
 
        if 'shell_env' in step:
            shell_env = {}
            for env_name in step['shell_env']:
                shell_env[env_name] = variable_template(
                    step['shell_env'][env_name]
 
        commands = [
            variable_template(command)
            for command in step['commands']
        ]