예제 #1
0
def handle_tag_in_table_definition_file(tag, table_file, defaultColumnsToShow, options):
    def get_file_list(result_tag):
        if not 'filename' in result_tag.attrib:
            logging.warning("Result tag without filename attribute in file '%s'.", table_file)
            return []
        return Util.get_file_list(os.path.join(os.path.dirname(table_file), result_tag.get('filename'))) # expand wildcards

    if tag.tag == 'result':
        columnsToShow = extract_columns_from_table_definition_file(tag) or defaultColumnsToShow
        run_set_id = tag.get('id')
        for resultsFile in get_file_list(tag):
            return load_result(resultsFile, options, run_set_id, columnsToShow)

    elif tag.tag == 'union':
        columnsToShow = extract_columns_from_table_definition_file(tag) or defaultColumnsToShow
        result = RunSetResult([], collections.defaultdict(list), columnsToShow)

        for resultTag in tag.findall('result'):
            run_set_id = resultTag.get('id')
            for resultsFile in get_file_list(resultTag):
                result_xml = parse_results_file(resultsFile, run_set_id)
                if result_xml is not None:
                    result.append(resultsFile, result_xml, options.all_columns)

        if result._xml_results:
            name = tag.get('title', tag.get('name'))
            if name:
                result.attributes['name'] = [name]
            result.collect_data(options.correct_only)
            return result
        return None
예제 #2
0
def load_result(result_file, options, run_set_id=None, columns=None):
    """
    Completely handle loading a single result file.
    @param result_file the file to parse
    @return a fully ready RunSetResult instance or None
    """
    xml = parse_results_file(result_file, run_set_id=run_set_id, ignore_errors=options.ignore_errors)
    if xml is None:
        return None

    result = RunSetResult.create_from_xml(result_file, xml, columns=columns, all_columns=options.all_columns)
    result.collect_data(options.correct_only)
    return result