Skip to content

Commit

Permalink
simplify and test
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarans committed Jun 27, 2024
1 parent 74686a8 commit ae33701
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/hdx/location/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,35 @@ def clean_name(name: str) -> str:
"""
# Replace all non-ASCII characters with equivalent if available or remove
chars = []
space = False
# space = False
for x in unicodedata.normalize("NFD", name):
match ord(x):
case num if 97 <= num < 123:
chars.append(x)
space = False
# 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
# 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
return "".join(chars).strip()

0 comments on commit ae33701

Please sign in to comment.