(self,other)
return err
Diff records - recursively diff sections (sorting RRs)
Diff records - recursively diff sections (sorting RRs)
Diff records - recursively diff sections ( sorting RRs )
def diff(self,other):
        """
            Diff records - recursively diff sections (sorting RRs)
        """
        err = []
        if self.header != other.header:
            err.append((self.header,other.header))
        for section in ('questions','rr','auth','ar'):
            if section == 'questions':
                k = lambda x:tuple(map(str,(x.qname,x.qtype)))
            else:
                k = lambda x:tuple(map(str,(x.rname,x.rtype,x.rdata)))
            a = dict([(k(rr),rr) for rr in getattr(self,section)])
            b = dict([(k(rr),rr) for rr in getattr(other,section)])
            sa = set(a)
            sb = set(b)
            for e in sorted(sa.intersection(sb)):
                if a[e] != b[e]:
                    err.append((a[e],b[e]))
            for e in sorted(sa.difference(sb)):
                err.append((a[e],None))
            for e in sorted(sb.difference(sa)):
                err.append((None,b[e]))
        return err
def diff ( self , other ) : err = [ ] if self . header != other . header : err . append ( ( self . header , other . header ) ) for section in ( 'questions' , 'rr' , 'auth' , 'ar' ) : if section == 'questions' : k = lambda x : tuple ( map ( str , ( x . qname , x . qtype ) ) ) else : k = lambda x : tuple ( map ( str , ( x . rname , x . rtype , x . rdata ) ) ) a = dict ( [ ( k ( rr ) , rr ) for rr in getattr ( self , section ) ] ) b = dict ( [ ( k ( rr ) , rr ) for rr in getattr ( other , section ) ] ) sa = set ( a ) sb = set ( b ) for e in sorted ( sa . intersection ( sb ) ) : if a [ e ] != b [ e ] : err . append ( ( a [ e ] , b [ e ] ) ) for e in sorted ( sa . difference ( sb ) ) : err . append ( ( a [ e ] , None ) ) for e in sorted ( sb . difference ( sa ) ) : err . append ( ( None , b [ e ] ) ) return err