From patchwork Wed Jun 2 21:00:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Peter_M=C3=BCller?= X-Patchwork-Id: 4390 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4FwLyg2Bvdz3wc6 for ; Wed, 2 Jun 2021 21:00:27 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4FwLyg03yRz9k; Wed, 2 Jun 2021 21:00:27 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4FwLyf665wz2xQs; Wed, 2 Jun 2021 21:00:26 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4FwLyd21HDz2xhP for ; Wed, 2 Jun 2021 21:00:25 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4FwLyb6smlz9k; Wed, 2 Jun 2021 21:00:23 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1622667624; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3mmuX1vPa0Fui7+fqYg2z+lCkLP7rz7IZxgOiCOtqJU=; b=9LlwzZXDbfn32WpvoohGp2DNB0F72X+pKzcdPf+/r4/C3GdZI7yz/VVylLZfRFlaLDfzms 9uk22ONuaPvEhtBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1622667624; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3mmuX1vPa0Fui7+fqYg2z+lCkLP7rz7IZxgOiCOtqJU=; b=D9x2ioA/VHUqmQOtIBwASTJ3uUwah4QEabGXUwmV0j5Vd347LbfJYH4QjikFV7RfKisuYv pkt/0qyOQo0l3+8FWkJUEuxZELTbDjppkMuN/rkG22fIA0ms5G/GHY+7QeyCByalpqnUxf 0YYKwgZSKlopGZ0+HW+GiYgnFjG2WG5TrrY1ybS+nHssVch/bwGQZBG7YlUuvj7SJDmvzI rWYNC8ZrhksSixdtaUPVCuBbH5zv5zqRfSKifIGGsJiFo5T87icY/vsaG3fg2o7vylF+q9 v+WWBF2RbEK5gC4/Ifj2A8E4ZMFxmJMbE+FDTC7cifRIGM4k7LtOYJDQgJfJsA== Subject: [PATCH] location-importer.in: track original countries more pythonic To: Michael Tremer References: <20210522125758.28770-1-peter.mueller@ipfire.org> From: =?utf-8?q?Peter_M=C3=BCller?= Message-ID: <5c46c7bb-4c42-4b8f-28b6-948c7f5641e8@ipfire.org> Date: Wed, 2 Jun 2021 23:00:22 +0200 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-BeenThere: location@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "IPFire: Location" Errors-To: location-bounces@lists.ipfire.org Sender: "Location" https://lists.ipfire.org/pipermail/location/2021-May/000377.html Reported-by: Michael Tremer Signed-off-by: Peter Müller --- src/python/location-importer.in | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/python/location-importer.in b/src/python/location-importer.in index a3c16bc..3e1f859 100644 --- a/src/python/location-importer.in +++ b/src/python/location-importer.in @@ -628,15 +628,17 @@ class CLI(object): inetnum[key] = [ipaddress.ip_network(val, strict=False)] elif key == "country": + val = val.upper() + # Catch RIR data objects with more than one country code... - if not key in inetnum.keys(): + if not key in inetnum: inetnum[key] = [] else: - if val.upper() in inetnum.get("country"): + if val in inetnum.get("country"): # ... but keep this list distinct... continue - inetnum[key].append(val.upper()) + inetnum[key].append(val) # Skip empty objects if not inetnum or not "country" in inetnum: