From: Michael Tremer Date: Mon, 16 Nov 2020 15:25:15 +0000 (+0000) Subject: database: Filter flags in C X-Git-Tag: 0.9.5~64 X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Flibloc.git;a=commitdiff_plain;h=bd1dc6bf6fe4ce40bf12e7426e283b31afd274e1 database: Filter flags in C Signed-off-by: Michael Tremer --- diff --git a/src/python/export.py b/src/python/export.py index 5e7fe53..739742f 100644 --- a/src/python/export.py +++ b/src/python/export.py @@ -29,7 +29,7 @@ import _location log = logging.getLogger("location.export") log.propagate = 1 -flags = { +FLAGS = { _location.NETWORK_FLAG_ANONYMOUS_PROXY : "A1", _location.NETWORK_FLAG_SATELLITE_PROVIDER : "A2", _location.NETWORK_FLAG_ANYCAST : "A3", @@ -186,12 +186,18 @@ class Exporter(object): # Filter countries from special country codes country_codes = [ - country_code for country_code in countries if not country_code in flags.values() + country_code for country_code in countries if not country_code in FLAGS.values() ] + # Collect flags + flags = 0 + for flag in FLAGS: + if FLAGS[flag] in countries: + flags |= flag + # Get all networks that match the family networks = self.db.search_networks(family=family, - country_codes=country_codes, flatten=True) + country_codes=country_codes, flags=flags, flatten=True) # Walk through all networks for network in networks: @@ -208,10 +214,10 @@ class Exporter(object): pass # Handle flags - for flag in flags: + for flag in FLAGS: if network.has_flag(flag): # Fetch the "fake" country code - country = flags[flag] + country = FLAGS[flag] try: writers[country].write(network)