From dd49c8efb8e047c7bf4a9508974ffe57ced669f3 Mon Sep 17 00:00:00 2001 From: MuK IT GmbH Date: Mon, 15 Oct 2018 18:23:48 +0000 Subject: [PATCH] publish muk_utils - 12.0 --- muk_utils/tools/file.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/muk_utils/tools/file.py b/muk_utils/tools/file.py index 21613ec..308f8c8 100644 --- a/muk_utils/tools/file.py +++ b/muk_utils/tools/file.py @@ -34,6 +34,14 @@ _logger = logging.getLogger(__name__) # File Helper #---------------------------------------------------------- +def slugify(value): + value = str(unicodedata.normalize('NFKD', value)) + if sys.version_info < (3,): + value = str(value.encode('ascii', 'ignore')) + value = str(re.sub('[^\w\s-]', '', value).strip().lower()) + value = str(re.sub('[-\s]+', '-', value)) + return value + def compute_name(name, suffix, escape_suffix): if escape_suffix: name, extension = os.path.splitext(name)