summaryrefslogtreecommitdiff
path: root/freebase-api
diff options
context:
space:
mode:
authormjtnix <mjtnix@5914aa95-5b3a-0410-a3b5-7b719e7fe9b2>2009-04-09 22:48:37 +0000
committermjtnix <mjtnix@5914aa95-5b3a-0410-a3b5-7b719e7fe9b2>2009-04-09 22:48:37 +0000
commit0926e468451e7b4811e0b10fb0df849414704ff6 (patch)
tree78222345ea5387b77d0d51196c15d72f1be14f3f /freebase-api
parent08f6ac4b43741012cfd4b40d6e80d8b5a6cbdf56 (diff)
include the code for urlencode_pathseg rather than referring to an internal piece of code.
git-svn-id: http://freebase-python.googlecode.com/svn/trunk@56 5914aa95-5b3a-0410-a3b5-7b719e7fe9b2
Diffstat (limited to 'freebase-api')
-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