當前位置: 首頁>>代碼示例>>Python>>正文


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;未經允許,請勿轉載。