def match_sections(self, ddiff):
        section_froms = list(Section.objects
                .filter(page__document=ddiff.document_from).all())
        section_tos = list(Section.objects
                .filter(page__document=ddiff.document_to).all())
        matched_tos = set()
        for section_from in section_froms:
            best_match = self._match_section(section_from, section_tos)
            if best_match is not None:
                (section_to, confidence) = best_match
                s_matcher = SectionMatcher(
                        section_from=section_from,
                        section_to=section_to,
                        confidence=confidence,
                        diff=ddiff)
                s_matcher.save()
                matched_tos.add(section_to.pk)
            else:
                ddiff.removed_sections.add(section_from)
            print('Matched section {0}'.format(section_from.title))

        for section_to in section_tos:
            if matched_tos not in section_to.pk:
                ddiff.added_sections.add(section_to)
                print('Matched section to')

        print('Finished matching sections')
dataset/ETHPy150Open bartdag/recodoc2/recodoc2/apps/doc/parser/doc_diff.py/DocDiffer.match_sections/swapped operands of `not in`