Skip to content

Commit

Permalink
use unidecode instead of custom strip_accents function
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rc1e committed Jun 15, 2021
1 parent 3a3c91e commit 33c520d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
5 changes: 0 additions & 5 deletions Lib/gftools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,3 @@ def read_proto(fp, schema):
with open(fp, "rb") as f:
data = text_format.Parse(f.read(), schema)
return data


def strip_accents(string):
"""Remove accents from a string e.g 'àce' --> 'ace'"""
return "".join([uni.normalize("NFD", x)[0] for x in string])
6 changes: 3 additions & 3 deletions bin/gftools-add-designer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from gftools.designers_pb2 import DesignerInfoProto
from google.protobuf import text_format
from pandas.core.base import PandasObject
from gftools.utils import strip_accents
from unidecode import unidecode


def process_image(fp):
Expand Down Expand Up @@ -110,8 +110,8 @@ def make_designer(
bio=None,
urls=None,
):
designer_dir_name = strip_accents(
name.lower().replace(" ", "").replace("-", "")
designer_dir_name = unidecode(
name.lower().replace(" ", "").replace("-", ""), "strict",
)
designer_dir = os.path.join(designer_directory, designer_dir_name)
if not os.path.isdir(designer_dir):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ skia-pathops
pandas
xlrd
openpyxl
unicdecode
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@ def gftools_scripts():
'pandas',
'xlrd',
'openpyxl',
'unidecode',
]
)

0 comments on commit 33c520d

Please sign in to comment.