Remove duplicate values from pdns results

The option is by default to remove duplicate. The
duplicate can be useful when you have a set of pdns in
cluster to validate the result set.
This commit is contained in:
Alexandre Dulaunoy 2013-12-25 09:49:27 +01:00
parent aa0342ecab
commit 02605d1e1c

View file

@ -83,10 +83,21 @@ def getAssociatedRecords(rdata = None):
records.append(v.decode(encoding='UTF-8')) records.append(v.decode(encoding='UTF-8'))
return records return records
def JsonQOF(rrfound = None): def RemDuplicate(d = None):
if d is None:
return False
outd = [dict(t) for t in set([tuple(o.items()) for o in d])]
return outd
def JsonQOF(rrfound = None, RemoveDuplicate=True):
if rrfound is None: if rrfound is None:
return False return False
rrqof = "" rrqof = ""
if RemoveDuplicate:
rrfound=RemDuplicate(d=rrfound)
for rr in rrfound: for rr in rrfound:
rrqof = rrqof + json.dumps(rr) + "\n" rrqof = rrqof + json.dumps(rr) + "\n"
return rrqof return rrqof