pvl.hosts-import: add --output-others
authorTero Marttila <terom@paivola.fi>
Thu, 19 Dec 2013 21:12:07 +0200
changeset 327 9d7d40206a74
parent 326 5ecd1226f445
child 328 9b4ee4bad3d1
pvl.hosts-import: add --output-others
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) :
     """