當前位置: 首頁>>代碼示例>>Python>>正文


Python urlparse.parse_qsl方法代碼示例

本文整理匯總了Python中urlparse.parse_qsl方法的典型用法代碼示例。如果您正苦於以下問題:Python urlparse.parse_qsl方法的具體用法?Python urlparse.parse_qsl怎麽用?Python urlparse.parse_qsl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在urlparse的用法示例。


在下文中一共展示了urlparse.parse_qsl方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: read_multi

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def read_multi(self, environ, keep_blank_values, strict_parsing):
        """Internal: read a part that is itself multipart."""
        ib = self.innerboundary
        if not valid_boundary(ib):
            raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,)
        self.list = []
        if self.qs_on_post:
            for key, value in urlparse.parse_qsl(self.qs_on_post,
                                self.keep_blank_values, self.strict_parsing):
                self.list.append(MiniFieldStorage(key, value))
            FieldStorageClass = None

        klass = self.FieldStorageClass or self.__class__
        part = klass(self.fp, {}, ib,
                     environ, keep_blank_values, strict_parsing)
        # Throw first part away
        while not part.done:
            headers = rfc822.Message(self.fp)
            part = klass(self.fp, headers, ib,
                         environ, keep_blank_values, strict_parsing)
            self.list.append(part)
        self.skip_lines() 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:24,代碼來源:cgi.py

示例2: get_params

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def get_params(self):

        ''' Get the params
        '''
        try:
            path = self.path[1:]

            if '?' in path:
                path = path.split('?', 1)[1]

            params = dict(urlparse.parse_qsl(path))
        except Exception:
            params = {}

        if params.get('transcode'):
            params['transcode'] = params['transcode'].lower() == 'true'

        if params.get('server') and params['server'].lower() == 'none':
            params['server'] = None

        return params 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:23,代碼來源:webservice.py

示例3: __init__

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def __init__(self, key, secret, email, password, cartodb_domain, host='carto.com', protocol='https', proxy_info=None, *args, **kwargs):
        super(CartoDBOAuth, self).__init__(cartodb_domain, host, protocol, *args, **kwargs)

        self.consumer_key = key
        self.consumer_secret = secret
        consumer = oauth.Consumer(self.consumer_key, self.consumer_secret)

        client = oauth.Client(consumer, proxy_info=proxy_info)
        client.set_signature_method = oauth.SignatureMethod_HMAC_SHA1()

        params = {}
        params["x_auth_username"] = email
        params["x_auth_password"] = password
        params["x_auth_mode"] = 'client_auth'

        # Get Access Token
        access_token_url = ACCESS_TOKEN_URL % {'user': cartodb_domain, 'domain': host, 'protocol': protocol}
        resp, token = client.request(access_token_url, method="POST", body=urllib.urlencode(params))
        access_token = dict(urlparse.parse_qsl(token))
        token = oauth.Token(access_token['oauth_token'], access_token['oauth_token_secret'])

        # prepare client
        self.client = oauth.Client(consumer, token) 
開發者ID:gkudos,項目名稱:qgis-cartodb,代碼行數:25,代碼來源:cartodb.py

示例4: GET

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def GET(self):
        """ list all rucio accounts.

        HTTP Success:
            200 OK

        HTTP Error:
            401 Unauthorized
            406 Not Acceptable
            500 InternalError

        :param Rucio-Account: Account identifier.
        :param Rucio-Auth-Token: as an 32 character hex string.
        :returns: A list containing all account names as dict.
        """
        header('Content-Type', 'application/x-json-stream')
        filter = {}
        if ctx.query:
            filter = dict(parse_qsl(ctx.query[1:]))

        for account in list_accounts(filter=filter):
            yield render_json(**account) + "\n" 
開發者ID:rucio,項目名稱:rucio,代碼行數:24,代碼來源:account.py

示例5: _add_query_parameter

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def _add_query_parameter(url, name, value):
  """Adds a query parameter to a url.

  Replaces the current value if it already exists in the URL.

  Args:
    url: string, url to add the query parameter to.
    name: string, query parameter name.
    value: string, query parameter value.

  Returns:
    Updated query parameter. Does not update the url if value is None.
  """
  if value is None:
    return url
  else:
    parsed = list(urlparse.urlparse(url))
    q = dict(urlparse.parse_qsl(parsed[4]))
    q[name] = value
    parsed[4] = urllib.urlencode(q)
    return urlparse.urlunparse(parsed) 
開發者ID:mortcanty,項目名稱:earthengine,代碼行數:23,代碼來源:util.py

示例6: do_GET

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def do_GET(self):
    """Handle a GET request.

    Parses the query parameters and prints a message
    if the flow has completed. Note that we can't detect
    if an error occurred.
    """
    self.send_response(200)
    self.send_header("Content-type", "text/html")
    self.end_headers()
    query = self.path.split('?', 1)[-1]
    query = dict(urlparse.parse_qsl(query))
    self.server.query_params = query
    self.wfile.write("<html><head><title>Authentication Status</title></head>")
    self.wfile.write("<body><p>The authentication flow has completed.</p>")
    self.wfile.write("</body></html>") 
開發者ID:mortcanty,項目名稱:earthengine,代碼行數:18,代碼來源:tools.py

示例7: urlparams

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def urlparams(url_, hash=None, **query):
    """Add a fragment and/or query paramaters to a URL.

    New query params will be appended to exising parameters, except duplicate
    names, which will be replaced.
    """
    url = urlparse.urlparse(url_)
    fragment = hash if hash is not None else url.fragment

    # Use dict(parse_qsl) so we don't get lists of values.
    query_dict = dict(urlparse.parse_qsl(url.query))
    query_dict.update(query)

    query_string = urlencode(
        [(k, v) for k, v in query_dict.items() if v is not None])
    new = urlparse.ParseResult(url.scheme, url.netloc, url.path, url.params,
                               query_string, fragment)
    return new.geturl() 
