def safejoin(base, *elements):
<EOL>base = os.path.abspath(base)<EOL>path = os.path.join(base, *elements)<EOL>path = os.path.normpath(path)<EOL>if not path_is_inside(path, base):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>return path<EOL>
Safely joins paths together.

    The result will always be a subdirectory under `base`, otherwise ValueError
    is raised.

    Args:
        base (str): base path
        elements (list of strings): path elements to join to base

    Returns:
        elements joined to base