Ejemplo n.º 1
0
def check_is_without_duplication(report_processor,
                                 constraint_section,
                                 element,
                                 are_duplicate,
                                 export_element,
                                 duplication_alowed=False):
    duplicate_element_list = [
        duplicate_element
        for duplicate_element in constraint_section.findall(".//" +
                                                            element.tag)
        if (element is not duplicate_element
            and are_duplicate(element, duplicate_element))
    ]
    if not duplicate_element_list:
        return

    report_processor.process(
        reports.duplicate_constraints_exist(
            element.tag,
            [
                export_element(duplicate_element)
                for duplicate_element in duplicate_element_list
            ],
            ReportItemSeverity.WARNING
            if duplication_alowed else ReportItemSeverity.ERROR,
            forceable=None
            if duplication_alowed else report_codes.FORCE_CONSTRAINT_DUPLICATE,
        ))
Ejemplo n.º 2
0
def check_is_without_duplication(
    report_processor,
    constraint_section, element, are_duplicate, export_element,
    duplication_alowed=False
):
    duplicate_element_list = [
        duplicate_element
        for duplicate_element in constraint_section.findall(".//"+element.tag)
        if(
            element is not duplicate_element
            and
            are_duplicate(element, duplicate_element)
        )
    ]
    if not duplicate_element_list:
        return

    report_processor.process(reports.duplicate_constraints_exist(
        element.tag,
        [
            export_element(duplicate_element)
            for duplicate_element in duplicate_element_list
        ],
        ReportItemSeverity.WARNING if duplication_alowed
            else ReportItemSeverity.ERROR,
        forceable=None if duplication_alowed
            else report_codes.FORCE_CONSTRAINT_DUPLICATE,
    ))