summaryrefslogtreecommitdiff
path: root/freebase-api/freebase
diff options
context:
space:
mode:
Diffstat (limited to 'freebase-api/freebase')
-rwxr-xr-xfreebase-api/freebase/api/mqlkey.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/freebase-api/freebase/api/mqlkey.py b/freebase-api/freebase/api/mqlkey.py
index 98b7d83..d7dd01b 100755
--- a/freebase-api/freebase/api/mqlkey.py
+++ b/freebase-api/freebase/api/mqlkey.py
@@ -96,15 +96,21 @@ def unquotekey(key, encoding=None):
return ustr.encode(encoding)
+# should this also include "'()" into safe?
+def urlencode_pathseg(data):
+ '''
+ urlencode for placement between slashes in an url.
+ '''
+ if isinstance(data, unicode):
+ data = data.encode('utf_8')
+ return urllib.quote(data, "~:@$!*,;=&+")
+
def id_to_urlid(id):
"""
convert a mql id to an id suitable for embedding in a url path.
"""
- # XXX shouldn't be in metaweb.api!
- from mw.formats.http import urlencode_pathseg
-
segs = id.split('/')
assert isinstance(id, str) and id != '', 'bad id "%s"' % id