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


Python urllib_parse.parse_qsl方法代碼示例

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


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

示例1: save_report

# 需要導入模塊: from six.moves import urllib_parse [as 別名]
# 或者: from six.moves.urllib_parse import parse_qsl [as 別名]
def save_report(session, repo, name, url, username):
    """ Save the report of issues based on the given URL of the project.
    """
    url_obj = urlparse(url)
    url = url_obj.geturl().replace(url_obj.query, "")
    query = {}
    for k, v in parse_qsl(url_obj.query):
        if k in query:
            if isinstance(query[k], list):
                query[k].append(v)
            else:
                query[k] = [query[k], v]
        else:
            query[k] = v
    reports = repo.reports
    reports[name] = query
    repo.reports = reports
    session.add(repo) 
開發者ID:Pagure,項目名稱:pagure,代碼行數:20,代碼來源:query.py

示例2: data

# 需要導入模塊: from six.moves import urllib_parse [as 別名]
# 或者: from six.moves.urllib_parse import parse_qsl [as 別名]
def data(self):
        """
        TODO: What is the right way to do this?
        """
        if not self.body:
            return self.body
        elif self.body is EMPTY:
            return EMPTY
        elif self.content_type and self.content_type.startswith('application/json'):
            try:
                if isinstance(self.body, six.binary_type):
                    return json.loads(self.body.decode('utf-8'))
                else:
                    return json.loads(self.body)
            except ValueError as e:
                if isinstance(e, JSONDecodeError):
                    # this will only be True for Python3+
                    raise e
                raise JSONDecodeError(str(e))
        elif self.content_type == 'application/x-www-form-urlencoded':
            return dict(urlparse.parse_qsl(self.body))
        else:
            raise NotImplementedError("No parser for content type") 
開發者ID:pipermerriam,項目名稱:flex,代碼行數:25,代碼來源:http.py

示例3: parse_auth_response_url

# 需要導入模塊: from six.moves import urllib_parse [as 別名]
# 或者: from six.moves.urllib_parse import parse_qsl [as 別名]
def parse_auth_response_url(url):
        query_s = urlparse(url).query
        form = dict(parse_qsl(query_s))
        if "error" in form:
            raise SpotifyOauthError("Received error from auth server: "
                                    "{}".format(form["error"]),
                                    error=form["error"])
        return tuple(form.get(param) for param in ["state", "code"]) 
開發者ID:plamere,項目名稱:spotipy,代碼行數:10,代碼來源:oauth2.py

示例4: parse_connection_string

# 需要導入模塊: from six.moves import urllib_parse [as 別名]
# 或者: from six.moves.urllib_parse import parse_qsl [as 別名]
def parse_connection_string(value):
    """Original Governor stores connection strings for each cluster members if a following format:
        postgres://{username}:{password}@{connect_address}/postgres
    Since each of our patroni instances provides own REST API endpoint it's good to store this information
    in DCS among with postgresql connection string. In order to not introduce new keys and be compatible with
    original Governor we decided to extend original connection string in a following way:
        postgres://{username}:{password}@{connect_address}/postgres?application_name={api_url}
    This way original Governor could use such connection string as it is, because of feature of `libpq` library.

    This method is able to split connection string stored in DCS into two parts, `conn_url` and `api_url`"""

    scheme, netloc, path, params, query, fragment = urlparse(value)
    conn_url = urlunparse((scheme, netloc, path, params, '', fragment))
    api_url = ([v for n, v in parse_qsl(query) if n == 'application_name'] or [None])[0]
    return conn_url, api_url 
開發者ID:zalando,項目名稱:patroni,代碼行數:17,代碼來源:__init__.py

示例5: conninfo_uri_parse

# 需要導入模塊: from six.moves import urllib_parse [as 別名]
# 或者: from six.moves.urllib_parse import parse_qsl [as 別名]
def conninfo_uri_parse(dsn):
    ret = {}
    r = urlparse(dsn)
    if r.username:
        ret['user'] = r.username
    if r.password:
        ret['password'] = r.password
    if r.path[1:]:
        ret['dbname'] = r.path[1:]
    hosts = []
    ports = []
    for netloc in r.netloc.split('@')[-1].split(','):
        host = port = None
        if '[' in netloc and ']' in netloc:
            host = netloc.split(']')[0][1:]
        tmp = netloc.split(':', 1)
        if host is None:
            host = tmp[0]
        if len(tmp) == 2:
            host, port = tmp
        if host is not None:
            hosts.append(host)
        if port is not None:
            ports.append(port)
    if hosts:
        ret['host'] = ','.join(hosts)
    if ports:
        ret['port'] = ','.join(ports)
    ret = {name: unquote(value) for name, value in ret.items()}
    ret.update({name: value for name, value in parse_qsl(r.query)})
    if ret.get('ssl') == 'true':
        del ret['ssl']
        ret['sslmode'] = 'require'
    return ret 
開發者ID:zalando,項目名稱:patroni,代碼行數:36,代碼來源:config.py


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