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


Python parse.ParseResult方法代码示例

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


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

示例1: Parse

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import ParseResult [as 别名]
def Parse(self, uri):
    parsed = urlparse(uri)
    # Work around python 2.7.3 not handling # in URIs correctly.
    if '#' in parsed.path:
      path, fragment = parsed.path.split('#', 1)
      parsed = ParseResult(
          scheme = parsed.scheme,
          netloc = parsed.netloc,
          path = path,
          params = parsed.params,
          query = parsed.query,
          fragment = fragment
      )

    handler = self.handlers.get(parsed.scheme.lower(), None)
    if not handler:
      raise Exception("No handler found for prefix %s" % parsed.scheme)
    return handler(parsed) 
开发者ID:steveniemitz,项目名称:scales,代码行数:20,代码来源:core.py

示例2: __new__

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import ParseResult [as 别名]
def __new__(cls, pr):
        return super(ParseResult, cls).__new__(cls, *pr) 
开发者ID:biocommons,项目名称:hgvs,代码行数:4,代码来源:ncbi.py

示例3: _parse_url

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import ParseResult [as 别名]
def _parse_url(db_url):
    """parse database connection urls into components

    UTA database connection URLs follow that of SQLAlchemy, except
    that a schema may be optionally specified after the database. The
    skeleton format is:

       driver://user:pass@host/database/schema

    >>> params = _parse_url("driver://user:pass@host:9876/database/schema")

    >>> params.scheme
    u'driver'

    >>> params.hostname
    u'host'

    >>> params.username
    u'user'

    >>> params.password
    u'pass'

    >>> params.database
    u'database'

    >>> params.schema
    u'schema'

    """

    return ParseResult(urlparse.urlparse(db_url)) 
开发者ID:biocommons,项目名称:hgvs,代码行数:34,代码来源:ncbi.py

示例4: setUp

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import ParseResult [as 别名]
def setUp(self):
        super(TestClientHTTPBasicAuth, self).setUp()
        conf = ceilometer_service.prepare_service(argv=[], config_files=[])
        self.CONF = self.useFixture(config_fixture.Config(conf)).conf
        self.parsed_url = urlparse.urlparse(
            'http://127.0.0.1:8080/controller/statistics?'
            'auth=%s&user=admin&password=admin_pass&'
            'scheme=%s' % (self.auth_way, self.scheme))
        self.params = urlparse.parse_qs(self.parsed_url.query)
        self.endpoint = urlparse.urlunparse(
            urlparse.ParseResult(self.scheme,
                                 self.parsed_url.netloc,
                                 self.parsed_url.path,
                                 None, None, None))
        odl_params = {'auth': self.params.get('auth')[0],
                      'user': self.params.get('user')[0],
                      'password': self.params.get('password')[0]}
        self.client = client.Client(self.CONF, self.endpoint, odl_params)

        self.resp = mock.MagicMock()
        self.get = mock.patch('requests.Session.get',
                              return_value=self.resp).start()

        self.resp.raw.version = 1.1
        self.resp.status_code = 200
        self.resp.reason = 'OK'
        self.resp.headers = {}
        self.resp.content = 'dummy' 
开发者ID:openstack,项目名称:networking-odl,代码行数:30,代码来源:test_client.py

示例5: __init__

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import ParseResult [as 别名]
def __init__(self, url):
        """
        :param urlparse.ParseResult url:
        """
        super().__init__("The URL '%s' is invalid." % url.geturl()) 
开发者ID:DataBiosphere,项目名称:toil,代码行数:7,代码来源:abstractJobStore.py

示例6: _findJobStoreForUrl

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import ParseResult [as 别名]
def _findJobStoreForUrl(self, url, export=False):
        """
        Returns the AbstractJobStore subclass that supports the given URL.

        :param urlparse.ParseResult url: The given URL
        :param bool export: The URL for
        :rtype: toil.jobStore.AbstractJobStore
        """
        for jobStoreCls in self._jobStoreClasses:
            if jobStoreCls._supportsUrl(url, export):
                return jobStoreCls
        raise RuntimeError("No job store implementation supports %sporting for URL '%s'" %
                           ('ex' if export else 'im', url.geturl())) 
开发者ID:DataBiosphere,项目名称:toil,代码行数:15,代码来源:abstractJobStore.py

