Python parse.SplitResult方法代码示例

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

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

示例1: urlparts

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import SplitResult [as 别名]
def urlparts(self):
        ''' The :attr:`url` string as an :class:`urlparse.SplitResult` tuple.
            The tuple contains (scheme, host, path, query_string and fragment),
            but the fragment is always empty because it is not visible to the
            server. '''
        env = self.environ
        http = env.get('HTTP_X_FORWARDED_PROTO') or env.get('wsgi.url_scheme', 'http')
        host = env.get('HTTP_X_FORWARDED_HOST') or env.get('HTTP_HOST')
        if not host:
            # HTTP 1.1 requires a Host-header. This is for HTTP/1.0 clients.
            host = env.get('SERVER_NAME', '127.0.0.1')
            port = env.get('SERVER_PORT')
            if port and port != ('80' if http == 'http' else '443'):
                host += ':' + port
        path = urlquote(self.fullpath)
        return UrlSplitResult(http, host, path, env.get('QUERY_STRING'), '') 
开发者ID:Autodesk,项目名称:arnold-usd,代码行数:18,代码来源:__init__.py


示例2: delete

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import SplitResult [as 别名]
def delete(url):
        url = unquote(url)
        match, project = Cache.match(url)
        if match:
            path = Cache.path(url, project, include_file=True)
            # Rather then wait for last updated statistics to expire, remove the
            # project cache if applicable.
            if project:
                apiurl, _ = Cache.spliturl(url)
                if project.isdigit():
                    # Clear target project cache upon request acceptance.
                    project = osc.core.get_request(apiurl, project).actions[0].tgt_project
                Cache.delete_project(apiurl, project)
            if os.path.exists(path):
                if conf.config['debug']: print('CACHE_DELETE', url, file=sys.stderr)
                os.remove(path)
        # Also delete version without query. This does not handle other
        # variations using different query strings. Handy for PUT with ?force=1.
        o = urlsplit(url)
        if o.query != '':
            url_plain = SplitResult(o.scheme, o.netloc, o.path, '', o.fragment).geturl()
            Cache.delete(url_plain) 
开发者ID:openSUSE,项目名称:openSUSE-release-tools,代码行数:27,代码来源:cache.py


示例3: urlparts

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import SplitResult [as 别名]
def urlparts(self):
        """ The :attr:`url` string as an :class:`urlparse.SplitResult` tuple.
            The tuple contains (scheme, host, path, query_string and fragment),
            but the fragment is always empty because it is not visible to the
            server. """
        env = self.environ
        http = env.get('HTTP_X_FORWARDED_PROTO') \
             or env.get('wsgi.url_scheme', 'http')
        host = env.get('HTTP_X_FORWARDED_HOST') or env.get('HTTP_HOST')
        if not host:
            # HTTP 1.1 requires a Host-header. This is for HTTP/1.0 clients.
            host = env.get('SERVER_NAME', '127.0.0.1')
            port = env.get('SERVER_PORT')
            if port and port != ('80' if http == 'http' else '443'):
                host += ':' + port
        path = urlquote(self.fullpath)
        return UrlSplitResult(http, host, path, env.get('QUERY_STRING'), '') 
开发者ID:brycesub,项目名称:silvia-pi,代码行数:19,代码来源:bottle.py


示例4: build_url_for_request

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import SplitResult [as 别名]
def build_url_for_request(request=None, path="", query=None, fragment=""):
    """ Builds a url from the base url relevant for the current request context
    :request: An instance of django.http.HTTPRequest
    :path: A str indicating the path
    :query: A dictionary with any GET parameters
    :fragment: A string indicating the fragment
    :return: An instance of urllib.parse.SplitResult
    """
    if request is None:
        request = get_current_request()
    return build_url(
        netloc=request.get_host(),
        scheme=request.scheme,
        path=path,
        query=query,
        fragment=fragment,
    ) 
开发者ID:BirkbeckCTP,项目名称:janeway,代码行数:20,代码来源:logic.py


示例5: urlparts

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import SplitResult [as 别名]
def urlparts(self):
        """ The :attr:`url` string as an :class:`urlparse.SplitResult` tuple.
            The tuple contains (scheme, host, path, query_string and fragment),
            but the fragment is always empty because it is not visible to the
            server. """
        env = self.environ
        http = env.get('HTTP_X_FORWARDED_PROTO') or env.get('wsgi.url_scheme', 'http')
        host = env.get('HTTP_X_FORWARDED_HOST') or env.get('HTTP_HOST')
        if not host:
            # HTTP 1.1 requires a Host-header. This is for HTTP/1.0 clients.
            host = env.get('SERVER_NAME', '127.0.0.1')
            port = env.get('SERVER_PORT')
            if port and port != ('80' if http == 'http' else '443'):
                host += ':' + port
        path = urlquote(self.fullpath)
        return UrlSplitResult(http, host, path, env.get('QUERY_STRING'), '') 
开发者ID:warriorframework,项目名称:warriorframework,代码行数:18,代码来源:bottle.py


示例6: fetch_api_description

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import SplitResult [as 别名]
def fetch_api_description(
    url: typing.Union[str, ParseResult, SplitResult], insecure: bool = False
):
    """Fetch the API description from the remote MAAS instance."""
    url_describe = urljoin(_ensure_url_string(url), "describe/")
    connector = aiohttp.TCPConnector(verify_ssl=(not insecure))
    session = aiohttp.ClientSession(connector=connector)
    async with session, session.get(url_describe) as response:
        if response.status != HTTPStatus.OK:
            raise RemoteError("{0} -> {1.status} {1.reason}".format(url, response))
        elif response.content_type != "application/json":
            raise RemoteError(
                "Expected application/json, got: %s" % response.content_type
            )
        else:
            return await response.json() 
开发者ID:maas,项目名称:python-libmaas,代码行数:18,代码来源:helpers.py


示例7: __init__

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import SplitResult [as 别名]
def __init__(self, url: parse.SplitResult, location_type=None,
                 container_subvolume_relpath: str = None):
        """
        c'tor
        :param url: Location URL
        """
        super().__init__(url)
        self.__location_type = None
        self.__uuid = None
        self.__container_subvolume_relpath = None
        self.__compress = False
        self.__retention = None
        self.__snapshots = []
        self.__identical_filesystem = False
        self.location_type = location_type
        if self.location_type == JobLocation.TYPE_SOURCE and container_subvolume_relpath is None:
            self.container_subvolume_relpath = _DEFAULT_CONTAINER_RELPATH
        else:
            self.container_subvolume_relpath = container_subvolume_relpath 
开发者ID:masc3d,项目名称:btrfs-sxbackup,代码行数:24,代码来源:core.py


示例8: __init__

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import SplitResult [as 别名]
def __init__(self, schema, netloc, port, path, query, fragment, userinfo):
        self._strict = False
        if port:
            netloc += ':{}'.format(port)
        if userinfo:
            netloc = yarl.quote(
                userinfo, safe='@:',
                protected=':', strict=False) + '@' + netloc
        if path:
            path = yarl.quote(path, safe='@:', protected='/', strict=False)
        if query:
            query = yarl.quote(
                query, safe='=+&?/:@',
                protected=yarl.PROTECT_CHARS, qs=True, strict=False)
        if fragment:
            fragment = yarl.quote(fragment, safe='?/:@', strict=False)
        self._val = SplitResult(
            schema or '',  # scheme
            netloc=netloc, path=path, query=query, fragment=fragment)
        self._cache = {} 
开发者ID:skylander86,项目名称:lambda-text-extractor,代码行数:27,代码来源:http_writer.py



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