Skip to content

Commit

Permalink
make designer dirs ascii
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rc1e committed Jun 14, 2021
1 parent 189eb09 commit 70974c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Lib/gftools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from configparser import ConfigParser
else:
from ConfigParser import ConfigParser
import unicodedata as uni

# =====================================
# HELPER FUNCTIONS
Expand Down Expand Up @@ -504,3 +505,7 @@ def read_proto(fp, schema):
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])
5 changes: 4 additions & 1 deletion bin/gftools-add-designer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +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


def process_image(fp):
Expand Down Expand Up @@ -96,7 +97,9 @@ def make_designer(
bio=None,
urls=None,
):
designer_dir_name = name.lower().replace(" ", "").replace("-", "")
designer_dir_name = strip_accents(
name.lower().replace(" ", "").replace("-", "")
)
designer_dir = os.path.join(designer_directory, designer_dir_name)
if not os.path.isdir(designer_dir):
print(f"{name} isn't in catalog. Creating new dir {designer_dir}")
Expand Down

0 comments on commit 70974c5

Please sign in to comment.