def set_cmd_env_var(value):
def func_decorator(function):<EOL><INDENT>@functools.wraps(function)<EOL>def wrapper(*args, **kwargs):<EOL><INDENT>previous_cmd_env_var = os.getenv(temple.constants.TEMPLE_ENV_VAR)<EOL>os.environ[temple.constants.TEMPLE_ENV_VAR] = value<EOL>try:<EOL><INDENT>ret_val = function(*args, **kwargs)<EOL><DEDENT>finally:<EOL><INDENT>if previous_cmd_env_var is None:<EOL><INDENT>del os.environ[temple.constants.TEMPLE_ENV_VAR]<EOL><DEDENT>else:<EOL><INDENT>os.environ[temple.constants.TEMPLE_ENV_VAR] = previous_cmd_env_var<EOL><DEDENT><DEDENT>return ret_val<EOL><DEDENT>return wrapper<EOL><DEDENT>return func_decorator<EOL>
Decorator that sets the temple command env var to value