Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP1:Update
geolite2legacy
0001-Automatically-determine-output-file-name.p...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Automatically-determine-output-file-name.patch of Package geolite2legacy
From 8af9043a9f951b4f95e7a447a15e67b1f36c881b Mon Sep 17 00:00:00 2001 From: Ludwig Nussel <ludwig.nussel@suse.de> Date: Mon, 30 Dec 2019 13:43:04 +0100 Subject: [PATCH] Automatically determine output file name --- geolite2legacy.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/geolite2legacy.py b/geolite2legacy.py index 0b4975b..43969ea 100755 --- a/geolite2legacy.py +++ b/geolite2legacy.py @@ -358,6 +358,11 @@ RTree = { 'ASN': {'IPv4': ASNRadixTree, 'IPv6': ASNv6RadixTree} } +Filenames = { + 'Country': {'IPv4': "GeoIP.dat", 'IPv6': "GeoIPv6.dat"}, + 'City': {'IPv4': "GeoIPCity.dat", 'IPv6': "GeoIPCityv6.dat"}, + 'ASN': {'IPv4': "GeoIPASNum.dat", 'IPv6': "GeoIPASNumv6.dat"} +} def parse_fips(fipsfile): with open(fipsfile) as f: @@ -371,7 +376,7 @@ def main(): parser = argparse.ArgumentParser() parser.add_argument('-i', '--input-file', required=True, help='input zip file containings csv databases') - parser.add_argument('-o', '--output-file', required=True, help='output GeoIP dat file') + parser.add_argument('-o', '--output-file', help='output GeoIP dat file') parser.add_argument('-f', '--fips-file', help='geonameid to fips code mappings') parser.add_argument('-e', '--encoding', help='encoding to use for the output rather than utf-8') parser.add_argument('-d', '--debug', action='store_true', default=False, help='debug mode') @@ -441,6 +446,10 @@ def main(): r.load(locs, TextIOWrapper(ziparchive.open(blocks, 'r'), encoding='utf-8')) + if not opts.output_file: + opts.output_file = Filenames[dbtype][opts.ipv6] + print('Output file {}'.format(opts.output_file)) + with open(opts.output_file, 'wb') as output: r.serialize(output) -- 2.16.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor