]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
location: Fix correct set name when family is selected
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Jul 2023 14:53:50 +0000 (14:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Jul 2023 14:53:50 +0000 (14:53 +0000)
This does however not fix the problem if no --family= parameter is being
given because we will then export for multiple families in one file.

This is for example not supported for ipset.

Fixes: #12897
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/location.in

index be13156b2509ec24c3c5bef84a3dfcfca3feb2cb..60b11d636622a2f0e380f9cf71a7233c04936ee6 100644 (file)
@@ -514,7 +514,7 @@ class CLI(object):
                writer = self.__get_output_formatter(ns)
 
                for asn in ns.asn:
-                       f = writer("AS%s" % asn, f=sys.stdout)
+                       f = writer("AS%s" % asn, family=ns.family, f=sys.stdout)
 
                        # Print all matching networks
                        for n in db.search_networks(asns=[asn], family=ns.family):
@@ -527,7 +527,7 @@ class CLI(object):
 
                for country_code in ns.country_code:
                        # Open standard output
-                       f = writer(country_code, f=sys.stdout)
+                       f = writer(country_code, family=ns.family, f=sys.stdout)
 
                        # Print all matching networks
                        for n in db.search_networks(country_codes=[country_code], family=ns.family):
@@ -554,7 +554,7 @@ class CLI(object):
                        raise ValueError(_("You must at least pass one flag"))
 
                writer = self.__get_output_formatter(ns)
-               f = writer("custom", f=sys.stdout)
+               f = writer("custom", family=ns.family, f=sys.stdout)
 
                for n in db.search_networks(flags=flags, family=ns.family):
                        f.write(n)
@@ -563,7 +563,7 @@ class CLI(object):
 
        def handle_list_bogons(self, db, ns):
                writer = self.__get_output_formatter(ns)
-               f = writer("bogons", f=sys.stdout)
+               f = writer("bogons", family=ns.family, f=sys.stdout)
 
                for n in db.list_bogons(family=ns.family):
                        f.write(n)