• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python urlparse.parse_qsl函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中urlparse.parse_qsl函数的典型用法代码示例。如果您正苦于以下问题:Python parse_qsl函数的具体用法?Python parse_qsl怎么用?Python parse_qsl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parse_qsl函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_get_download_url_aurora_l10n

 def test_get_download_url_aurora_l10n(self):
     """Aurora non en-US should have a slightly different product name."""
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'win', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-aurora-latest-l10n'),
                           ('os', 'win'),
                           ('lang', 'pt-BR')])
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'win64', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-aurora-latest-l10n'),
                           ('os', 'win64'),
                           ('lang', 'pt-BR')])
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'osx', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-aurora-latest-l10n'),
                           ('os', 'osx'),
                           ('lang', 'pt-BR')])
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'linux', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-aurora-latest-l10n'),
                           ('os', 'linux'),
                           ('lang', 'pt-BR')])
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'linux64', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-aurora-latest-l10n'),
                           ('os', 'linux64'),
                           ('lang', 'pt-BR')])
开发者ID:JosephBywater,项目名称:bedrock,代码行数:27,代码来源:test_firefox_details.py


示例2: get_download_url_ssl

    def get_download_url_ssl(self):
        """
        SSL-enabled links should always be used except Windows stub installers.
        """

        # SSL-enabled links won't be used for Windows builds (but SSL download
        # is enabled by default for stub installers)
        url = firefox_desktop.get_download_url('release', '27.0', 'win', 'pt-BR', True)
        self.assertListEqual(parse_qsl(urlparse(url).query),
                             [('product', 'firefox-27.0'),
                              ('os', 'win'),
                              ('lang', 'pt-BR')])

        # SSL-enabled links will be used for OS X builds
        url = firefox_desktop.get_download_url('release', '27.0', 'osx', 'pt-BR', True)
        self.assertListEqual(parse_qsl(urlparse(url).query),
                             [('product', 'firefox-27.0-SSL'),
                              ('os', 'osx'),
                              ('lang', 'pt-BR')])

        # SSL-enabled links will be used for Linux builds
        url = firefox_desktop.get_download_url('release', '27.0', 'linux', 'pt-BR', True)
        self.assertListEqual(parse_qsl(urlparse(url).query),
                             [('product', 'firefox-27.0-SSL'),
                              ('os', 'linux'),
                              ('lang', 'pt-BR')])
开发者ID:TheoChevalier,项目名称:bedrock,代码行数:26,代码来源:test_firefox_details.py


示例3: get_download_url_ssl

    def get_download_url_ssl(self):
        """
        SSL-enabled links should be used for the specific verions, except the
        Windows stub installers.
        """

        # SSL-enabled links won't be used for 26.0
        url = firefox_details.get_download_url("OS X", "pt-BR", "26.0")
        self.assertListEqual(
            parse_qsl(urlparse(url).query), [("product", "firefox-26.0"), ("os", "osx"), ("lang", "pt-BR")]
        )

        # SSL-enabled links won't be used for 27.0 Windows builds (but SSL
        # download is enabled by default for stub installers)
        url = firefox_details.get_download_url("Windows", "pt-BR", "27.0")
        self.assertListEqual(
            parse_qsl(urlparse(url).query), [("product", "firefox-27.0"), ("os", "win"), ("lang", "pt-BR")]
        )

        # SSL-enabled links will be used for 27.0 OS X builds
        url = firefox_details.get_download_url("OS X", "pt-BR", "27.0")
        self.assertListEqual(
            parse_qsl(urlparse(url).query), [("product", "firefox-27.0-SSL"), ("os", "osx"), ("lang", "pt-BR")]
        )

        # SSL-enabled links will be used for 27.0 Linux builds
        url = firefox_details.get_download_url("Linux", "pt-BR", "27.0")
        self.assertListEqual(
            parse_qsl(urlparse(url).query), [("product", "firefox-27.0-SSL"), ("os", "linux"), ("lang", "pt-BR")]
        )
开发者ID:RiteshBhat,项目名称:bedrock,代码行数:30,代码来源:tests.py


示例4: collect_parameters

