From 57a8293ff831a5c6b079cb7b439f5f0e9a2143de Mon Sep 17 00:00:00 2001 From: mcarans Date: Thu, 27 Jun 2024 13:41:44 +1200 Subject: [PATCH] simplify and test --- src/hdx/location/names.py | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/src/hdx/location/names.py b/src/hdx/location/names.py index 93ca3b1..26f879a 100644 --- a/src/hdx/location/names.py +++ b/src/hdx/location/names.py @@ -32,35 +32,12 @@ def clean_name(name: str) -> str: """ # Replace all non-ASCII characters with equivalent if available or remove chars = [] -# space = False for x in unicodedata.normalize("NFD", name): - match ord(x): - case num if 97 <= num < 123: - chars.append(x) -# space = False - case num if 65 <= num < 91: - chars.append(chr(num + 32)) -# space = False - # case num if 32 <= num < 39: - # if space: - # continue - # chars.append(" ") - # space = True - # case num if 39 <= num < 65: - # if space: - # continue - # chars.append(" ") - # space = True - # case num if 91 <= num < 97: - # if space: - # continue - # chars.append(" ") - # space = True - # case num if 123 <= num < 127: - # if space: - # continue - # chars.append(" ") - # space = True - case _: - continue + ordch = ord(x) + if 97 <= ordch < 123: + chars.append(x) + elif 65 <= ordch < 91: + chars.append(chr(ordch + 32)) + else: + continue return "".join(chars).strip()