# HG changeset patch # User Tero Marttila # Date 1387480327 -7200 # Node ID 9d7d40206a7451e5e52ecf7d6b92faec01c2c695 # Parent 5ecd1226f4451b1be2fc99a3366c597d046ea8a4 pvl.hosts-import: add --output-others diff -r 5ecd1226f445 -r 9d7d40206a74 bin/pvl.hosts-import --- a/bin/pvl.hosts-import Thu Dec 19 20:06:37 2013 +0200 +++ b/bin/pvl.hosts-import Thu Dec 19 21:12:07 2013 +0200 @@ -82,6 +82,9 @@ parser.add_option('--output-domain', metavar='DOMAIN', help="Select hosts by domain") + parser.add_option('--output-others', action='store_true', + help="Negate selection") + # defaults parser.set_defaults( import_zone_hosts = [], @@ -659,15 +662,22 @@ sort = ipaddr.IPAddress(0) # select + match = True + if prefix: if not (ip and ip in prefix) : - continue + match = False if select_domain : if not (domain and domain == select_domain) : - continue + match = False - yield (domain, sort), (host, domain), fields + if match and options.output_others : + pass + elif not match and not options.output_others : + pass + else : + yield (domain, sort), (host, domain), fields def export_hosts (options, hosts) : """