# Path: calliope/core/util/tools.py
# def relative_path(base_path_file, path):
#     """
#     If ``path`` is not absolute, it is interpreted as relative to the
#     path of the given ``base_path_file``.
# 
#     """
#     # Check if base_path_file is a string because it might be an AttrDict
#     if not os.path.isabs(path) and isinstance(base_path_file, str):
#         path = os.path.join(os.path.dirname(base_path_file), path)
#     return path


import io
import logging
import numpy as np
import ruamel.yaml as ruamel_yaml
from pathlib import Path
from calliope.core.util.tools import relative_path
                for i in range(len(v)):
                    if isinstance(v[i], dict):
                        v[i] = AttrDict(v[i])
                self.set_key(k, v)
            else:
                self.set_key(k, v)

    @classmethod
    def _resolve_imports(cls, loaded, resolve_imports, base_path=None):
        if (
            isinstance(resolve_imports, bool)
            and resolve_imports is True
            and "import" in loaded
        ):
            loaded_dict = loaded
        elif (
            isinstance(resolve_imports, str)
            and resolve_imports + ".import" in loaded.keys_nested()
        ):
            loaded_dict = loaded.get_key(resolve_imports)
        else:  # Return right away if no importing to be done
            return loaded

        # If we end up here, we have something to import
        imports = loaded_dict.get_key("import")
        if not isinstance(imports, list):
            raise ValueError("`import` must be a list.")

        for k in imports:
            if base_path:

# Path: calliope/core/util/tools.py
# def relative_path(base_path_file, path):
#     """
#     If ``path`` is not absolute, it is interpreted as relative to the
#     path of the given ``base_path_file``.
# 
#     """
#     # Check if base_path_file is a string because it might be an AttrDict
#     if not os.path.isabs(path) and isinstance(base_path_file, str):
#         path = os.path.join(os.path.dirname(base_path_file), path)
#     return path


# Path: calliope/core/attrdict.py
import io
import logging
import numpy as np
import ruamel.yaml as ruamel_yaml
from pathlib import Path
from calliope.core.util.tools import relative_path

                for i in range(len(v)):
                    if isinstance(v[i], dict):
                        v[i] = AttrDict(v[i])
                self.set_key(k, v)
            else:
                self.set_key(k, v)

    @classmethod
    def _resolve_imports(cls, loaded, resolve_imports, base_path=None):
        if (
            isinstance(resolve_imports, bool)
            and resolve_imports is True
            and "import" in loaded
        ):
            loaded_dict = loaded
        elif (
            isinstance(resolve_imports, str)
            and resolve_imports + ".import" in loaded.keys_nested()
        ):
            loaded_dict = loaded.get_key(resolve_imports)
        else:  # Return right away if no importing to be done
            return loaded

        # If we end up here, we have something to import
        imports = loaded_dict.get_key("import")
        if not isinstance(imports, list):
            raise ValueError("`import` must be a list.")

        for k in imports:
            if base_path:

                path = relative_path(base_path, k)