diff options
| author | Kui Shi <skuicloud@gmail.com> | 2013-10-15 06:50:33 +0800 |
|---|---|---|
| committer | Kui Shi <skuicloud@gmail.com> | 2013-10-21 20:51:15 +0800 |
| commit | 59b0f1c27a7da75e127be713fdc702edfa5204ed (patch) | |
| tree | e01eda381316375701fd5a53f90284483b8e6f1b /troveclient/utils.py | |
| parent | b46248c98fd3dcafb6dba24cf17103d4e644e2e4 (diff) | |
| download | python-troveclient-59b0f1c27a7da75e127be713fdc702edfa5204ed.tar.gz | |
Fix unicode issue
In Python 3, all string is unicode.
Replace unicode() with six.u()
Make use of strutils.to_slug() for slugify() definition
Partial implements: blueprint py33-support
Change-Id: I6a1e19c095a2fbafcbe47b34c7af17e1b0353b9e
Diffstat (limited to 'troveclient/utils.py')
| -rw-r--r-- | troveclient/utils.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/troveclient/utils.py b/troveclient/utils.py index 0cb9d49..3e96d50 100644 --- a/troveclient/utils.py +++ b/troveclient/utils.py @@ -212,10 +212,6 @@ class HookableMixin(object): hook_func(*args, **kwargs) -_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): @@ -224,10 +220,7 @@ def slugify(value): and converts spaces to hyphens. From Django's "django/template/defaultfilters.py". + + Make use strutils.to_slug from openstack common """ - import unicodedata - if not isinstance(value, unicode): - value = unicode(value) - value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore') - value = unicode(_slugify_strip_re.sub('', value).strip().lower()) - return _slugify_hyphenate_re.sub('-', value) + return strutils.to_slug(value, incoming=None, errors="strict") |
