location-importer.in: Do not make things more complicated than they are

Message ID b9338bb9-1212-dccf-d134-c8a91fff2b46@ipfire.org
State Accepted
Commit 38d0faeabb9f7cea8394521a45f9ed204a4e16fb
Headers
Series location-importer.in: Do not make things more complicated than they are |

Commit Message

Peter Müller Dec. 18, 2021, 12:57 p.m. UTC
  Suggested-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
---
 src/python/location-importer.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Michael Tremer Dec. 20, 2021, 4:54 p.m. UTC | #1
Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>

> On 18 Dec 2021, at 13:57, Peter Müller <peter.mueller@ipfire.org> wrote:
> 
> Suggested-by: Michael Tremer <michael.tremer@ipfire.org>
> Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
> ---
> src/python/location-importer.in | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/python/location-importer.in b/src/python/location-importer.in
> index 118b0de..f39a42b 100644
> --- a/src/python/location-importer.in
> +++ b/src/python/location-importer.in
> @@ -687,7 +687,7 @@ class CLI(object):
> 						start_address = ipaddress.ip_network(start_address, strict=False)
> 					except ValueError:
> 						start_address = start_address.split("/")
> -						ldigits = len(start_address[0].split("."))
> +						ldigits = start_address[0].count(".")
> 
> 						# How many octets do we need to add?
> 						# (LACNIC does not seem to have a /8 or greater assigned, so the following should suffice.)
> -- 
> 2.26.2
  

Patch

diff --git a/src/python/location-importer.in b/src/python/location-importer.in
index 118b0de..f39a42b 100644
--- a/src/python/location-importer.in
+++ b/src/python/location-importer.in
@@ -687,7 +687,7 @@  class CLI(object):
 						start_address = ipaddress.ip_network(start_address, strict=False)
 					except ValueError:
 						start_address = start_address.split("/")
-						ldigits = len(start_address[0].split("."))
+						ldigits = start_address[0].count(".")
 
 						# How many octets do we need to add?
 						# (LACNIC does not seem to have a /8 or greater assigned, so the following should suffice.)