def collect_parameters(uri_query=None, authorization_header=None, body=None, exclude_oauth_signature=True):
    """Collect parameters from the uri query, authorization header, and request
    body.
    Per `section 3.4.1.3.1`_ of the spec.

    .. _`section 3.4.1.3.1`: http://tools.ietf.org/html/rfc5849#section-3.4.1.3.1
    """
    params = []

    if uri_query is not None:
        params.extend(urlparse.parse_qsl(uri_query))

    if authorization_header is not None:
        params.extend(utils.parse_authorization_header(authorization_header))

    if body is not None:
        params.extend(urlparse.parse_qsl(body))

    exclude_params = [u"realm"]
    if exclude_oauth_signature:
        exclude_params.append(u"oauth_signature")

    params = filter(lambda i: i[0] not in exclude_params, params)

    return params
开发者ID:ghickman,项目名称:oauthlib,代码行数:25,代码来源:signature.py


示例5: test_get_download_url_nightly_full

 def test_get_download_url_nightly_full(self):
     """
     The Aurora version should give us a bouncer url. For Windows, a full url
     should be returned.
     """
     url = firefox_desktop.get_download_url('nightly', '50.0a1', 'win', 'en-US', True, True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-nightly-latest-ssl'),
                           ('os', 'win'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('nightly', '50.0a1', 'win64', 'en-US', True, True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-nightly-latest-ssl'),
                           ('os', 'win64'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('nightly', '50.0a1', 'osx', 'en-US', True, True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-nightly-latest-ssl'),
                           ('os', 'osx'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('nightly', '50.0a1', 'linux', 'en-US', True, True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-nightly-latest-ssl'),
                           ('os', 'linux'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('nightly', '50.0a1', 'linux64', 'en-US', True, True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-nightly-latest-ssl'),
                           ('os', 'linux64'),
                           ('lang', 'en-US')])
开发者ID:TheoChevalier,项目名称:bedrock,代码行数:30,代码来源:test_firefox_details.py


示例6: test_get_download_url_devedition_full

 def test_get_download_url_devedition_full(self):
     """
     The Developer Edition version should give us a bouncer url. For Windows,
     a full url should be returned.
     """
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'win', 'en-US', True, True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-devedition-latest-ssl'),
                           ('os', 'win'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'win64', 'en-US', True, True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-devedition-latest-ssl'),
                           ('os', 'win64'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'osx', 'en-US', True, True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-devedition-latest-ssl'),
                           ('os', 'osx'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'linux', 'en-US', True, True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-devedition-latest-ssl'),
                           ('os', 'linux'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'linux64', 'en-US', True, True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-devedition-latest-ssl'),
                           ('os', 'linux64'),
                           ('lang', 'en-US')])
开发者ID:RickieES,项目名称:bedrock,代码行数:30,代码来源:test_firefox_details.py


示例7: test_get_download_url_nightly_l10n

 def test_get_download_url_nightly_l10n(self):
     """
     The Nightly version should give us a bouncer url. A stub url should be
     returned for win32/64, while other platforms get a full url. The product
     name is slightly different from en-US.
     """
     url = firefox_desktop.get_download_url('nightly', '50.0a1', 'win', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-nightly-stub'),
                           ('os', 'win'),
                           ('lang', 'pt-BR')])
     url = firefox_desktop.get_download_url('nightly', '50.0a1', 'win64', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-nightly-stub'),
                           ('os', 'win64'),
                           ('lang', 'pt-BR')])
     url = firefox_desktop.get_download_url('nightly', '50.0a1', 'osx', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-nightly-latest-l10n-ssl'),
                           ('os', 'osx'),
                           ('lang', 'pt-BR')])
     url = firefox_desktop.get_download_url('nightly', '50.0a1', 'linux', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-nightly-latest-l10n-ssl'),
                           ('os', 'linux'),
                           ('lang', 'pt-BR')])
     url = firefox_desktop.get_download_url('nightly', '50.0a1', 'linux64', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-nightly-latest-l10n-ssl'),
                           ('os', 'linux64'),
                           ('lang', 'pt-BR')])
开发者ID:RickieES,项目名称:bedrock,代码行数:31,代码来源:test_firefox_details.py


示例8: twitter

def twitter():
    request_token_url = 'https://api.twitter.com/oauth/request_token'
    access_token_url = 'https://api.twitter.com/oauth/access_token'
    authenticate_url = 'https://api.twitter.com/oauth/authenticate'

    if request.args.get('oauth_token') and request.args.get('oauth_verifier'):
        auth = OAuth1(app.config['TWITTER_CONSUMER_KEY'],
                      client_secret=app.config['TWITTER_CONSUMER_SECRET'],
                      resource_owner_key=request.args.get('oauth_token'),
                      verifier=request.args.get('oauth_verifier'))
        r = requests.post(access_token_url, auth=auth)
        profile = dict(parse_qsl(r.text))

        user = User.query.filter_by(twitter=profile['user_id']).first()
        if user:
            token = create_token(user)
            return jsonify(token=token)

        u = User(twitter=profile['user_id'],
                 display_name=profile['screen_name'],
                 oauth_token=profile['oauth_token'],
                 oauth_token_secret=profile['oauth_token_secret'])
        db.session.add(u)
        db.session.commit()
        token = create_token(u)
        return jsonify(token=token)
    else:
        oauth = OAuth1(app.config['TWITTER_CONSUMER_KEY'],
                       client_secret=app.config['TWITTER_CONSUMER_SECRET'],
                       callback_uri=app.config['TWITTER_CALLBACK_URL'])
        r = requests.post(request_token_url, auth=oauth)
        oauth_token = dict(parse_qsl(r.text))
        qs = urlencode(dict(oauth_token=oauth_token['oauth_token']))
        return redirect(authenticate_url + '?' + qs)
开发者ID:anapitupulu,项目名称:wikidpr-tweet,代码行数:34,代码来源:app.py


示例9: link_account

    def link_account(self, widget,consumer_key,consumer_secret):
        consumer_key = consumer_key.get_text()
        consumer_secret = consumer_secret.get_text()
        
        consumer = oauth.Consumer(consumer_key, consumer_secret)
        client = oauth.Client(consumer)

        resp, content = client.request(self.config_data['request_token_url'], "POST", urllib.urlencode({'oauth_callback':'oob'}))
        if resp['status'] == '200':
            request_token = dict(urlparse.parse_qsl(content))
            oauth_verifier = self.show_dialog("Click <a href='%s?oauth_token=%s'>HERE</a>, authorize the application and copy the pin:" % (self.config_data['authorize_url'], request_token['oauth_token']),"")
         
            token = oauth.Token(request_token['oauth_token'],request_token['oauth_token_secret'])
            token.set_verifier(oauth_verifier)
            client = oauth.Client(consumer, token)

            resp, content = client.request(self.config_data['access_token_url'], "POST")
            if resp['status'] == '200':
                access_token = dict(urlparse.parse_qsl(content))

                self.config_data['oauth_token'] = access_token['oauth_token']
                self.config_data['oauth_token_secret'] = access_token['oauth_token_secret']
                self.save_config_file()

                self.show_dialog("The application was successfully authorized.",None)
            else:
                self.show_dialog("There was an error in authorizing the application. Please verify that you granted access to the application and inputed the pin correctly.",None)
        else:
            self.show_dialog("Invalid response from server. Please verify the consumer key and secret.",None)    
开发者ID:marcoconstancio,项目名称:cloudpt_filemanagers_submenu,代码行数:29,代码来源:cloudpt_nautilus_submenu.py


示例10: get_access

def get_access(client):
    if os.path.exists("access.db"):
        return load_access()


    response, content = make_request(client,request_token_url,{},"Failed to fetch request token","POST")

    # parse out the tokens from the response
    request_token = dict(urlparse.parse_qsl(content))
    print "Go to the following link in your browser:"
    print "%s?oauth_token=%s" % (authorize_url, request_token['oauth_token'])
 
    # ask for the verifier pin code
    oauth_verifier = raw_input('What is the PIN? ')
 
    # swap in the new token + verifier pin
    token = oauth.Token(request_token['oauth_token'],request_token['oauth_token_secret'])
    token.set_verifier(oauth_verifier)
    client = oauth.Client(consumer, token)
 
    # fetch the access token
    response, content = make_request(client,access_token_url,{},"Failed to fetch access token","POST")

    # parse out the access token
    access_token = dict(urlparse.parse_qsl(content))
    print "Access Token:"
    print "    - oauth_token        = %s" % access_token['oauth_token']
    print "    - oauth_token_secret = %s" % access_token['oauth_token_secret']
    print

    database = shelve.open("access.db")
    database['access'] = access_token
    database.close()

    return access_token 
开发者ID:A7Zulu,项目名称:linkedin,代码行数:35,代码来源:test.py


示例11: tokens

    def tokens(self):

        consumer = oauth2.Consumer(self.consumer_token, self.consumer_secret)
        client = oauth2.Client(consumer)

        # Request request tokens
        resp, content = client.request(self.request_token_url, "GET")

        if resp['status'] != '200':
            raise Exception("Invalid response %s." % resp['status'])

        request_token = dict(urlparse.parse_qsl(content))

        logging.debug("Request Token:\n" +
                      "    - oauth_token        = {0[oauth_token]}\n".format(request_token) +
                      "    - oauth_token_secret = {0[oauth_token_secret]}\n".format(request_token))

        # interactively ask for permission/connect to the account
        verifier = self.verifier("%s?oauth_token=%s" % (self.authorize_url, request_token['oauth_token']))

        token = oauth2.Token(request_token['oauth_token'],
                             request_token['oauth_token_secret'])
        token.set_verifier(verifier)

        # convert request token + verifier token into access token
        client = oauth2.Client(consumer, token)
        resp, content = client.request(self.access_token_url, "POST")

        access_token = dict(urlparse.parse_qsl(content))
        return access_token
开发者ID:severak,项目名称:clients,代码行数:30,代码来源:user_details.py


示例12: get_access_token

def get_access_token(consumer):

  client = oauth.Client(consumer)

  resp, content = client.request(request_token_url, "GET")
  if resp['status'] != '200':
      raise Exception("Invalid response %s." % resp['status'])

  request_token = dict(urlparse.parse_qsl(content))


  print "[ACTION] Go to the following link in your browser:"
  print "%s?oauth_token=%s" % (authorize_url, request_token['oauth_token'])
  print 

  accepted = 'n'
  while accepted.lower() == 'n':
      accepted = raw_input('Have you authorized me? (y/n) ')
  oauth_verifier = raw_input('What is the PIN? ')

  token = oauth.Token(request_token['oauth_token'],
      request_token['oauth_token_secret'])
  token.set_verifier(oauth_verifier)
  client = oauth.Client(consumer, token)

  resp, content = client.request(access_token_url, "POST")
  access_token = dict(urlparse.parse_qsl(content))

  return access_token
开发者ID:puntofisso,项目名称:twitter-death-checker,代码行数:29,代码来源:tdc.py


示例13: oauth_requests

def oauth_requests():
    auth = OAuth1(AK.API_KEY, AK.SECRET_KEY, callback_uri=callback_uri)
    #print auth
    r = requests.post(request_url, auth=auth)
    #print r
    request_token = dict(urlparse.parse_qsl(r.text))
    #print request_token

    # Getting the User Authorization
    # ブラウザを開きOAuth認証確認画面を表示
    # ユーザーが許可するとPINコードが表示される
    url = '{0}?oauth_token={1}&perms=write'.format(authorize_url,  request_token['oauth_token'])
    #print testurl
    #print MI.BROWSER_PATH
    browser = webbrowser.get(MI.BROWSER_PATH)
    browser.open(url)

    oauth_verifier = raw_input("[PIN Code]> ")  # 上記PINコードを入力する
    #print oauth_verifier
    auth = OAuth1(
            AK.API_KEY,
            AK.SECRET_KEY,
            request_token['oauth_token'],
            request_token['oauth_token_secret'],
            verifier=oauth_verifier)
    r = requests.post(access_token_url, auth=auth)

    access_token = dict(urlparse.parse_qsl(r.text))
    return access_token
开发者ID:MeijiMori,项目名称:flickr_album_sort,代码行数:29,代码来源:flickr_album_sort.py


示例14: _get_access_tokens

    def _get_access_tokens(self):
        oauth_consumer = oauth2.Consumer(key=self.CONSUMER_KEY,
                                        secret=self.CONSUMER_SECRET)
        oauth_client = oauth2.Client(oauth_consumer)

        resp, content = oauth_client.request(twitter.REQUEST_TOKEN_URL, 'GET')

        if resp['status'] != '200':
            print('Invalid respond from Twitter requesting temp token: %s'
                  % resp['status'])
            return

        request_token = dict(urlparse.parse_qsl(content))
        webbrowser.open('%s?oauth_token=%s' % (twitter.AUTHORIZATION_URL,
                                               request_token['oauth_token']))
        pincode = raw_input('Enter pincode')
        token = oauth2.Token(request_token['oauth_token'],
                            request_token['oauth_token_secret'])
        token.set_verifier(pincode)
        oauth_client  = oauth2.Client(oauth_consumer, token)
        resp, content = oauth_client.request(twitter.ACCESS_TOKEN_URL,
            method='POST', body='oauth_verifier=%s' % pincode)

        if resp['status'] != '200':
            print('Invalid respond from Twitter requesting access token: %s'
                  % resp['status'])
            return

        access_token  = dict(urlparse.parse_qsl(content))
        request_token = dict(urlparse.parse_qsl(content))

        return access_token['oauth_token'], access_token['oauth_token_secret']
开发者ID:Man-UP,项目名称:the-punisher,代码行数:32,代码来源:olive.py


示例15: test_get_download_url_esr

 def test_get_download_url_esr(self):
     """
     The ESR version should give us a bouncer url. There is no stub for ESR.
     """
     url = firefox_desktop.get_download_url('esr', '28.0a2', 'win', 'en-US', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-esr-latest-ssl'),
                           ('os', 'win'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('esr', '28.0a2', 'win64', 'en-US', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-esr-latest-ssl'),
                           ('os', 'win64'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('esr', '28.0a2', 'osx', 'en-US', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-esr-latest-ssl'),
                           ('os', 'osx'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('esr', '28.0a2', 'linux', 'en-US', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-esr-latest-ssl'),
                           ('os', 'linux'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('esr', '28.0a2', 'linux64', 'en-US', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-esr-latest-ssl'),
                           ('os', 'linux64'),
                           ('lang', 'en-US')])
开发者ID:RickieES,项目名称:bedrock,代码行数:29,代码来源:test_firefox_details.py


示例16: callback

def callback():
    # Extract parameters from callback URL
    data = dict(parse_qsl(urlparse(request.url).query))
    resource_owner = data.get(u'oauth_token').decode(u'utf-8')
    verifier = data.get(u'oauth_verifier').decode(u'utf-8')
    token_secret = session["token_secret"]

    # Request the access token
    client = OAuth1(app.config["CLIENT_KEY"],
        resource_owner_key=resource_owner,
        resource_owner_secret=token_secret,
        verifier=verifier,
        **app.config["OAUTH_CREDENTIALS"])
    r = requests.post(u"http://127.0.0.1:5000/access_token", auth=client)

    # Extract the access token from the response
    data = dict(parse_qsl(r.content))
    resource_owner = data.get(u'oauth_token').decode(u'utf-8')
    resource_owner_secret = data.get(u'oauth_token_secret').decode(u'utf-8')
    client = OAuth1(app.config["CLIENT_KEY"],
        resource_owner_key=resource_owner,
        resource_owner_secret=resource_owner_secret,
        **app.config["OAUTH_CREDENTIALS"])
    r = requests.get(u"http://127.0.0.1:5000/protected", auth=client)
    r = requests.get(u"http://127.0.0.1:5000/protected_realm", auth=client)
    return r.content
开发者ID:Chitrank-Dixit,项目名称:flask-oauthprovider,代码行数:26,代码来源:client.py


示例17: test_get_download_url_esr_next

 def test_get_download_url_esr_next(self):
     """
     The ESR_NEXT version should give us a bouncer url with a full version. There is no stub for ESR.
     """
     url = firefox_desktop.get_download_url('esr_next', '52.4.1esr', 'win', 'en-US', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-52.4.1esr-SSL'),
                           ('os', 'win'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('esr_next', '52.4.1esr', 'win64', 'en-US', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-52.4.1esr-SSL'),
                           ('os', 'win64'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('esr_next', '52.4.1esr', 'osx', 'en-US', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-52.4.1esr-SSL'),
                           ('os', 'osx'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('esr_next', '52.4.1esr', 'linux', 'en-US', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-52.4.1esr-SSL'),
                           ('os', 'linux'),
                           ('lang', 'en-US')])
     url = firefox_desktop.get_download_url('esr_next', '52.4.1esr', 'linux64', 'en-US', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-52.4.1esr-SSL'),
                           ('os', 'linux64'),
                           ('lang', 'en-US')])
开发者ID:RickieES,项目名称:bedrock,代码行数:29,代码来源:test_firefox_details.py


示例18: test_get_request_token

    def test_get_request_token(self):
        """
        Tests that expected responses from the LinkedIn API for
        get_request_token are properly handled. Known cases:
            success response without scope
            success response with scope
        """
        with patch('linkedin_json_client.api.oauth.Client') as patched_Client:
            client = patched_Client.return_value
            client.request.return_value = (
                self._responseFactory({
                    'content-length': '236',
                }),
                self.request_token)

            # test a successful request without scope
            self.failUnlessEqual(
                self.api.get_request_token(),
                dict(urlparse.parse_qsl(self.request_token)))

            # test a successful request with
            self.failUnlessEqual(
                self.api.get_request_token(
                    scope=[
                        LinkedInScope.BASIC_PROFILE,
                        LinkedInScope.EMAIL_ADDRESS,
                        LinkedInScope.NETWORK_UPDATES,
                        LinkedInScope.CONNECTIONS,
                        LinkedInScope.CONTACT_INFO,
                        LinkedInScope.MESSAGES]),
                dict(urlparse.parse_qsl(self.request_token)))
开发者ID:ekabiri,项目名称:LinkedIn-API-JSON-Client,代码行数:31,代码来源:tests.py


示例19: test_get_download_url_devedition_l10n

 def test_get_download_url_devedition_l10n(self):
     """
     The Developer Edition version should give us a bouncer url. A stub url
     should be returned for win32/64, while other platforms get a full url.
     The product name is the same as en-US.
     """
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'win', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-devedition-stub'),
                           ('os', 'win'),
                           ('lang', 'pt-BR')])
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'win64', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-devedition-stub'),
                           ('os', 'win64'),
                           ('lang', 'pt-BR')])
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'osx', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-devedition-latest-ssl'),
                           ('os', 'osx'),
                           ('lang', 'pt-BR')])
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'linux', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-devedition-latest-ssl'),
                           ('os', 'linux'),
                           ('lang', 'pt-BR')])
     url = firefox_desktop.get_download_url('alpha', '28.0a2', 'linux64', 'pt-BR', True)
     self.assertListEqual(parse_qsl(urlparse(url).query),
                          [('product', 'firefox-devedition-latest-ssl'),
                           ('os', 'linux64'),
                           ('lang', 'pt-BR')])
开发者ID:RickieES,项目名称:bedrock,代码行数:31,代码来源:test_firefox_details.py


示例20: TwitterAuth

def TwitterAuth(params):
    consumer = oauth.Consumer(consumer_key, consumer_secret)
    client = oauth.Client(consumer)
    # step 1 - obtain a request token
    resp, content = client.request(
        'https://api.twitter.com/oauth/request_token', 'POST')
    if resp['status'] != '200':
        print 'Failed to get request token. [%s]' % resp['status']
        return 1
    request_token = dict(urlparse.parse_qsl(content))
    # step 2 - redirect the user
    redirect_url = 'https://api.twitter.com/oauth/authorize?oauth_token=%s' % (
        request_token['oauth_token'])
    if not webbrowser.open(redirect_url, new=2, autoraise=0):
        print 'Please use a web browser to open the following URL'
        print redirect_url
    pin = raw_input('Please enter the PIN shown in your web browser: ').strip()
    # step 3 - convert the request token to an access token
    token = oauth.Token(
        request_token['oauth_token'], request_token['oauth_token_secret'])
    token.set_verifier(pin)
    client = oauth.Client(consumer, token)
    resp, content = client.request(
        'https://api.twitter.com/oauth/access_token', 'POST')
    if resp['status'] != '200':
        print 'Failed to get access token. [%s]' % resp['status']
        return 1
    access_token = dict(urlparse.parse_qsl(content))
    params.set('twitter', 'key', access_token['oauth_token'])
    params.set('twitter', 'secret', access_token['oauth_token_secret'])
    print 'Success! Authorisation data has been stored in %s' % params._path
    return 0
开发者ID:ccsalvesen,项目名称:pywws,代码行数:32,代码来源:TwitterAuth.py



注:本文中的urlparse.parse_qsl函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python urlparse.unquote函数代码示例发布时间:2022-05-27
下一篇:
Python urlparse.parse_qs函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap