import pathlib


def resolve_path(benchmark_path, url):
    """Fix a relative path from the simulation_list.yaml file

    Relative paths are allowed in the simulation_list.yaml. This turns
    those relative paths into correct URIs if not already a URI.

    Args:
      benchmark_path: path to the file with the benchmark result list
      url: the URL to repair

    Returns:
      the repaired URL

    >>> resolve_path(None, "file:///blah/blah")
    'file:///blah/blah'

    """
    if url[:4] in ["http", "file"]:
        return url
    return (pathlib.Path(benchmark_path).parent / url).as_uri()