write to stdout only
authorRalf Jung <post@ralfj.de>
Tue, 11 Nov 2014 09:57:36 +0000 (10:57 +0100)
committerRalf Jung <post@ralfj.de>
Tue, 11 Nov 2014 09:57:36 +0000 (10:57 +0100)
zone-maker
zonemaker/zone.py

index 57f8afe3470c4bdf169d18168d295bf6d4c41b78..d2669b6f95bbc5887a266a76ade23a4ecf13f643 100755 (executable)
@@ -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:]:
index 35363ff6c207db8208af574a623b22bc5e1a682c..f9712e9e5e3aa9a7fa8a94df09a4720fd07998f9 100644 (file)
@@ -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 <https://www.ralfj.de/projects/zonemaker> on {1}".format(self._name, datetime.datetime.now()))
+        for rr in self.generate_rrs():
+            print(rr)