Compare commits

...

2 commits

Author SHA1 Message Date
mwiegand
77ed1970e1 wip 2021-07-13 19:00:26 +02:00
mwiegand
5a1ca9142d wip 2021-07-13 18:53:48 +02:00
2 changed files with 14 additions and 6 deletions

View file

@ -1,4 +1,5 @@
from ipaddress import ip_interface
hdict, hlist = repo.libs.hashable.hdict, repo.libs.hashable.hlist
defaults = {
@ -75,9 +76,9 @@ def collect_records(metadata):
for type, values in records.items():
for value in values:
zones\
.setdefault(zone, [])\
.append(
{'name': name, 'type': type, 'value': value}
.setdefault(zone, set())\
.add(
hdict({'name': name, 'type': type, 'value': value})
)
return {
@ -104,10 +105,10 @@ def ns_records(metadata):
return {
'bind': {
'zones': {
zone: [
{'name': '@', 'type': 'NS', 'value': f"{nameserver}."}
zone: {
hdict({'name': '@', 'type': 'NS', 'value': f"{nameserver}."})
for nameserver in nameservers
] for zone in metadata.get('bind/zones').keys()
} for zone in metadata.get('bind/zones').keys()
},
},
}

7
libs/hashable.py Normal file
View file

@ -0,0 +1,7 @@
class hdict(dict):
def __hash__(self):
return hash(tuple(sorted(self.items())))
class hlist(list):
def __hash__(self):
return hash(tuple(sorted(self)))