Pass environ and self.variables in to template.

        self.variables overrides environ so that suprises in environ don't
        cause unexpected output if you are passing a value in explicitly.
543321
def body(self, environ, file_like):
        
        variables = environ.copy()
        variables.update(self.variables)
        template = string.Template(file_like.read())
        if self.safe is True:
            return [template.safe_substitute(variables)]
        else:
            return [template.substitute(variables)]
648543
def expand(template, variables=None):
    
    if variables is None:
        variables = {}
    return patterns.sub(functools.partial(_replace, variables), template)
1349819
def _render_template(param, username):
    '''
    
    '''
    env = Environment()
    template = env.from_string(param)
    variables = {'username': username}
    return template.render(variables)
272438
def var_set(session, **kwargs):
        
        if not kwargs:
            for name, value in session.variables.items():
                session.write_line("{0}={1}".format(name, value))
        else:
            for name, value in kwargs.items():
                name = name.strip()
                session.set(name, value)
                session.write_line("{0}={1}", name, value)
353106
def env(var_name, default=False):
    
    try:
        value = os.environ[var_name]
        if str(value).strip().lower() in ['false', 'f', 'no', 'off' '0', 'none', 'null', '', ]:
            return None
        return value
    except:
        from traceback import format_exc
        msg = "Unable to find the %s environment variable.\nUsing the value %s (the default) instead.\n" % (var_name, default)
        sys.stderr.write(format_exc())
        sys.stderr.write(msg)
        return default
379425
public void setEnvironmentVariables(Map<String, String> environment) {
    for (Map.Entry<String, String> entry : environment.entrySet()) {
      setEnvironmentVariable(entry.getKey(), entry.getValue());
    }
  }
598802
private boolean vForVariable(String loopVariablesDefinition, TemplateParserContext context) {
    Matcher matcher = VFOR_VARIABLE.matcher(loopVariablesDefinition);
    if (matcher.matches()) {
      initLoopVariable(matcher.group(1), matcher.group(2), context);
      indexVariableInfo = null;
      return true;
    }

    return false;
  }
1074509
public void collectVariables(EnvVars env, Run build, TaskListener listener) {
        EnvVars buildParameters = Utils.extractBuildParameters(build, listener);
        if (buildParameters != null) {
            env.putAll(buildParameters);
        }
        addAllWithFilter(envVars, env, filter.getPatternFilter());
        Map<String, String> sysEnv = new HashMap<>();
        Properties systemProperties = System.getProperties();
        Enumeration<?> enumeration = systemProperties.propertyNames();
        while (enumeration.hasMoreElements()) {
            String propertyKey = (String) enumeration.nextElement();
            sysEnv.put(propertyKey, systemProperties.getProperty(propertyKey));
        }
        addAllWithFilter(sysVars, sysEnv, filter.getPatternFilter());
    }
712180
def get_env_default(self, variable, default):
        
        if variable in os.environ:
            env_var = os.environ[variable]
        else:
            env_var = default
        return env_var
895663
function envReplace(str, vars) {
  return str.replace(/\$?\$\{([A-Za-z0-9_]+)(:-(.*?))?\}/g, function (varStr, varName, _, defValue) {
    // Handle escaping:
    if (varStr.indexOf('$$') === 0) {
      return varStr;
    }
    // Handle simple variable replacement:
    if (vars.hasOwnProperty(varName)) {
      log.debug(`${varName} replaced in configuration file`);
      return vars[varName];
    }
    // Handle default values:
    if (defValue) {
      log.debug(`${varName} replaced with default value in configuration file`);
      return defValue;
    }
    log.warn(`Unknown variable: ${varName}. Returning null.`);
    return null;
  });
}
994567
def set(self, variables: Dict[str, str]):
        
        current_variables = self.get()
        difference = DictDiffer(variables, current_variables)

        removed_keys = difference.removed()
        self.remove(removed_keys)

        changed_keys = difference.added() | difference.changed()
        changed = {key: variables[key] for key in changed_keys}
        self.add(changed, overwrite=True)
16651
private static void printEnvVariables() {
    System.out.println("Environment Variables: ");
    Map<String,String> map = System.getenv();
    Set<String> keys = map.keySet();
    Iterator iter = keys.iterator();
    while(iter.hasNext()) {
      String thiskey = (String)(iter.next()); 
      String value = map.get(thiskey);
      System.out.println(thiskey + " = " + value);
    }
  }
535819
def render_template(env, filename, values=None):
    
    if not values:
        values = {}
    tmpl = env.get_template(filename)
    return tmpl.render(values)
605706
def set_environ(inherit=True, append={}):
    
    _environ = {} if not inherit else environ
    for k,v in append.iteritems():
        _environ[k] = v
    return _environ
40550
def __add_variables(self, *args, **kwargs):
        

        for variable in args:
            self.__variables[variable] = None
        self.__variables.update(kwargs)
142965
def var_set(self, session, **kwargs):
        
        if not kwargs:
            session.write_line(
                self._utils.make_table(
                    ("Name", "Value"), session.variables.items()
                )
            )
        else:
            for name, value in kwargs.items():
                name = name.strip()
                session.set(name, value)
                session.write_line("{0}={1}", name, value)
155757
def env(*vars, **kwargs):
    
    for v in vars:
        value = os.environ.get(v)
        if value:
            return value
    return kwargs.get('default', '')