648
|
1 |
#!/usr/bin/env python
|
|
2 |
|
|
3 |
"""
|
|
4 |
Extract a list of $INCLUDE paths from a zone file.
|
|
5 |
"""
|
|
6 |
|
|
7 |
import logging; log = logging.getLogger('pvl.dns-includes')
|
|
8 |
import optparse
|
|
9 |
import pvl.args
|
|
10 |
import pvl.dns
|
|
11 |
import pvl.dns.process
|
|
12 |
|
|
13 |
def main (argv):
|
|
14 |
parser = optparse.OptionParser(main.__doc__)
|
|
15 |
parser.add_option_group(pvl.args.parser(parser))
|
|
16 |
parser.add_option_group(pvl.dns.process.optparser(parser))
|
|
17 |
|
|
18 |
parser.add_option('--include-path', metavar='PATH',
|
|
19 |
help="Rewrite includes to given absolute path")
|
|
20 |
|
|
21 |
# input
|
|
22 |
options, args = pvl.args.parse(parser, argv)
|
|
23 |
|
|
24 |
# process
|
|
25 |
zone = list(pvl.dns.process.apply_zone(options, args))
|
|
26 |
|
|
27 |
if options.include_path:
|
|
28 |
log.info("Set zone include path: %s", options.include_path)
|
|
29 |
|
|
30 |
zone = list(pvl.dns.process.zone_includes_path(zone, options.include_path))
|
|
31 |
|
|
32 |
for include in pvl.dns.process.zone_includes(zone):
|
|
33 |
# output include path only
|
|
34 |
print include
|
|
35 |
|
|
36 |
return 0
|
|
37 |
|
|
38 |
if __name__ == '__main__':
|
|
39 |
pvl.args.main(main)
|