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


Python urlparse.urlsplit方法代码示例

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


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

示例1: get_url_rev

# 需要导入模块: from pip.backwardcompat import urlparse [as 别名]
# 或者: from pip.backwardcompat.urlparse import urlsplit [as 别名]
def get_url_rev(self):
        """
        Returns the correct repository URL and revision by parsing the given
        repository URL
        """
        error_message = (
           "Sorry, '%s' is a malformed VCS url. "
           "The format is <vcs>+<protocol>://<url>, "
           "e.g. svn+http://myrepo/svn/MyApp#egg=MyApp")
        assert '+' in self.url, error_message % self.url
        url = self.url.split('+', 1)[1]
        scheme, netloc, path, query, frag = urlparse.urlsplit(url)
        rev = None
        if '@' in path:
            path, rev = path.rsplit('@', 1)
        url = urlparse.urlunsplit((scheme, netloc, path, query, ''))
        return url, rev 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:19,代码来源:__init__.py

示例2: _get_content_type

# 需要导入模块: from pip.backwardcompat import urlparse [as 别名]
# 或者: from pip.backwardcompat.urlparse import urlsplit [as 别名]
def _get_content_type(url, session=None):
        """Get the Content-Type of the given url, using a HEAD request"""
        if session is None:
            session = PipSession()

        scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
        if not scheme in ('http', 'https', 'ftp', 'ftps'):
            ## FIXME: some warning or something?
            ## assertion error?
            return ''

        resp = session.head(url, allow_redirects=True)
        resp.raise_for_status()

        return resp.headers.get("Content-Type", "") 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:17,代码来源:index.py

示例3: filename

# 需要导入模块: from pip.backwardcompat import urlparse [as 别名]
# 或者: from pip.backwardcompat.urlparse import urlsplit [as 别名]
def filename(self):
        _, netloc, path, _, _ = urlparse.urlsplit(self.url)
        name = posixpath.basename(path.rstrip('/')) or netloc
        assert name, ('URL %r produced no filename' % self.url)
        return name 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:7,代码来源:index.py

示例4: scheme

# 需要导入模块: from pip.backwardcompat import urlparse [as 别名]
# 或者: from pip.backwardcompat.urlparse import urlsplit [as 别名]
def scheme(self):
        return urlparse.urlsplit(self.url)[0] 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:4,代码来源:index.py

示例5: path

# 需要导入模块: from pip.backwardcompat import urlparse [as 别名]
# 或者: from pip.backwardcompat.urlparse import urlsplit [as 别名]
def path(self):
        return urlparse.urlsplit(self.url)[2] 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:4,代码来源:index.py

示例6: url_without_fragment

# 需要导入模块: from pip.backwardcompat import urlparse [as 别名]
# 或者: from pip.backwardcompat.urlparse import urlsplit [as 别名]
def url_without_fragment(self):
        scheme, netloc, path, query, fragment = urlparse.urlsplit(self.url)
        return urlparse.urlunsplit((scheme, netloc, path, query, None)) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:5,代码来源:index.py

示例7: get_rev_options

# 需要导入模块: from pip.backwardcompat import urlparse [as 别名]
# 或者: from pip.backwardcompat.urlparse import urlsplit [as 别名]
def get_rev_options(url, rev):
    if rev:
        rev_options = ['-r', rev]
    else:
        rev_options = []

    r = urlparse.urlsplit(url)
    if hasattr(r, 'username'):
        # >= Python-2.5
        username, password = r.username, r.password
    else:
        netloc = r[1]
        if '@' in netloc:
            auth = netloc.split('@')[0]
            if ':' in auth:
                username, password = auth.split(':', 1)
            else:
                username, password = auth, None
        else:
            username, password = None, None

    if username:
        rev_options += ['--username', username]
    if password:
        rev_options += ['--password', password]
    return rev_options 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:28,代码来源:subversion.py

示例8: __init__

# 需要导入模块: from pip.backwardcompat import urlparse [as 别名]
# 或者: from pip.backwardcompat.urlparse import urlsplit [as 别名]
def __init__(self, url=None, *args, **kwargs):

        # Works around an apparent Git bug
        # (see http://article.gmane.org/gmane.comp.version-control.git/146500)
        if url:
            scheme, netloc, path, query, fragment = urlsplit(url)
            if scheme.endswith('file'):
                initial_slashes = path[:-len(path.lstrip('/'))]
                newpath = initial_slashes + url2pathname(path).replace('\\', '/').lstrip('/')
                url = urlunsplit((scheme, netloc, newpath, query, fragment))
                after_plus = scheme.find('+') + 1
                url = scheme[:after_plus] + urlunsplit((scheme[after_plus:], netloc, newpath, query, fragment))

        super(Git, self).__init__(url, *args, **kwargs) 
开发者ID:jwvanderbeck,项目名称:krpcScripts,代码行数:16,代码来源:git.py


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