webapp2.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:webapp2 作者: GoogleCloudPlatform 项目源码 文件源码
def _urlunsplit(scheme=None, netloc=None, path=None, query=None,
                fragment=None):
    """Like ``urlparse.urlunsplit``, but will escape values and urlencode and
    sort query arguments.

    :param scheme:
        URI scheme, e.g., `http` or `https`.
    :param netloc:
        Network location, e.g., `localhost:8080` or `www.google.com`.
    :param path:
        URI path.
    :param query:
        URI query as an escaped string, or a dictionary or list of key-values
        tuples to build a query.
    :param fragment:
        Fragment identifier, also known as "anchor".
    :returns:
        An assembled absolute or relative URI.
    """
    if not scheme or not netloc:
        scheme = ''
        netloc = None

    if path:
        path = quote(_to_utf8(path))

    if query and not isinstance(query, six.string_types):
        if isinstance(query, dict):
            query = six.iteritems(query)

        # Sort args: commonly needed to build signatures for services.
        query = urlencode(sorted(query))

    if fragment:
        fragment = quote(_to_utf8(fragment))

    return urlunsplit((scheme, netloc, path, query, fragment))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号