nodes.py: use setdefault()

This commit is contained in:
Franzi 2022-01-04 11:33:18 +01:00
parent 3a3ce5c5fd
commit 226fac0d78
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -10,8 +10,5 @@ for node in Path(join(repo_path, "nodes")).rglob("*.py"):
exec(f.read()) exec(f.read())
for name, data in nodes.items(): for name, data in nodes.items():
if 'hostname' not in data.keys(): data.setdefault('hostname', '.'.join(reversed(name.split('.'))) + '.kunbox.net')
data['hostname'] = '.'.join(reversed(name.split('.'))) + '.kunbox.net' data.setdefault('metadata', {}).setdefault('hostname', '.'.join(reversed(name.split('.'))) + '.kunbox.net')
if 'hostname' not in data['metadata'].keys():
data['metadata']['hostname'] = '.'.join(reversed(name.split('.'))) + '.kunbox.net'