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


Python urllib.unquote方法代码示例

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


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

示例1: normalize_url

# 需要导入模块: from pip.backwardcompat import urllib [as 别名]
# 或者: from pip.backwardcompat.urllib import unquote [as 别名]
def normalize_url(self, url):
        """
        Normalize a URL for comparison by unquoting it and removing any trailing slash.
        """
        return urllib.unquote(url).rstrip('/') 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:7,代码来源:__init__.py

示例2: url_to_path

# 需要导入模块: from pip.backwardcompat import urllib [as 别名]
# 或者: from pip.backwardcompat.urllib import unquote [as 别名]
def url_to_path(url):
    """
    Convert a file: URL to a path.
    """
    assert url.startswith('file:'), (
        "You can only turn file: urls into filenames (not %r)" % url)
    path = url[len('file:'):].lstrip('/')
    path = urllib.unquote(path)
    if _url_drive_re.match(path):
        path = path[0] + ':' + path[2:]
    else:
        path = '/' + path
    return path 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:15,代码来源:download.py

示例3: get_file_content

# 需要导入模块: from pip.backwardcompat import urllib [as 别名]
# 或者: from pip.backwardcompat.urllib import unquote [as 别名]
def get_file_content(url, comes_from=None, session=None):
    """Gets the content of a file; it may be a filename, file: URL, or
    http: URL.  Returns (location, content).  Content is unicode."""
    if session is None:
        session = PipSession()

    match = _scheme_re.search(url)
    if match:
        scheme = match.group(1).lower()
        if (scheme == 'file' and comes_from
            and comes_from.startswith('http')):
            raise InstallationError(
                'Requirements file %s references URL %s, which is local'
                % (comes_from, url))
        if scheme == 'file':
            path = url.split(':', 1)[1]
            path = path.replace('\\', '/')
            match = _url_slash_drive_re.match(path)
            if match:
                path = match.group(1) + ':' + path.split('|', 1)[1]
            path = urllib.unquote(path)
            if path.startswith('/'):
                path = '/' + path.lstrip('/')
            url = path
        else:
            ## FIXME: catch some errors
            resp = session.get(url)
            resp.raise_for_status()

            if six.PY3:
                return resp.url, resp.text
            else:
                return resp.url, resp.content
    try:
        f = open(url)
        content = f.read()
    except IOError:
        e = sys.exc_info()[1]
        raise InstallationError('Could not open requirements file: %s' % str(e))
    else:
        f.close()
    return url, content 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:44,代码来源:download.py


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