diff --git a/novaclient/base.py b/novaclient/base.py index 38434c282..517d13779 100644 --- a/novaclient/base.py +++ b/novaclient/base.py @@ -442,7 +442,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): diff --git a/novaclient/utils.py b/novaclient/utils.py index e7e848173..7668ebfd0 100644 --- a/novaclient/utils.py +++ b/novaclient/utils.py @@ -14,7 +14,6 @@ import json import os import pkg_resources -import re import sys import textwrap import uuid @@ -381,27 +380,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."""