From c4716f5f0e5c82a53abd9c06b39952a93f13e2ff Mon Sep 17 00:00:00 2001 From: Fabian Wunsch Date: Sun, 10 Apr 2022 11:56:10 +0200 Subject: [PATCH 1/7] Remove duplicate points using format.py This is acutally a very widespread "problem". There are many entries that have 2 points after each other that are identical. This happens especially often with identical first and last points. This should not alter the appearance in any way. --- tools/formatter.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/formatter.py b/tools/formatter.py index f9af7a1f..5b843b1f 100644 --- a/tools/formatter.py +++ b/tools/formatter.py @@ -120,6 +120,20 @@ def remove_extras(entry: dict): return entry +def remove_duplicate_points(entry: dict): + """ + Removes points from paths that occur twice after each other + """ + path: list = entry['path'] + last: list = path[0] + for i in range(len(path)-1, 0, -1): + current: list = path[i] + if current == last: + path.pop(i) + last = current + + return entry + def fix_r_caps(entry: dict): """ Fixes capitalization of /r/. (/R/place -> /r/place) @@ -298,6 +312,8 @@ def print_(*args, **kwargs): entry = fix_no_protocol_urls(entry) print_("Removing extras...") entry = remove_extras(entry) + print_("removing duplicate points") + entry = remove_duplicate_points(entry) print_("Updating center") entry = update_center(entry) print_("Validating...") From 9b44ba2ab880b4ffb6b9c0ae1b2c27b888d5cb24 Mon Sep 17 00:00:00 2001 From: Fabian Wunsch <42294590+fabi321@users.noreply.github.com> Date: Sun, 10 Apr 2022 13:06:05 +0200 Subject: [PATCH 2/7] Changed the print content Co-authored-by: Hans5958 --- tools/formatter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/formatter.py b/tools/formatter.py index 5b843b1f..6fb46369 100644 --- a/tools/formatter.py +++ b/tools/formatter.py @@ -312,7 +312,7 @@ def print_(*args, **kwargs): entry = fix_no_protocol_urls(entry) print_("Removing extras...") entry = remove_extras(entry) - print_("removing duplicate points") + print_("Removing duplicate points...") entry = remove_duplicate_points(entry) print_("Updating center") entry = update_center(entry) From 2ea0e48a1a16880f2844b11c5843dca88b8825ab Mon Sep 17 00:00:00 2001 From: Fabian Wunsch Date: Sun, 10 Apr 2022 13:12:37 +0200 Subject: [PATCH 3/7] Off by one error --- tools/formatter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/formatter.py b/tools/formatter.py index 6fb46369..94752a22 100644 --- a/tools/formatter.py +++ b/tools/formatter.py @@ -126,7 +126,7 @@ def remove_duplicate_points(entry: dict): """ path: list = entry['path'] last: list = path[0] - for i in range(len(path)-1, 0, -1): + for i in range(len(path)-1, -1, -1): current: list = path[i] if current == last: path.pop(i) From da58a130582efe408700af404b57e1df49e2fd97 Mon Sep 17 00:00:00 2001 From: Fabian Wunsch Date: Sun, 10 Apr 2022 13:48:29 +0200 Subject: [PATCH 4/7] Small consistency improvement --- tools/formatter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/formatter.py b/tools/formatter.py index 94752a22..a89e620d 100644 --- a/tools/formatter.py +++ b/tools/formatter.py @@ -314,7 +314,7 @@ def print_(*args, **kwargs): entry = remove_extras(entry) print_("Removing duplicate points...") entry = remove_duplicate_points(entry) - print_("Updating center") + print_("Updating center...") entry = update_center(entry) print_("Validating...") status_code = validate(entry) From 37d43251867a14f4744b8366ec8d106c5d7d2016 Mon Sep 17 00:00:00 2001 From: Fabian Wunsch Date: Sun, 10 Apr 2022 13:53:31 +0200 Subject: [PATCH 5/7] Small naming improvement for better clarity --- tools/formatter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/formatter.py b/tools/formatter.py index a89e620d..9ab82725 100644 --- a/tools/formatter.py +++ b/tools/formatter.py @@ -125,12 +125,12 @@ def remove_duplicate_points(entry: dict): Removes points from paths that occur twice after each other """ path: list = entry['path'] - last: list = path[0] + previous: list = path[0] for i in range(len(path)-1, -1, -1): current: list = path[i] - if current == last: + if current == previous: path.pop(i) - last = current + previous = current return entry From 149a1e4209720ff96e7250ba06c460332a0d22a5 Mon Sep 17 00:00:00 2001 From: Fabian Wunsch Date: Sun, 10 Apr 2022 13:58:13 +0200 Subject: [PATCH 6/7] Changed indentation from spaces to tabs --- tools/formatter.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/formatter.py b/tools/formatter.py index 9ab82725..8c480847 100644 --- a/tools/formatter.py +++ b/tools/formatter.py @@ -121,18 +121,18 @@ def remove_extras(entry: dict): return entry def remove_duplicate_points(entry: dict): - """ - Removes points from paths that occur twice after each other - """ - path: list = entry['path'] - previous: list = path[0] - for i in range(len(path)-1, -1, -1): - current: list = path[i] - if current == previous: - path.pop(i) - previous = current + """ + Removes points from paths that occur twice after each other + """ + path: list = entry['path'] + previous: list = path[0] + for i in range(len(path)-1, -1, -1): + current: list = path[i] + if current == previous: + path.pop(i) + previous = current - return entry + return entry def fix_r_caps(entry: dict): """ From ed084ac9369b039100510e9da6fa38e47859156c Mon Sep 17 00:00:00 2001 From: Fabian Wunsch Date: Sun, 10 Apr 2022 15:32:50 +0200 Subject: [PATCH 7/7] Fixed logical indentation error --- tools/formatter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/formatter.py b/tools/formatter.py index 8c480847..44cfdeed 100644 --- a/tools/formatter.py +++ b/tools/formatter.py @@ -130,7 +130,7 @@ def remove_duplicate_points(entry: dict): current: list = path[i] if current == previous: path.pop(i) - previous = current + previous = current return entry