本文整理汇总了Python中urllib.urlunquote函数的典型用法代码示例。如果您正苦于以下问题:Python urlunquote函数的具体用法?Python urlunquote怎么用?Python urlunquote使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了urlunquote函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_user_info
def get_user_info(self, auth_token, auth_verifier=""):
"""Get User Info.
Exchanges the auth token for an access token and returns a dictionary
of information about the authenticated user.
"""
auth_token = urlunquote(auth_token)
auth_verifier = urlunquote(auth_verifier)
auth_secret = memcache.get(self._get_memcache_auth_key(auth_token))
if not auth_secret:
logging.error("The auth token %s is missing from memcache" % auth_token)
response = self.make_request(self.access_url,
token=auth_token,
secret=auth_secret,
additional_params={"oauth_verifier":
auth_verifier})
# Extract the access token/secret from the response.
result = self._extract_credentials(response)
# Try to collect some information about this user from the service.
user_info = self._lookup_user_info(result["token"], result["secret"])
user_info.update(result)
return user_info
示例2: get_user_info
def get_user_info(self, auth_token, auth_verifier=""):
"""Get User Info.
Exchanges the auth token for an access token and returns a dictionary
of information about the authenticated user.
"""
auth_token = urlunquote(auth_token)
auth_verifier = urlunquote(auth_verifier)
auth_secret = memcache.get(self._get_memcache_auth_key(auth_token))
if not auth_secret:
result = AuthToken.gql(""" WHERE token = :1 LIMIT 1 """, auth_token).get()
if not result:
logging.error("The auth token %s was not found in our db" % auth_token)
raise Exception, "Could not find Auth Token in database"
else:
auth_secret = result.secret
response = self.make_request(self.access_url,
token=auth_token,
secret=auth_secret,
additional_params={"oauth_verifier":
auth_verifier})
# Extract the access token/secret from the response.
result = self._extract_credentials(response)
# Try to collect some information about this user from the service.
user_info = self._lookup_user_info(result["token"], result["secret"])
user_info.update(result)
return user_info
示例3: _url2path
def _url2path(self,url):
"""Convert a server-side URL into a client-side path."""
path = urlunquote(urlparse(url).path)
root = urlunquote(self._url_p.path)
path = path[len(root)-1:].decode("utf8")
while path.endswith("/"):
path = path[:-1]
return path
示例4: get_access_token
def get_access_token(self, auth_token, auth_verifier):
auth_token = urlunquote(auth_token)
auth_verifier = urlunquote(auth_verifier)
response = self.make_request( self.access_url,
token=auth_token,
additional_params={"oauth_verifier": auth_verifier} )
result = parse_qs(response.content)
return result["user_id"][0], result["oauth_token"][0], result["oauth_token_secret"][0]
示例5: urldecode
def urldecode(qs):
r = []
for pair in qs.replace(';', '&').split('&'):
if not pair: continue
nv = pair.split('=', 1)
if len(nv) != 2: nv.append('')
key = urlunquote(nv[0].replace('+', ' '))
value = urlunquote(nv[1].replace('+', ' '))
r.append((key, value))
return r
示例6: run
def run(self, edit):
for s in self.view.sel():
if s.empty():
s = self.view.word(s)
selected = self.view.substr(s)
try:
txt = urlunquote(selected.encode('utf8')).decode('utf8')
except TypeError:
txt = urlunquote(selected)
self.view.replace(edit, s, txt)
示例7: get_access_token
def get_access_token(self, auth_token, auth_verifier):
auth_token = urlunquote(auth_token)
auth_verifier = urlunquote(auth_verifier)
response = self.make_request(
self.access_url, token=auth_token, additional_params={"oauth_verifier": auth_verifier}
)
# Extract the access token/secret from the response.
result = self._extract_credentials(response)
return result["token"], result["secret"], result["screen_name"]
示例8: from_parsedurl
def from_parsedurl(cls, parsedurl, **kwargs):
auth, host = urllib2.splituser(parsedurl.netloc)
password = parsedurl.password
if password is not None:
password = urlunquote(password)
username = parsedurl.username
if username is not None:
username = urlunquote(username)
# TODO(jelmer): This also strips the username
parsedurl = parsedurl._replace(netloc=host)
return cls(urlparse.urlunparse(parsedurl),
password=password, username=username, **kwargs)
示例9: update_status
def update_status(self, status,auth_token,auth_verifier=""):
auth_token = urlunquote(auth_token)
auth_verifier = urlunquote(auth_verifier)
global auth_secret
response = self.make_request(self.access_url,
token=auth_token,
secret=auth_secret,
additional_params={"oauth_verifier":auth_verifier})
result = self._extract_credentials(response)
data = self._update_status(result["token"], result["secret"],status)
return data
示例10: get_user_info
def get_user_info(self, auth_token, auth_verifier=""):
auth_token = urlunquote(auth_token)
auth_verifier = urlunquote(auth_verifier)
global auth_secret
response = self.make_request(self.access_url,
token=auth_token,
secret=auth_secret,
additional_params={"oauth_verifier":auth_verifier})
result = self._extract_credentials(response)
user_info = self._lookup_user_info(result["token"], result["secret"])
user_info.update(result)
return user_info
示例11: get_user_info
def get_user_info(self, auth_token, auth_verifier=""):
"""Get User Info.
Exchanges the auth token for an access token and returns a dictionary
of information about the authenticated user.
"""
auth_token = urlunquote(auth_token)
auth_verifier = urlunquote(auth_verifier)
auth_secret = memcache.get(self._get_memcache_auth_key(auth_token))
if not auth_secret:
result = AuthToken.gql("""
WHERE
service = :1 AND
token = :2
LIMIT
1
""", self.service_name, auth_token).get()
if not result:
logging.error("The auth token %s was not found in our db" % auth_token)
raise Exception, "Could not find Auth Token in database"
else:
auth_secret = result.secret
response = self.make_request(self.access_url,
token=auth_token,
secret=auth_secret,
additional_params={"oauth_verifier":
auth_verifier})
key_name = ""
username = ""
if self.service_name == 'gdi-acc':
respdict = parse_qs(response.content)
username = respdict['user_name']
key_name = 'id-%s' % uuid4();
# Extract the access token/secret from the response.
result = self._extract_credentials(response)
# Try to collect some information about this user from the service.
#user_info = self._lookup_user_info(result["token"], result["secret"])
#user_info.update(result)
self.set_cookie(key_name)
self.set_cookie_username(username[0])
return username[0]
示例12: parse_content
def parse_content(content):
content_dict = {}
content_pairs = content.split("&")
for content_pair in content_pairs:
k,v = content_pair.split("=")
content_dict[k] = urlunquote(v)
return content_dict
示例13: get_access_token
def get_access_token(self, request_token, verifier):
"""Exchanges a Request Token for an Access Token. Returns (access_token, access_secret).
Note that the access_token and access_secret can be stored, allowing future
requests to be made without going through the happy OAuth dance again.
"""
request_token, verifier = urlunquote(request_token), urlunquote(verifier)
request_secret = self._retrieve_request_secret(request_token)
access_request = self._make_request(self.access_url,
method = 'POST',
token = request_token,
secret = request_secret,
additional_oauth = {"oauth_verifier": verifier})
access_response = self._extract_credentials(access_request)
return (access_response["token"], access_response["secret"])
示例14: verify
def verify(self, request):
""" verify: Called by the external service to verify you authentication request
"""
auth_token = urlunquote(request.get("oauth_token"))
auth_verifier = urlunquote(request.get("oauth_verifier"))
# Extract the access token/secret from the response.
response = self._make_request(self.access_token_url, token=auth_token, secret=self.store['oauth_secret'], additional_params={"oauth_verifier": auth_verifier})
if response.status_code == 200:
data = self._extract_credentials(response)
self.user.credentials = OAuth1Credentials(user_token=data['token'], user_secret=data['secret'])
else:
raise OAuthClientError(response.status_code, response.content)
return super(OAuth1Client, self).verify(request)
示例15: get_user_info
def get_user_info(self, auth_token, auth_verifier=''):
'''Get User Info.
Exchanges the auth token for an access token and returns a dictionary
of information about the authenticated user.
'''
auth_token = urlunquote(auth_token)
auth_verifier = urlunquote(auth_verifier)
auth_secret = memcache.get(self._get_memcache_auth_key(auth_token))
if not auth_secret:
result = AuthToken.gql('''
WHERE
service = :1 AND
token = :2
LIMIT
1
''', self.service_name, auth_token).get()
if not result:
logging.error('The auth token %s was not found in our db' % auth_token)
raise Exception, 'Could not find Auth Token in database'
else:
auth_secret = result.secret
response = self.make_request(self.access_url,
token=auth_token,
secret=auth_secret,
additional_params={'oauth_verifier':
auth_verifier})
# Extract the access token/secret from the response.
result = self._extract_credentials(response)
# Try to collect some information about this user from the service.
user_info = self._lookup_user_info(result['token'], result['secret'])
user_info.update(result)
return user_info