From: Ralf Jung Date: Tue, 11 Nov 2014 09:57:36 +0000 (+0100) Subject: write to stdout only X-Git-Url: https://git.ralfj.de/zonemaker.git/commitdiff_plain/62c4aa98cb5889fdda183ac6b58a54bb1c7427b0?ds=inline;hp=164584073909c27d2a310c95ca13333bbf769aba write to stdout only --- diff --git a/zone-maker b/zone-maker index 57f8afe..d2669b6 100755 --- a/zone-maker +++ b/zone-maker @@ -13,9 +13,8 @@ def load_module(name, path, write_bytecode = False): def make_zone(filename: str) -> None: zonefile = load_module(os.path.basename(filename), filename) - zones = zonefile.__zones__ # type: Sequence[Zone] - for zone in zones: - zone.write() + zone = zonefile.__zone__ # type: Zone + zone.write() if __name__ == "__main__": for name in sys.argv[1:]: diff --git a/zonemaker/zone.py b/zonemaker/zone.py index 35363ff..f9712e9 100644 --- a/zonemaker/zone.py +++ b/zonemaker/zone.py @@ -1,4 +1,4 @@ -import re +import re, datetime from ipaddress import IPv4Address, IPv6Address from typing import List, Dict, Any, Iterator, Tuple, Sequence @@ -191,12 +191,11 @@ def SecureDelegation(name: str, tag: int, alg: int, digest: int, key: str) -> Na class Zone: - def __init__(self, name: str, serialfile: str, dbfile: str, mail: str, NS: List[str], + def __init__(self, name: str, serialfile: str, mail: str, NS: List[str], secondary_refresh: int, secondary_retry: int, secondary_expire: int, NX_TTL: int = None, A_TTL: int = None, other_TTL: int = None, domains: Dict[str, Any] = {}) -> None: self._serialfile = serialfile - self._dbfile = dbfile if not name.endswith('.'): raise Exception("Expected an absolute hostname") self._name = check_hostname(name) @@ -272,7 +271,6 @@ class Zone: yield rr def write(self) -> None: - with open(self._dbfile, 'w') as f: - for rr in self.generate_rrs(): - f.write(rr+"\n") - print(rr) + print(";; {0} zone file, generated by zonemaker on {1}".format(self._name, datetime.datetime.now())) + for rr in self.generate_rrs(): + print(rr)