d2669b6f95bbc5887a266a76ade23a4ecf13f643
[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     zone = zonefile.__zone__ # type: Zone
17     zone.write()
18
19 if __name__ == "__main__":
20     for name in sys.argv[1:]:
21         make_zone(name)
22