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


Python urlparse.unquote方法代码示例

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


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

示例1: filename

# 需要导入模块: import urlparse [as 别名]
# 或者: from urlparse import unquote [as 别名]
def filename(self):
        '''Returns the filename to be used for saving the repo file.

        The filename is derived from the repo url by injecting a suffix
        after the name and before the file extension. This suffix is a
        partial md5 checksum of the full repourl. This avoids multiple
        repos from being written to the same file.
        '''
        urlpath = unquote(urlsplit(self.repourl, allow_fragments=False).path)
        basename = os.path.basename(urlpath)
        if not basename.endswith(REPO_SUFFIX):
            basename += REPO_SUFFIX
        if self.add_hash:
            suffix = '-' + md5(self.repourl.encode('utf-8')).hexdigest()[:5]  # nosec
        else:
            suffix = ''
        final_name = suffix.join(os.path.splitext(basename))
        return final_name 
开发者ID:containerbuildsystem,项目名称:atomic-reactor,代码行数:20,代码来源:yum.py

示例2: GET

# 需要导入模块: import urlparse [as 别名]
# 或者: from urlparse import unquote [as 别名]
def GET(self, obj, query_params=None):
        # Replace the a10_url with just the base path, stripping out any previous querystring
        parse_result = urlparse.urlparse(obj.a10_url)
        obj.a10_url = parse_result.path
        obj.a10_url = self.url_encoder(obj.a10_url)
        if query_params:
            obj.a10_url += '?' + urlparse.unquote(urllib.urlencode(query_params))

        conn = self.get_connection()
        conn.request("GET", obj.a10_url, "", self.headers)
        response = conn.getresponse()
        conn.close()
        obj.__setattr__("DEBUG_CONNECTION", conn.__dict__)
        obj.__setattr__("DEBUG_Payload", "")
        obj.__setattr__("DEBUG_Response", response)
        obj.__setattr__("DEBUG_URL", obj.a10_url)
        obj.__setattr__("DEBUG_headers", self.headers)
        return self.request_handler("GET", obj, response)


    # TODO: Due to Bug 175975, add zero_length kwarg to optionally send zero-length POST. Remove code once bug resolved 
开发者ID:a10networks,项目名称:a10sdk-python,代码行数:23,代码来源:device_proxy.py

示例3: _ParseBaseRequest

# 需要导入模块: import urlparse [as 别名]
# 或者: from urlparse import unquote [as 别名]
def _ParseBaseRequest(self, method):
        """Return path, headers and post data commonly required by all methods"""

        try:
            from urllib.parse import unquote, urlparse, parse_qsl
        except ImportError:
            from urlparse import unquote, urlparse, parse_qsl

        path = py2_decode(urlparse(self.path).path[1:])  # Get URI without the trailing slash
        path = path.split('/')  # license/<asin>/<ATV endpoint>
        Log('[PS] Requested {} path {}'.format(method, path), Log.DEBUG)

        # Retrieve headers and data
        headers = {k: self.headers[k] for k in self.headers if k not in ['host', 'content-length']}
        data_length = self.headers.get('content-length')
        data = {k: v for k, v in parse_qsl(self.rfile.read(int(data_length)))} if data_length else None
        return (path, headers, data) 
开发者ID:Sandmann79,项目名称:xbmc,代码行数:19,代码来源:proxy.py

示例4: do_POST

# 需要导入模块: import urlparse [as 别名]
# 或者: from urlparse import unquote [as 别名]
def do_POST(self):
        """Respond to POST requests"""

        try:
            from urllib.parse import unquote
        except ImportError:
            from urlparse import unquote

        path, headers, data = self._ParseBaseRequest('POST')
        if None is path: return

        if ('gpr' == path[0]) and (2 == len(path)):
            self._AlterGPR(unquote(path[1]), headers, data)
        else:
            Log('[PS] Invalid request received', Log.DEBUG)
            self.send_error(501, 'Invalid request') 
开发者ID:Sandmann79,项目名称:xbmc,代码行数:18,代码来源:proxy.py

示例5: do_GET

# 需要导入模块: import urlparse [as 别名]
# 或者: from urlparse import unquote [as 别名]
def do_GET(self):
        """Respond to GET requests"""

        try:
            from urllib.parse import unquote
        except ImportError:
            from urlparse import unquote

        path, headers, data = self._ParseBaseRequest('GET')
        if None is path: return

        if ('mpd' == path[0]) and (2 == len(path)):
            self._AlterMPD(unquote(path[1]), headers, data)
        elif ('subtitles' == path[0]) and (3 == len(path)):
            self._TranscodeSubtitle(unquote(path[1]), headers, data, path[2])
        else:
            Log('[PS] Invalid request received', Log.DEBUG)
            self.send_error(501, 'Invalid request') 
开发者ID:Sandmann79,项目名称:xbmc,代码行数:20,代码来源:proxy.py

示例6: api_index

