def _dump_environment(self, execution, file):
env_vars = []<EOL>for module in execution.get('<STR_LIT>') or []:<EOL><INDENT>env_vars.append(self.MODULE_TO_VAR_RE.sub('<STR_LIT:_>', module))<EOL><DEDENT>for var in execution.get('<STR_LIT>') or {}:<EOL><INDENT>env_vars.append(var)<EOL><DEDENT>with open(file, '<STR_LIT:w>') as ostr:<EOL><INDENT>yaml.dump(dict((name, os.environ.get(name)) for name in env_vars), ostr)<EOL><DEDENT>
Write in a YAML file a dict containing sub-set
        of `os.environ`. Only the following variables are
        writen:
        * those in execution['environment']
        * based on execution['modules'], for instance if module
          `foo/bar` is specified in execution, then
          expect `foo_bar` to be in `os.environ`