当前位置: 首页>>代码示例>>Python>>正文


Python urllib_parse.urlsplit方法代码示例

本文整理汇总了Python中six.moves.urllib_parse.urlsplit方法的典型用法代码示例。如果您正苦于以下问题:Python urllib_parse.urlsplit方法的具体用法?Python urllib_parse.urlsplit怎么用?Python urllib_parse.urlsplit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在six.moves.urllib_parse的用法示例。


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

示例1: url_to_path

# 需要导入模块: from six.moves import urllib_parse [as 别名]
# 或者: from six.moves.urllib_parse import urlsplit [as 别名]
def url_to_path(url):
    # type: (str) -> str
    """Convert a valid file url to a local filesystem path.

    Follows logic taken from pip's equivalent function
    """

    assert is_file_url(url), "Only file: urls can be converted to local paths"
    _, netloc, path, _, _ = urllib_parse.urlsplit(url)
    # Netlocs are UNC paths
    if netloc:
        netloc = "\\\\" + netloc

    path = urllib_request.url2pathname(netloc + path)
    return urllib_parse.unquote(path) 
开发者ID:pypa,项目名称:pipenv,代码行数:17,代码来源:path.py

示例2: get_odl_url

# 需要导入模块: from six.moves import urllib_parse [as 别名]
# 或者: from six.moves.urllib_parse import urlsplit [as 别名]
def get_odl_url(path=''):
    '''Make a URL for some ODL resource (path)'''
    purl = urlparse.urlsplit(cfg.CONF.ml2_odl.url)
    features_url = urlparse.urlunparse((
        purl.scheme, purl.netloc, path, '', '', ''))
    return features_url 
开发者ID:openstack,项目名称:networking-odl,代码行数:8,代码来源:utils.py

示例3: getProxiedURIT

# 需要导入模块: from six.moves import urllib_parse [as 别名]
# 或者: from six.moves.urllib_parse import urlsplit [as 别名]
def getProxiedURIT(uriT):
    tmurl = list(urlsplit(uriT))
    if app.proxy is not None:
        # urlsplit put domain in path for "example.com"
        tmurl[1] = app.proxy  # Set replay host/port if no scheme
        proxyuri = urlsplit(app.proxy)
        if proxyuri.scheme != '':
            tmurl[0] = proxyuri.scheme
            tmurl[1] = proxyuri.netloc + proxyuri.path

    return tmurl 
开发者ID:oduwsdl,项目名称:ipwb,代码行数:13,代码来源:replay.py

示例4: __init__

# 需要导入模块: from six.moves import urllib_parse [as 别名]
# 或者: from six.moves.urllib_parse import urlsplit [as 别名]
def __init__(self, target, **params):
        if isinstance(target, six.string_types):
            self._host = urlsplit(target)
        elif isinstance(target, (tuple, list)):
            self._host = urlsplit('http://%s:%s/' % target)
        else:
            raise TypeError('Host must be a string or tuple')
        self._params = params 
开发者ID:dlecocq,项目名称:nsq-py,代码行数:10,代码来源:__init__.py

示例5: _SerializeRequest

# 需要导入模块: from six.moves import urllib_parse [as 别名]
# 或者: from six.moves.urllib_parse import urlsplit [as 别名]
def _SerializeRequest(self, request):
        """Convert a http_wrapper.Request object into a string.

        Args:
          request: A http_wrapper.Request to serialize.

        Returns:
          The request as a string in application/http format.
        """
        # Construct status line
        parsed = urllib_parse.urlsplit(request.url)
        request_line = urllib_parse.urlunsplit(
            ('', '', parsed.path, parsed.query, ''))
        if not isinstance(request_line, six.text_type):
            request_line = request_line.decode('utf-8')
        status_line = u' '.join((
            request.http_method,
            request_line,
            u'HTTP/1.1\n'
        ))
        major, minor = request.headers.get(
            'content-type', 'application/json').split('/')
        msg = mime_nonmultipart.MIMENonMultipart(major, minor)

        # MIMENonMultipart adds its own Content-Type header.
        # Keep all of the other headers in `request.headers`.
        for key, value in request.headers.items():
            if key == 'content-type':
                continue
            msg[key] = value

        msg['Host'] = parsed.netloc
        msg.set_unixfrom(None)

        if request.body is not None:
            msg.set_payload(request.body)

        # Serialize the mime message.
        str_io = six.StringIO()
        # maxheaderlen=0 means don't line wrap headers.
        gen = generator.Generator(str_io, maxheaderlen=0)
        gen.flatten(msg, unixfrom=False)
        body = str_io.getvalue()

        return status_line + body 
开发者ID:google,项目名称:apitools,代码行数:47,代码来源:batch.py


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