This will lead to some networks showing up twice. Once with
their real country and once with their faked one.
It is likely that the first one will match.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
import os
import socket
+import _location
+
# Initialise logging
log = logging.getLogger("location.export")
log.propagate = 1
+flags = {
+ _location.NETWORK_FLAG_ANONYMOUS_PROXY : "A1",
+ _location.NETWORK_FLAG_SATELLITE_PROVIDER : "A2",
+ _location.NETWORK_FLAG_ANYCAST : "A3",
+}
+
class OutputWriter(object):
suffix = "networks"
mode = "w"
except KeyError:
pass
+ # Handle flags
+ for flag in flags:
+ if network.has_flag(flag):
+ # Fetch the "fake" country code
+ country = flags[flag]
+
+ try:
+ writers[country].write(network)
+ except KeyError:
+ pass
+
# Write everything to the filesystem
for writer in writers.values():
writer.finish()