From 0aa88e53473dad95e31db3ba45f6793c7ca6fcec Mon Sep 17 00:00:00 2001 From: Otthorn Date: Mon, 5 Apr 2021 00:28:23 +0200 Subject: [PATCH] :rotating_light: use black --- main.py | 63 ++++++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/main.py b/main.py index 116cdf9..dd7e2aa 100644 --- a/main.py +++ b/main.py @@ -45,6 +45,7 @@ def format_mname(name: str): return mname + HANDLERS = { "soa": soa_handler, "originv4": originv4_handler, @@ -58,12 +59,13 @@ HANDLERS = { "aaaa_records": aaaa_records_handler, } + def soa_handler(zone, records): """Handler for SOA record""" - soa = zone['soa'] + soa = zone["soa"] - records['@'].append( + records["@"].append( dns.rdtypes.ANY.SOA.SOA( dns.rdataclass.IN, dns.rdatatype.SOA, @@ -77,58 +79,50 @@ def soa_handler(zone, records): ) ) + def originv4_hanlder(zone, records): """Handler for the IPv4 origin""" ipv4_addr = zone["originv4"]["ipv4"] - records['@'].append( - dns.rdtypes.ANY.A.A( - dns.rdataclass.IN, - dns.rdatatypes.A, - ipv4_addr - ) - ) + records["@"].append( + dns.rdtypes.ANY.A.A(dns.rdataclass.IN, dns.rdatatypes.A, ipv4_addr) + ) + def originv6_handler(zone, records): """Handler for the IPv6 origin""" ipv6_addr = zone["originv6"] # Yes, re2o is this weird and inconsistent - records['@'].append( - dns.rdtypes.ANY.AAAA.AAAA( - dns.rdataclass.IN, - dns.rdatatype.AAAA, - ipv6_addr - ) - ) + records["@"].append( + dns.rdtypes.ANY.AAAA.AAAA(dns.rdataclass.IN, dns.rdatatype.AAAA, ipv6_addr) + ) + def ns_records_handler(zone, records): - """Handler for the NS record""" + """Handler for the NS record""" for record in zone["ns_records"]: - + target = record["target"] records["@"].append( - dns.rdtypes.ANY.NS.NS( - dns.rdataclass.IN, - dns.rdatatype.NS, - target - ) + dns.rdtypes.ANY.NS.NS(dns.rdataclass.IN, dns.rdatatype.NS, target) ) + def sshfp_record_handler(zone, records): """Handler for the SSHFP record""" for record in zone["sshfp"]: for fp in record["sshfp"]: - + algorithm = fp["algo_id"] for fp_type in fp["hash"]: - fingerprint = fp["hash"][fp_type] + fingerprint = fp["hash"][fp_type] records[record["hostname"]].append( dns.rdtype.ANY.SSHFP.SSHFP( @@ -136,10 +130,11 @@ def sshfp_record_handler(zone, records): dns.rdatatype.SSHFP, algorithm, fp_type, - fingerprint + fingerprint, ) ) + def txt_records_handler(zone, records): """Handler for TXT record""" @@ -149,12 +144,11 @@ def txt_records_handler(zone, records): records[name].append( dns.rdtypes.ANY.TXT.TXT( - dns.rdataclass.IN, - dns.rdatatype.TXT, - record["field2"] + dns.rdataclass.IN, dns.rdatatype.TXT, record["field2"] ) ) + def srv_records_handler(zone, records): """Handler for SRV record""" @@ -167,13 +161,13 @@ def srv_records_handler(zone, records): dns.rdtypes.ANY.SRV.SRV( dns.rdataclass.IN, dns.rdatatype.SRV, - record['priority'], - record['weight'], - record['port'], - record['target'] + record["priority"], + record["weight"], + record["port"], + record["target"], ) ) - + def a_records_handler(zone, recordds): """Handler for A Record""" @@ -187,6 +181,7 @@ def a_records_handler(zone, recordds): ) ) + parser = argparse.ArgumentParser() parser.add_argument(