2 ###############################################################################
4 # libloc - A library to determine the location of someone on the Internet #
6 # Copyright (C) 2024 IPFire Development Team <info@ipfire.org> #
8 # This library is free software; you can redistribute it and/or #
9 # modify it under the terms of the GNU Lesser General Public #
10 # License as published by the Free Software Foundation; either #
11 # version 2.1 of the License, or (at your option) any later version. #
13 # This library is distributed in the hope that it will be useful, #
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
16 # Lesser General Public License for more details. #
18 ###############################################################################
23 from location
.i18n
import _
26 location
.NETWORK_FLAG_ANONYMOUS_PROXY
,
27 location
.NETWORK_FLAG_SATELLITE_PROVIDER
,
28 location
.NETWORK_FLAG_ANYCAST
,
29 location
.NETWORK_FLAG_DROP
,
32 def copy_all(db
, writer
):
35 writer
.vendor
= db
.vendor
39 writer
.description
= db
.description
43 writer
.license
= db
.license
47 new
= writer
.add_as(old
.number
)
51 for old
in db
.networks
:
52 new
= writer
.add_network("%s" % old
)
55 new
.country_code
= old
.country_code
63 if old
.has_flag(flag
):
67 for old
in db
.countries
:
68 new
= writer
.add_country(old
.code
)
71 new
.continent_code
= old
.continent_code
80 parser
= argparse
.ArgumentParser(
81 description
=_("Copies a location database"),
85 parser
.add_argument("input-file", help=_("File to read"))
88 parser
.add_argument("output-file", help=_("File to write"))
91 args
= parser
.parse_args()
93 input_file
= getattr(args
, "input-file")
94 output_file
= getattr(args
, "output-file")
97 db
= location
.Database(input_file
)
100 writer
= location
.Writer()
106 writer
.write(output_file
)