本文整理汇总了Python中urllib.urlunquote函数的典型用法代码示例。如果您正苦于以下问题:Python urlunquote函数的具体用法?Python urlunquote怎么用?Python urlunquote使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了urlunquote函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:ebby,项目名称:brokentv,代码行数:29,代码来源:oauth.py
示例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
开发者ID:pee,项目名称:hpt,代码行数:34,代码来源:twitterauth.py
示例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
开发者ID:DANCEcollaborative,项目名称:forum-xblock,代码行数:8,代码来源:__init__.py
示例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]
开发者ID:yukixz,项目名称:tweetcntd-gae,代码行数:9,代码来源:oauth.py
示例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
开发者ID:caser789,项目名称:cocopot,代码行数:10,代码来源:utils.py
示例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)
开发者ID:titoBouzout,项目名称:hasher,代码行数:10,代码来源:hasher.py
示例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"]
开发者ID:xwl,项目名称:gtap,代码行数:11,代码来源:oauth.py
示例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)
开发者ID:mjmaenpaa,项目名称:dulwich,代码行数:12,代码来源:client.py
示例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
开发者ID:dongyuwei,项目名称:oauth4sinaweibo,代码行数:12,代码来源:oauth4sina.py
示例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
开发者ID:dongyuwei,项目名称:oauth4sinaweibo,代码行数:13,代码来源:oauth4sina.py
示例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]
开发者ID:nuhajat,项目名称:chat,代码行数:50,代码来源:oauth.py
示例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
开发者ID:montsamu,项目名称:bullspec,代码行数:7,代码来源:bullpay.py
示例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"])
开发者ID:jwintersinger,项目名称:twitinerary,代码行数:16,代码来源:ohauth.py
示例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)
开发者ID:aadjemonkeyrock,项目名称:memovent,代码行数:17,代码来源:client.py
示例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
开发者ID:maxeng,项目名称:han-ra,代码行数:41,代码来源:oauth.py
示例16: verify
def verify(self, request):
connected = False
if self.version == '1.0':
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_url, token=auth_token, secret=self.tokens.oauth_secret, additional_params={"oauth_verifier": auth_verifier})
if response.status_code == 200:
data = self._extract_credentials(response)
self.modified = datetime.datetime.now()
self.tokens.oauth_user_token = data['token']
self.tokens.oauth_user_secret = data['secret']
self.tokens.put()
connected = True
elif self.version == '2.0':
# prepare a post to get the access code
params = {
"grant_type": "authorization_code",
"client_id": self.consumer_key,
"client_secret": self.consumer_secret,
"redirect_uri": self.callback_url
}
params_str = "code=" + request.get("code") + "&" + urlencode(params)
response = urlfetch.fetch(self.access_url, method=urlfetch.POST, payload=params_str, deadline=20, follow_redirects=True)
if response.status_code == 200:
data = json.loads(response.content)
self.tokens.modified = datetime.datetime.now()
self.tokens.oauth_access_token = data["access_token"]
self.tokens.oauth_refresh_token = data["refresh_token"]
self.tokens.oauth_expires_in = data["expires_in"]
self.tokens.put()
connected = True
else:
raise Error(response.status_code, response.content)
if connected: # Get the user information
self.setUserInfo()
开发者ID:aadjemonkeyrock,项目名称:exactapi,代码行数:41,代码来源:base.py
示例17: _cover_from_html
def _cover_from_html(self, hcover):
from calibre.ebooks import render_html_svg_workaround
with TemporaryDirectory('_html_cover') as tdir:
writer = OEBWriter()
writer(self.oeb, tdir)
path = os.path.join(tdir, urlunquote(hcover.href))
data = render_html_svg_workaround(path, self.logger)
if not data:
data = ''
id, href = self.oeb.manifest.generate('cover', 'cover.jpg')
item = self.oeb.manifest.add(id, href, JPEG_MIME, data=data)
return item
开发者ID:mihailim,项目名称:calibre,代码行数:12,代码来源:reader.py
示例18: get_user_info
def get_user_info(self, auth_token, auth_verifier="", detailed_info=False):
"""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)
key = AuthToken.key_name(self.service_name, auth_token)
auth_model = memcache.get(key) # @UndefinedVariable
if not auth_model:
auth_model = AuthToken.get_by_key_name(key)
if not auth_model:
logging.error("The auth token %s was not found in our db" % auth_token)
raise Exception, "Could not find Auth Token in database"
if not auth_model.auth_token:
response = self.make_request(self.access_url, token=auth_token, secret=auth_model.secret,
additional_params={"oauth_verifier": auth_verifier})
# Extract the access token/secret from the response.
result = self._extract_credentials(response)
auth_model.auth_token = json.dumps(result)
auth_model.put()
memcache.set(key, auth_model, 20 * 60) # @UndefinedVariable
else:
result = json.loads(auth_model.auth_token)
# Try to collect some information about this user from the service.
if detailed_info:
user_info = self._lookup_user_info(result["token"], result["secret"])
user_info.update(result)
return user_info
else:
return result
开发者ID:gitter-badger,项目名称:rogerthat-backend,代码行数:39,代码来源:oauth.py
示例19: href_to_name
def href_to_name(self, href, base=None):
"""
Convert an href (relative to base) to a name (i.e. a path
relative to self.root with POSIX separators).
base must be an absolute path with OS separators or None, in which case
the href is interpreted relative to the dir containing the OPF.
"""
if base is None:
base = self.opf_dir
href = urlunquote(href.partition("#")[0])
fullpath = os.path.join(base, *href.split("/"))
return self.abspath_to_name(fullpath)
开发者ID:john-peterson,项目名称:calibre,代码行数:13,代码来源:container.py
示例20: lambda_handler
def lambda_handler(event, context):
bucketname = 'dbarnetttestimageforlambda'
tilex, tiley = urlunquote(event['coords']).strip("()").replace(' ', '').split(',')
zoom = event['zoom']
keyname = Key="%s:%s:%s" % (zoom, tilex, tiley)
s3 = boto3.resource('s3')
try:
#s3.Bucket(bucketname).get_object(keyname)
s3.Object(bucketname, keyname).load()
except botocore.exceptions.ClientError as e:
Mandel(int(zoom), int(tilex), int(tiley))
s3.Bucket(bucketname).put_object(Key=keyname, Body=open('/tmp/tile.png', 'rb'))
return json.loads('{"location": "https://s3-us-west-2.amazonaws.com/%s/%s"}' % (bucketname, keyname))
开发者ID:dhbarnett,项目名称:lambdel,代码行数:13,代码来源:lambda_handler.py
注:本文中的urllib.urlunquote函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论