def parse_results_file(resultFile, run_set_id=None, ignore_errors=False):
    '''
    This function parses a XML file with the results of the execution of a run set.
    It returns the "result" XML tag.
    @param resultFile: The file name of the XML file with the results.
    @param run_set_id: An optional identifier of this set of results.
    '''
    logging.info('    %s', resultFile)
    url = Util.make_url(resultFile)

    parse = ElementTree.ElementTree().parse
    try:
        with Util.open_url_seekable(url, mode='rb') as f:
            try:
                try:
                    resultElem = parse(gzip.GzipFile(fileobj=f))
                except IOError:
                    f.seek(0)
                    try:
                        resultElem = parse(bz2.BZ2File(f))
                    except __HOLE__:
                        # Python 3.2 does not support giving a file-like object to BZ2File
                        resultElem = parse(io.BytesIO(bz2.decompress(f.read())))
            except IOError:
                f.seek(0)
                resultElem = parse(f)
    except IOError as e:
        logging.error('Could not read result file %s: %s', resultFile, e)
        exit(1)
    except ElementTree.ParseError as e:
        logging.error('Result file %s is invalid: %s', resultFile, e)
        exit(1)

    if resultElem.tag not in ['result', 'test']:
        logging.error("XML file with benchmark results seems to be invalid.\n"
                      "The root element of the file is not named 'result' or 'test'.\n"
                      "If you want to run a table-definition file,\n"
                      "you should use the option '-x' or '--xml'.")
        exit(1)

    if ignore_errors and 'error' in resultElem.attrib:
        logging.warning('Ignoring file "%s" because of error: %s',
                        resultFile,
                        resultElem.attrib['error'])
        return None

    if run_set_id is not None:
        for sourcefile in _get_run_tags_from_xml(resultElem):
            sourcefile.set('runset', run_set_id)

    insert_logfile_names(resultFile, resultElem)
    return resultElem
dataset/ETHPy150Open sosy-lab/benchexec/benchexec/tablegenerator/__init__.py/parse_results_file