開發者ID:mozilla,項目名稱:sugardough,代碼行數:20,代碼來源:helpers.py

示例8: _add_query_parameter

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def _add_query_parameter(url, name, value):
  """Adds a query parameter to a url.

  Replaces the current value if it already exists in the URL.

  Args:
    url: string, url to add the query parameter to.
    name: string, query parameter name.
    value: string, query parameter value.

  Returns:
    Updated query parameter. Does not update the url if value is None.
  """
  if value is None:
    return url
  else:
    parsed = list(urlparse.urlparse(url))
    q = dict(parse_qsl(parsed[4]))
    q[name] = value
    parsed[4] = urllib.urlencode(q)
    return urlparse.urlunparse(parsed) 
開發者ID:splunk,項目名稱:splunk-ref-pas-code,代碼行數:23,代碼來源:util.py

示例9: do_GET

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def do_GET(s):
    """Handle a GET request.

    Parses the query parameters and prints a message
    if the flow has completed. Note that we can't detect
    if an error occurred.
    """
    s.send_response(200)
    s.send_header("Content-type", "text/html")
    s.end_headers()
    query = s.path.split('?', 1)[-1]
    query = dict(parse_qsl(query))
    s.server.query_params = query
    s.wfile.write("<html><head><title>Authentication Status</title></head>")
    s.wfile.write("<body><p>The authentication flow has completed.</p>")
    s.wfile.write("</body></html>") 
開發者ID:splunk,項目名稱:splunk-ref-pas-code,代碼行數:18,代碼來源:tools.py

示例10: parse_vcs_requirement

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def parse_vcs_requirement(req):
    """Parses VCS line to egg name, version etc.
    """
    if '+' not in req:
        return None
    vcs, url = req.split('+', 1)
    if vcs not in ('git', 'svn', 'hg'):
        return None
    parsed_url = urlparse(url)
    parsed = dict(parse_qsl(parsed_url.fragment))
    if 'egg' not in parsed:
        return None
    egg = parsed['egg'].rsplit('-', 1)
    if len(egg) > 1:
        try:
            pkg_resources_parse_version(egg[1])
        except pkg_resources._vendor.packaging.version.InvalidVersion:
            return parsed['egg'].lower(), req, None
        return egg[0].lower(), req, egg[1]
    else:
        return parsed['egg'].lower(), req, None 
開發者ID:Deepwalker,項目名稱:pundler,代碼行數:23,代碼來源:pundle.py

示例11: fetch

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def fetch(self, url, post=False, headers=None, **kw):
        params = urllib.urlencode(kw)
        if params and not post:
            url += ('?' + params)

        request = urllib2.Request(url, params if post else None, headers or {})

        if self.timeout:
            response = urllib2.urlopen(request, timeout=self.timeout)
        else:
            response = urllib2.urlopen(request)

        content_type = response.info().getheader('content-type').split(';')[0]
        data = response.read()
        response.close()

        if response.getcode() != 200:
            return None
        return json.loads(data)if content_type in ('application/json', 'text/javascript') else dict(urlparse.parse_qsl(data)) 
開發者ID:Net-ng,項目名稱:kansha,代碼行數:21,代碼來源:oauth_providers.py

示例12: get_parse_callable

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def get_parse_callable():

    class Result(dict):

        def get(self, k):
            return 200

    def parse(url):

        for k, v in parse_qsl(url.split("?")[1]):
            if k == "max_results":
                max_result = int(v)

        result = Result()
        result['entries'] = [
            get_random_arxiv_entry() for _ in range(max_result)]
        return result

    return parse 
開發者ID:lukasschwab,項目名稱:arxiv.py,代碼行數:21,代碼來源:test_search.py

示例13: get_oauth_url

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def get_oauth_url(self):
        """ Returns the URL with OAuth params """
        params = OrderedDict()

        if "?" in self.url:
            url = self.url[:self.url.find("?")]
            for key, value in parse_qsl(urlparse(self.url).query):
                params[key] = value
        else:
            url = self.url

        params["oauth_consumer_key"] = self.consumer_key
        params["oauth_timestamp"] = self.timestamp
        params["oauth_nonce"] = self.generate_nonce()
        params["oauth_signature_method"] = "HMAC-SHA256"
        params["oauth_signature"] = self.generate_oauth_signature(params, url)

        query_string = urlencode(params)

        return "%s?%s" % (url, query_string) 
開發者ID:woocommerce,項目名稱:wc-api-python,代碼行數:22,代碼來源:oauth.py

示例14: parse_qsl

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
    """Parse a query given as a string argument."""
    warn("cgi.parse_qsl is deprecated, use urlparse.parse_qsl instead",
         PendingDeprecationWarning, 2)
    return urlparse.parse_qsl(qs, keep_blank_values, strict_parsing) 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:7,代碼來源:cgi.py

示例15: read_urlencoded

# 需要導入模塊: import urlparse [as 別名]
# 或者: from urlparse import parse_qsl [as 別名]
def read_urlencoded(self):
        """Internal: read data in query string format."""
        qs = self.fp.read(self.length)
        if self.qs_on_post:
            qs += '&' + self.qs_on_post
        self.list = list = []
        for key, value in urlparse.parse_qsl(qs, self.keep_blank_values,
                                            self.strict_parsing):
            list.append(MiniFieldStorage(key, value))
        self.skip_lines() 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:12,代碼來源:cgi.py


注:本文中的urlparse.parse_qsl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。