From: Ralf Jung Date: Sat, 8 Nov 2014 21:29:28 +0000 (+0100) Subject: parse IP addresses X-Git-Url: https://git.ralfj.de/zonemaker.git/commitdiff_plain/8afd5eb407397e88da8f7d2151088d14abbe51e4?hp=2fd3698a920105ffa759f546666a1793c8c46c14 parse IP addresses --- diff --git a/zone-maker b/zone-maker index ddfb195..100b17a 100755 --- a/zone-maker +++ b/zone-maker @@ -12,7 +12,9 @@ def load_module(name, path, write_bytecode = False): def make_zone(filename): zonefile = load_module(os.path.basename(filename), filename) zones = zonefile.__zones__ - # TODO do something with the zones + # TODO do something more clever with the zones + for zone in zones: + zone.write(sys.stdout) if __name__ == "__main__": for name in sys.argv[1:]: diff --git a/zonemaker/zone.py b/zonemaker/zone.py index 6319505..5e83854 100644 --- a/zonemaker/zone.py +++ b/zonemaker/zone.py @@ -1,3 +1,5 @@ +import ipaddress + second = 1 minute = 60*second hour = 60*minute @@ -5,8 +7,8 @@ day = 24*hour class Address: def __init__(self, IPv4 = None, IPv6 = None): - self._IPv4 = IPv4 - self._IPv6 = IPv6 + self._IPv4 = None if IPv4 is None else ipaddress.IPv4Address(IPv4) + self._IPv6 = None if IPv6 is None else ipaddress.IPv6Address(IPv6) def IPv4(self): return Address(IPv4 = self._IPv4) @@ -40,3 +42,6 @@ class Zone: self._NX_TTL = other_TTL if NX_TTL is None else NX_TTL self._A_TTL = other_TTL if A_TTL is None else A_TTL self._other_TTL = other_TTL + + def write(self, file): + raise NotImplementedError()