def merge()

in libmozdata/bugzilla.py [0:0]


    def merge(self, bz):
        if self.bugids is None or bz.bugids is None:
            return None

        def __merge_fields(f1, f2):
            if f1:
                f1 = {f1} if isinstance(f1, six.string_types) else set(f1)
                if f2:
                    f2 = {f2} if isinstance(f2, six.string_types) else set(f2)
                    return list(f1.union(f2))
                else:
                    return f1
            else:
                if f2:
                    return f2
                else:
                    return None

        bugids = list(set(self.bugids).union(set(bz.bugids)))
        include_fields = __merge_fields(self.include_fields, bz.include_fields)
        comment_include_fields = __merge_fields(
            self.comment_include_fields, bz.comment_include_fields
        )
        attachment_include_fields = __merge_fields(
            self.attachment_include_fields, bz.attachment_include_fields
        )
        bughandler = self.bughandler.merge(bz.bughandler)
        historyhandler = self.historyhandler.merge(bz.historyhandler)
        commenthandler = self.commenthandler.merge(bz.commenthandler)
        attachmenthandler = self.attachmenthandler.merge(bz.attachmenthandler)

        return Bugzilla(
            bugids=bugids,
            include_fields=include_fields,
            bughandler=bughandler,
            historyhandler=historyhandler,
            commenthandler=commenthandler,
            attachmenthandler=attachmenthandler,
            comment_include_fields=comment_include_fields,
            attachment_include_fields=attachment_include_fields,
        )