def _make_env(resultdir=None):
    """Loads the env from `resultdir` if not `None` or makes a new one.

    An Enos environment handles all specific variables of an
    experiment. This function either generates a new environment or
    loads a previous one. If the value of `resultdir` is `None`, then
    this function makes a new environment and return it. If the value
    is a directory path that contains an Enos environment, then this function
    loads and returns it.

    In case of a directory path, this function also rereads the
    configuration file (the reservation.yaml) and reloads it. This
    lets the user update his configuration between each phase.

    Args:
        resultdir (str): directory path to load the env from.
    """
    env = {
        "config":      {},          # The config
        "resultdir":   "",          # Path to the result directory
        "config_file": "",          # The initial config file
        "nodes":       {},          # Roles with nodes
        "phase":       "",          # Last phase that have been run
        "user":        "",          # User id for this job
        "cwd":         os.getcwd()  # Current Working Directory
    }

    if resultdir:
        env_path = os.path.join(resultdir, "env")
        if os.path.isfile(env_path):
            with open(env_path, "r") as f:
                env.update(yaml.load(f))
                logger.debug("Loaded environment %s", env_path)

        if "config_file" in env and env["config_file"] is not None:
            # Resets the configuration of the environment
            if os.path.isfile(env["config_file"]):
                with open(env["config_file"], "r") as f:
                    env["config"].update(yaml.load(f))
                    logger.debug("Reloaded config %s", env["config"])

    return env
def _make_env ( resultdir = None ) : env = { "config" : { } , "resultdir" : "" , "config_file" : "" , "nodes" : { } , "phase" : "" , "user" : "" , "cwd" : os . getcwd ( ) } if resultdir : env_path = os . path . join ( resultdir , "env" ) if os . path . isfile ( env_path ) : with open ( env_path , "r" ) as f : env . update ( yaml . load ( f ) ) logger . debug ( "Loaded environment %s" , env_path ) if "config_file" in env and env [ "config_file" ] is not None : if os . path . isfile ( env [ "config_file" ] ) : with open ( env [ "config_file" ] , "r" ) as f : env [ "config" ] . update ( yaml . load ( f ) ) logger . debug ( "Reloaded config %s" , env [ "config" ] ) return env
Loads the env from `resultdir` if not `None` or makes a new one.

    An Enos environment handles all specific variables of an
    experiment. This function either generates a new environment or
    loads a previous one. If the value of `resultdir` is `None`, then
    this function makes a new environment and return it. If the value
    is a directory path that contains an Enos environment, then this function
    loads and returns it.

    In case of a directory path, this function also rereads the
    configuration file (the reservation.yaml) and reloads it. This
    lets the user update his configuration between each phase.

    Args:
        resultdir (str): directory path to load the env from.