emit to dbfile
[zonemaker.git] / zone-maker
1 #!/usr/bin/python3
2 import sys, os
3 from zonemaker.zone import Zone
4 from typing import Sequence
5
6 def load_module(name, path, write_bytecode = False):
7     import importlib.machinery
8     old_val = sys.dont_write_bytecode
9     sys.dont_write_bytecode = not write_bytecode
10     module = importlib.machinery.SourceFileLoader(name, path).load_module()
11     sys.dont_write_bytecode = old_val
12     return module
13
14 def make_zone(filename: str) -> None:
15     zonefile = load_module(os.path.basename(filename), filename)
16     zones = zonefile.__zones__ # type: Sequence[Zone]
17     for zone in zones:
18         zone.write()
19
20 if __name__ == "__main__":
21     for name in sys.argv[1:]:
22         make_zone(name)
23