import re


def get_path(file_name: str, instance: str):
    """
    This function returns the path of a file starting from the root of
    the delphi repository. The returned path varies depending on whether
    it is for a namespace or a source variable, which is denoted by the
    `instance` argument variable. It is important to note that the path
    refers to that of the original system being analyzed i.e. the Fortran
    code and not the intermediate Python file which is used to generate
    the AST.
    """
    if instance == "source":
        source_match = re.match(r"[./]*(.*)", file_name)
        assert source_match, (
            f"Original Fortran source file for {file_name} " f"not found."
        )
        return source_match.group(1)
    elif instance == "namespace":
        source_match = re.match(r"[./]*(.*)\.", file_name)
        assert source_match, f"Namespace path for {file_name} not found."
        return source_match.group(1).split("/")
    else:
        assert False, f"Error when trying to get the path of file {file_name}."