experiment with mypy type annotations
[zonemaker.git] / zone-maker
1 #!/usr/bin/python3
2 import sys, os
3
4 def load_module(name, path, write_bytecode = False):
5     import importlib.machinery
6     old_val = sys.dont_write_bytecode
7     sys.dont_write_bytecode = not write_bytecode
8     module = importlib.machinery.SourceFileLoader(name, path).load_module()
9     sys.dont_write_bytecode = old_val
10     return module
11
12 def make_zone(filename):
13     zonefile = load_module(os.path.basename(filename), filename)
14     zones = zonefile.__zones__
15     # TODO do something more clever with the zones
16     for zone in zones:
17         zone.write(sys.stdout)
18
19 if __name__ == "__main__":
20     for name in sys.argv[1:]:
21         make_zone(name)
22