676bf9c1a8559e73040a2f1cb088f7d8acf1972f
[zonemaker.git] / zone-maker
1 #!/usr/bin/python3
2 import sys, os
3 from zonemaker.zone import Zone
4 #import typing
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