From 0926e468451e7b4811e0b10fb0df849414704ff6 Mon Sep 17 00:00:00 2001 From: mjtnix Date: Thu, 9 Apr 2009 22:48:37 +0000 Subject: 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 --- freebase-api/freebase/api/mqlkey.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'freebase-api/freebase') 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 -- cgit v1.3.1