# 需要导入模块: import urlparse [as 别名]
# 或者: from urlparse import unquote [as 别名]
def api_index(request):
    if check_if_valid_token(request):
        try:
            token = urlparse.unquote(request.META['HTTP_AUTHORIZATION'])
            user_id = extrapolate_user(token)
            user = User.objects.get(user_id=user_id)
            if user.is_admin:
                data = serializers.serialize("json", User.objects.all())
                return HttpResponse(data, content_type='application/json')
            else:
                data = serializers.serialize("json", User.objects.filter(user_id=user_id))
                return HttpResponse(data, content_type='application/json')
        except User.DoesNotExist:
            return HttpResponse("null", content_type='application/json')
    else:
        return HttpResponse('Unauthorized', status=401) 
开发者ID:Contrast-Security-OSS,项目名称:DjanGoat,代码行数:18,代码来源:views.py

示例7: check_if_valid_token

# 需要导入模块: import urlparse [as 别名]
# 或者: from urlparse import unquote [as 别名]
def check_if_valid_token(request):
    if 'HTTP_AUTHORIZATION' not in request.META:
        return False
    else:
        token = urlparse.unquote(request.META['HTTP_AUTHORIZATION'])
        regex = re.compile("(.*?)-(.*)")
        split_token = token.split('=')[1]
        regex_groups = regex.search(split_token)
        if regex_groups.group(1):
            group_id = regex_groups.group(1)
        else:
            return False
        if regex_groups.group(2):
            group_hash = regex_groups.group(2)
        else:
            return False

    sha = SHA.new()
    sha.update(ACCESS_TOKEN_SALT + ":" + str(group_id))
    return group_hash == sha.hexdigest() 
开发者ID:Contrast-Security-OSS,项目名称:DjanGoat,代码行数:22,代码来源:views.py

示例8: url2name

# 需要导入模块: import urlparse [as 别名]
# 或者: from urlparse import unquote [as 别名]
def url2name(url):

    from os.path import basename

    url = url.split('|')[0]
    return basename(unquote(urlparse.urlsplit(url)[2])) 
开发者ID:bugatsinho,项目名称:bugatsinho.github.io,代码行数:8,代码来源:client.py

示例9: parse_redis_url

# 需要导入模块: import urlparse [as 别名]
# 或者: from urlparse import unquote [as 别名]
def parse_redis_url(url, password_quote):
    """Parses a redis URL."""

    # create config with some sane defaults
    redis_config = {
        "DB": 0,
        "PASSWORD": None,
        "HOST": "localhost",
        "PORT": 6379,
        "SSL": False,
    }

    if not url:
        return redis_config

    url = urlparse.urlparse(url)
    # Remove query strings.
    path = url.path[1:]
    path = path.split("?", 2)[0]

    if path:
        redis_config.update({"DB": int(path)})
    if url.password:
        password = url.password
        if password_quote:
            password = urlparse.unquote(password)
        redis_config.update({"PASSWORD": password})
    if url.hostname:
        redis_config.update({"HOST": url.hostname})
    if url.port:
        redis_config.update({"PORT": int(url.port)})
    if url.scheme in ["https", "rediss"]:
        redis_config.update({"SSL": True})

    return redis_config 
开发者ID:jazzband,项目名称:django-defender,代码行数:37,代码来源:connection.py

示例10: unquote_bytes_to_wsgi

# 需要导入模块: import urlparse [as 别名]
# 或者: from urlparse import unquote [as 别名]
def unquote_bytes_to_wsgi(bytestring):
        return unquote_to_bytes(bytestring).decode('latin-1') 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:4,代码来源:compat.py

示例11: filename

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

示例12: path

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

示例13: normalize

# 需要导入模块: import urlparse [as 别名]
# 或者: from urlparse import unquote [as 别名]
def normalize(string):
    unescaped = unescape(string)
    unquoted = unquote(unescaped)
    return unicodedata.normalize("NFKD", unquoted).replace('\n', '') 
开发者ID:a4k-openproject,项目名称:a4kScrapers,代码行数:6,代码来源:utils.py

示例14: file_url_to_local_path

# 需要导入模块: import urlparse [as 别名]
# 或者: from urlparse import unquote [as 别名]
def file_url_to_local_path(file_url):
    parts = urlparse.urlparse(file_url)
    path = urlparse.unquote(parts.path)
    if path.startswith('/') and not path.startswith('//'):
        if len(parts.netloc) == 2 and parts.netloc[1] == ':':
            return parts.netloc + path
        return 'C:' + path
    if len(path) > 2 and path[1] == ':':
        return path 
开发者ID:genotrance,项目名称:px,代码行数:11,代码来源:px.py

示例15: path_from_uri

# 需要导入模块: import urlparse [as 别名]
# 或者: from urlparse import unquote [as 别名]
def path_from_uri(uri):
    # Convert file uri to path (strip html like head part)
    if not uri.startswith("file://"):
        return uri
    if os.name == "nt":
        _, path = uri.split("file:///", 1)
    else:
        _, path = uri.split("file://", 1)
    return os.path.normpath(unquote(path)) 
开发者ID:hansec,项目名称:fortran-language-server,代码行数:11,代码来源:jsonrpc.py


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