示例7: _importFile

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import ParseResult [as 别名]
def _importFile(self, otherCls, url, sharedFileName=None, hardlink=False):
        """
        Import the file at the given URL using the given job store class to retrieve that file.
        See also :meth:`.importFile`. This method applies a generic approach to importing: it
        asks the other job store class for a stream and writes that stream as either a regular or
        a shared file.

        :param AbstractJobStore otherCls: The concrete subclass of AbstractJobStore that supports
               reading from the given URL and getting the file size from the URL.

        :param urlparse.ParseResult url: The location of the file to import.

        :param str sharedFileName: Optional name to assign to the imported file within the job store

        :return The jobStoreFileId of imported file or None if sharedFileName was given
        :rtype: toil.fileStores.FileID or None
        """
        if sharedFileName is None:
            with self.writeFileStream() as (writable, jobStoreFileID):
                size = otherCls._readFromUrl(url, writable)
                return FileID(jobStoreFileID, size)
        else:
            self._requireValidSharedFileName(sharedFileName)
            with self.writeSharedFileStream(sharedFileName) as writable:
                otherCls._readFromUrl(url, writable)
                return None 
开发者ID:DataBiosphere,项目名称:toil,代码行数:28,代码来源:abstractJobStore.py

示例8: _exportFile

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import ParseResult [as 别名]
def _exportFile(self, otherCls, jobStoreFileID, url):
        """
        Refer to exportFile docstring for information about this method.

        :param AbstractJobStore otherCls: The concrete subclass of AbstractJobStore that supports
               exporting to the given URL. Note that the type annotation here is not completely
               accurate. This is not an instance, it's a class, but there is no way to reflect
               that in :pep:`484` type hints.

        :param str jobStoreFileID: The id of the file that will be exported.

        :param urlparse.ParseResult url: The parsed URL of the file to export to.
        """
        self._defaultExportFile(otherCls, jobStoreFileID, url) 
开发者ID:DataBiosphere,项目名称:toil,代码行数:16,代码来源:abstractJobStore.py

示例9: _defaultExportFile

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import ParseResult [as 别名]
def _defaultExportFile(self, otherCls, jobStoreFileID, url):
        """
        Refer to exportFile docstring for information about this method.

        :param AbstractJobStore otherCls: The concrete subclass of AbstractJobStore that supports
               exporting to the given URL. Note that the type annotation here is not completely
               accurate. This is not an instance, it's a class, but there is no way to reflect
               that in :pep:`484` type hints.

        :param str jobStoreFileID: The id of the file that will be exported.

        :param urlparse.ParseResult url: The parsed URL of the file to export to.
        """
        with self.readFileStream(jobStoreFileID) as readable:
            otherCls._writeToUrl(readable, url) 
开发者ID:DataBiosphere,项目名称:toil,代码行数:17,代码来源:abstractJobStore.py

示例10: _readFromUrl

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import ParseResult [as 别名]
def _readFromUrl(cls, url, writable):
        """
        Reads the contents of the object at the specified location and writes it to the given
        writable stream.

        Refer to :func:`~AbstractJobStore.importFile` documentation for currently supported URL schemes.

        :param urlparse.ParseResult url: URL that points to a file or object in the storage
               mechanism of a supported URL scheme e.g. a blob in an AWS s3 bucket.

        :param writable: a writable stream

        :return int: returns the size of the file in bytes
        """
        raise NotImplementedError() 
开发者ID:DataBiosphere,项目名称:toil,代码行数:17,代码来源:abstractJobStore.py

示例11: _writeToUrl

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import ParseResult [as 别名]
def _writeToUrl(cls, readable, url):
        """
        Reads the contents of the given readable stream and writes it to the object at the
        specified location.

        Refer to AbstractJobStore.importFile documentation for currently supported URL schemes.

        :param urlparse.ParseResult url: URL that points to a file or object in the storage
               mechanism of a supported URL scheme e.g. a blob in an AWS s3 bucket.

        :param readable: a readable stream
        """
        raise NotImplementedError() 
开发者ID:DataBiosphere,项目名称:toil,代码行数:15,代码来源:abstractJobStore.py

示例12: _supportsUrl

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import ParseResult [as 别名]
def _supportsUrl(cls, url, export=False):
        """
        Returns True if the job store supports the URL's scheme.

        Refer to AbstractJobStore.importFile documentation for currently supported URL schemes.

        :param bool export: Determines if the url is supported for exported
        :param urlparse.ParseResult url: a parsed URL that may be supported
        :return bool: returns true if the cls supports the URL
        """
        raise NotImplementedError() 
开发者ID:DataBiosphere,项目名称:toil,代码行数:13,代码来源:abstractJobStore.py

示例13: test_load_cert_chain_invalid_cert_url_throw_exception

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import ParseResult [as 别名]
def test_load_cert_chain_invalid_cert_url_throw_exception(self):
        mocked_parsed_url = mock.MagicMock(spec=ParseResult)
        with mock.patch(
                "ask_sdk_webservice_support.verifier.urlparse",
                return_value=mocked_parsed_url):

            with self.assertRaises(VerificationException) as exc:
                self.request_verifier._load_cert_chain(self.MALFORMED_URL)

        self.assertIn(
            "Unable to load certificate from URL", str(exc.exception)) 
开发者ID:alexa,项目名称:alexa-skills-kit-sdk-for-python,代码行数:13,代码来源:test_verifier.py


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