import re


def remove_temporary_path(codevalidator_output, temporary__dir_path):
    """
    Removes the temporary dir path from the file paths

    >>> remove_temporary_path('/tmp/test/file.a ERROR', '/tmp/test')
    'file.a ERROR'

    :param codevalidator_output: Raw codevalidator output
    :type codevalidator_output: str
    :param temporary__dir_path:
    :type temporary__dir_path: pathlib.Path
    :return: codevalidator_output with paths relative to the root directory
    """

    regular_expression = '^{temp_dir}/'.format(temp_dir=re.escape(str(temporary__dir_path)))
    regex = re.compile(regular_expression)
    lines = [regex.sub('', line, 1) for line in codevalidator_output.splitlines()]
    return '\n'.join(lines)