Skip to content

Commit

Permalink
bug fixed, if id is a unicode instance
Browse files Browse the repository at this point in the history
  • Loading branch information
hepochen committed Oct 22, 2013
1 parent cfd5f03 commit d56a399
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pyes/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import base64
from urllib import quote
from urllib import quote as _quote
import array
import uuid

__all__ = ['clean_string', "ESRange", "ESRangeOp", "string_b64encode", "string_b64decode", "make_path", "make_id"]

def quote(value):
value = value.encode('utf8', errors='ignore') if isinstance(value, unicode) else str(value)
return _quote(value, safe='')

def make_id(value):
"""
Build a string id from a value
Expand All @@ -24,7 +28,7 @@ def make_path(*path_components):
"""
Smash together the path components. Empty components will be ignored.
"""
path_components = [quote(str(component), "") for component in path_components if component]
path_components = [quote(component) for component in path_components if component]
path = '/'.join(path_components)
if not path.startswith('/'):
path = '/' + path
Expand Down

0 comments on commit d56a399

Please sign in to comment.