use strutils.to_slug() instead of utils.slugify()

Change-Id: I4c07728ff795b4f4200256fc7629a29a7b1a4594
Closes-Bug: #1266127
This commit is contained in:
Christian Berendt 2014-05-27 23:48:11 +02:00
parent f9c2578d4e
commit e63cd72cd5
2 changed files with 1 additions and 23 deletions

View File

@ -434,7 +434,7 @@ class Resource(object):
for bash completion.
"""
if self.NAME_ATTR in self.__dict__ and self.HUMAN_ID:
return utils.slugify(getattr(self, self.NAME_ATTR))
return strutils.to_slug(getattr(self, self.NAME_ATTR))
return None
def _add_details(self, info):

View File

@ -14,7 +14,6 @@
import json
import os
import pkg_resources
import re
import sys
import textwrap
import uuid
@ -383,27 +382,6 @@ def import_class(import_str):
__import__(mod_str)
return getattr(sys.modules[mod_str], class_str)
_slugify_strip_re = re.compile(r'[^\w\s-]')
_slugify_hyphenate_re = re.compile(r'[-\s]+')
# http://code.activestate.com/recipes/
# 577257-slugify-make-a-string-usable-in-a-url-or-filename/
def slugify(value):
"""Normalizes string, converts to lowercase, removes non-alpha characters,
and converts spaces to hyphens.
From Django's "django/template/defaultfilters.py".
"""
import unicodedata
if not isinstance(value, six.text_type):
value = six.text_type(value)
value = unicodedata.normalize('NFKD',
value).encode('ascii',
'ignore').decode("ascii")
value = six.text_type(_slugify_strip_re.sub('', value).strip().lower())
return _slugify_hyphenate_re.sub('-', value)
def _load_entry_point(ep_name, name=None):
"""Try to load the entry point ep_name that matches name."""