def check_not_intersecting_pages()

in annotation/annotation/schemas/annotations.py [0:0]


    def check_not_intersecting_pages(cls, values):
        """
        Same pages should not be in annotated or failed
        arrays at the same time.
        """
        annotated, validated, failed = (
            set([i.page_num for i in values.get("pages", {}) or []]),
            values.get("validated", set()) or set(),
            values.get("failed_validation_pages", set()) or set(),
        )

        intersecting_pages = annotated.intersection(failed)
        intersecting_pages.update(validated.intersection(failed))

        if intersecting_pages:
            raise ValueError(
                f"Pages {intersecting_pages} "
                "should not be in annotated (pages), and "
                "failed validation arrays at the "
                "same time. "
            )
        return values