當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。