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


Python misc.parse_uri函数代码示例

本文整理汇总了Python中taskflow.utils.misc.parse_uri函数的典型用法代码示例。如果您正苦于以下问题:Python parse_uri函数的具体用法?Python parse_uri怎么用?Python parse_uri使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_merge_user_password

 def test_merge_user_password(self):
     url = "http://josh:[email protected]/"
     parsed = misc.parse_uri(url)
     joined = misc.merge_uri(parsed, {})
     self.assertEqual('www.yahoo.com', joined.get('hostname'))
     self.assertEqual('josh', joined.get('username'))
     self.assertEqual('harlow', joined.get('password'))
开发者ID:junneyang,项目名称:taskflow,代码行数:7,代码来源:test_utils.py

示例2: test_merge

 def test_merge(self):
     url = "http://www.yahoo.com/?a=b&c=d"
     parsed = misc.parse_uri(url)
     joined = misc.merge_uri(parsed, {})
     self.assertEqual('b', joined.get('a'))
     self.assertEqual('d', joined.get('c'))
     self.assertEqual('www.yahoo.com', joined.get('hostname'))
开发者ID:junneyang,项目名称:taskflow,代码行数:7,代码来源:test_utils.py

示例3: test_port_provided

 def test_port_provided(self):
     url = "rabbitmq://www.yahoo.com:5672"
     parsed = misc.parse_uri(url)
     self.assertEqual('rabbitmq', parsed.scheme)
     self.assertEqual('www.yahoo.com', parsed.hostname)
     self.assertEqual(5672, parsed.port)
     self.assertEqual('', parsed.path)
开发者ID:codybum,项目名称:OpenStackInAction,代码行数:7,代码来源:test_utils.py

示例4: _extract_engine

def _extract_engine(**kwargs):
    """Extracts the engine kind and any associated options."""
    options = {}
    kind = kwargs.pop('engine', None)
    engine_conf = kwargs.pop('engine_conf', None)
    if engine_conf is not None:
        warnings.warn("Using the 'engine_conf' argument is"
                      " deprecated and will be removed in a future version,"
                      " please use the 'engine' argument instead.",
                      DeprecationWarning)
        if isinstance(engine_conf, six.string_types):
            kind = engine_conf
        else:
            options.update(engine_conf)
            kind = options.pop('engine', None)
    if not kind:
        kind = ENGINE_DEFAULT
    # See if it's a URI and if so, extract any further options...
    try:
        uri = misc.parse_uri(kind)
    except (TypeError, ValueError):
        pass
    else:
        kind = uri.scheme
        options = misc.merge_uri(uri, options.copy())
    # Merge in any leftover **kwargs into the options, this makes it so that
    # the provided **kwargs override any URI or engine_conf specific options.
    options.update(kwargs)
    return (kind, options)
开发者ID:kbijon,项目名称:OpenStack-CVRM,代码行数:29,代码来源:helpers.py

示例5: _compat_extract

 def _compat_extract(**kwargs):
     options = {}
     kind = kwargs.pop('engine', None)
     engine_conf = kwargs.pop('engine_conf', None)
     if engine_conf is not None:
         if isinstance(engine_conf, six.string_types):
             kind = engine_conf
         else:
             options.update(engine_conf)
             kind = options.pop('engine', None)
     if not kind:
         kind = ENGINE_DEFAULT
     # See if it's a URI and if so, extract any further options...
     try:
         uri = misc.parse_uri(kind)
     except (TypeError, ValueError):
         pass
     else:
         kind = uri.scheme
         options = misc.merge_uri(uri, options.copy())
     # Merge in any leftover **kwargs into the options, this makes it so
     # that the provided **kwargs override any URI or engine_conf specific
     # options.
     options.update(kwargs)
     return (kind, options)
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:25,代码来源:helpers.py

示例6: test_parse

 def test_parse(self):
     url = "zookeeper://192.168.0.1:2181/a/b/?c=d"
     parsed = misc.parse_uri(url)
     self.assertEqual('zookeeper', parsed.scheme)
     self.assertEqual(2181, parsed.port)
     self.assertEqual('192.168.0.1', parsed.hostname)
     self.assertEqual('', parsed.fragment)
     self.assertEqual('/a/b/', parsed.path)
     self.assertEqual({'c': 'd'}, parsed.params)
开发者ID:codybum,项目名称:OpenStackInAction,代码行数:9,代码来源:test_utils.py

示例7: test_merge_user_password_existing

 def test_merge_user_password_existing(self):
     url = "http://josh:[email protected]/"
     parsed = misc.parse_uri(url)
     existing = {
         'username': 'joe',
         'password': 'biggie',
     }
     joined = misc.merge_uri(parsed, existing)
     self.assertEqual('www.yahoo.com', joined.get('hostname'))
     self.assertEqual('joe', joined.get('username'))
     self.assertEqual('biggie', joined.get('password'))
开发者ID:junneyang,项目名称:taskflow,代码行数:11,代码来源:test_utils.py

示例8: fetch

def fetch(conf, namespace=BACKEND_NAMESPACE, **kwargs):
    """Fetch a persistence backend with the given configuration.

    This fetch method will look for the entrypoint name in the entrypoint
    namespace, and then attempt to instantiate that entrypoint using the
    provided configuration and any persistence backend specific kwargs.

    NOTE(harlowja): to aid in making it easy to specify configuration and
    options to a backend the configuration (which is typical just a dictionary)
    can also be a URI string that identifies the entrypoint name and any
    configuration specific to that backend.

    For example, given the following configuration URI::

        mysql://<not-used>/?a=b&c=d

    This will look for the entrypoint named 'mysql' and will provide
    a configuration object composed of the URI's components, in this case that
    is ``{'a': 'b', 'c': 'd'}`` to the constructor of that persistence backend
    instance.
    """
    if isinstance(conf, six.string_types):
        conf = {'connection': conf}
    backend_name = conf['connection']
    try:
        uri = misc.parse_uri(backend_name)
    except (TypeError, ValueError):
        pass
    else:
        backend_name = uri.scheme
        conf = misc.merge_uri(uri, conf.copy())
    # If the backend is like 'mysql+pymysql://...' which informs the
    # backend to use a dialect (supported by sqlalchemy at least) we just want
    # to look at the first component to find our entrypoint backend name...
    if backend_name.find("+") != -1:
        backend_name = backend_name.split("+", 1)[0]
    LOG.debug('Looking for %r backend driver in %r', backend_name, namespace)
    try:
        mgr = driver.DriverManager(namespace, backend_name,
                                   invoke_on_load=True,
                                   invoke_args=(conf,),
                                   invoke_kwds=kwargs)
        return mgr.driver
    except RuntimeError as e:
        raise exc.NotFound("Could not find backend %s: %s" % (backend_name, e))
开发者ID:linkedinyou,项目名称:taskflow,代码行数:45,代码来源:__init__.py

示例9: _extract_engine

def _extract_engine(engine, **kwargs):
    """Extracts the engine kind and any associated options."""
    kind = engine
    if not kind:
        kind = ENGINE_DEFAULT

    # See if it's a URI and if so, extract any further options...
    options = {}
    try:
        uri = misc.parse_uri(kind)
    except (TypeError, ValueError):
        pass
    else:
        kind = uri.scheme
        options = misc.merge_uri(uri, options.copy())

    # Merge in any leftover **kwargs into the options, this makes it so
    # that the provided **kwargs override any URI/engine specific
    # options.
    options.update(kwargs)
    return (kind, options)
开发者ID:jimbobhickville,项目名称:taskflow,代码行数:21,代码来源:helpers.py

示例10: fetch

def fetch(conf, namespace=BACKEND_NAMESPACE, **kwargs):
    """Fetches a given backend using the given configuration (and any backend
    specific kwargs) in the given entrypoint namespace.
    """
    backend_name = conf['connection']
    try:
        pieces = misc.parse_uri(backend_name)
    except (TypeError, ValueError):
        pass
    else:
        backend_name = pieces['scheme']
        conf = misc.merge_uri(pieces, conf.copy())
    LOG.debug('Looking for %r backend driver in %r', backend_name, namespace)
    try:
        mgr = driver.DriverManager(namespace, backend_name,
                                   invoke_on_load=True,
                                   invoke_args=(conf,),
                                   invoke_kwds=kwargs)
        return mgr.driver
    except RuntimeError as e:
        raise exc.NotFound("Could not find backend %s: %s" % (backend_name, e))
开发者ID:ziziwu,项目名称:openstack,代码行数:21,代码来源:__init__.py

示例11: fetch

def fetch(name, conf, namespace=BACKEND_NAMESPACE, **kwargs):
    """Fetch a jobboard backend with the given configuration.

    This fetch method will look for the entrypoint name in the entrypoint
    namespace, and then attempt to instantiate that entrypoint using the
    provided name, configuration and any board specific kwargs.

    NOTE(harlowja): to aid in making it easy to specify configuration and
    options to a board the configuration (which is typical just a dictionary)
    can also be a URI string that identifies the entrypoint name and any
    configuration specific to that board.

    For example, given the following configuration URI::

        zookeeper://<not-used>/?a=b&c=d

    This will look for the entrypoint named 'zookeeper' and will provide
    a configuration object composed of the URI's components, in this case that
    is ``{'a': 'b', 'c': 'd'}`` to the constructor of that board
    instance (also including the name specified).
    """
    if isinstance(conf, six.string_types):
        conf = {'board': conf}
    board = conf['board']
    try:
        uri = misc.parse_uri(board)
    except (TypeError, ValueError):
        pass
    else:
        board = uri.scheme
        conf = misc.merge_uri(uri, conf.copy())
    LOG.debug('Looking for %r jobboard driver in %r', board, namespace)
    try:
        mgr = driver.DriverManager(namespace, board,
                                   invoke_on_load=True,
                                   invoke_args=(name, conf),
                                   invoke_kwds=kwargs)
        return mgr.driver
    except RuntimeError as e:
        raise exc.NotFound("Could not find jobboard %s" % (board), e)
开发者ID:junneyang,项目名称:taskflow,代码行数:40,代码来源:__init__.py

示例12: fetch

def fetch(conf, namespace=BACKEND_NAMESPACE, **kwargs):
    """Fetch a persistence backend with the given configuration.

    This fetch method will look for the entrypoint name in the entrypoint
    namespace, and then attempt to instantiate that entrypoint using the
    provided configuration and any persistence backend specific kwargs.

    NOTE(harlowja): to aid in making it easy to specify configuration and
    options to a backend the configuration (which is typical just a dictionary)
    can also be a uri string that identifies the entrypoint name and any
    configuration specific to that backend.

    For example, given the following configuration uri:

    mysql://<not-used>/?a=b&c=d

    This will look for the entrypoint named 'mysql' and will provide
    a configuration object composed of the uris parameters, in this case that
    is {'a': 'b', 'c': 'd'} to the constructor of that persistence backend
    instance.
    """
    backend_name = conf['connection']
    try:
        uri = misc.parse_uri(backend_name)
    except (TypeError, ValueError):
        pass
    else:
        backend_name = uri.scheme
        conf = misc.merge_uri(uri, conf.copy())
    LOG.debug('Looking for %r backend driver in %r', backend_name, namespace)
    try:
        mgr = driver.DriverManager(namespace, backend_name,
                                   invoke_on_load=True,
                                   invoke_args=(conf,),
                                   invoke_kwds=kwargs)
        return mgr.driver
    except RuntimeError as e:
        raise exc.NotFound("Could not find backend %s: %s" % (backend_name, e))
开发者ID:TheSriram,项目名称:taskflow,代码行数:38,代码来源:__init__.py

示例13: fetch

def fetch(name, conf, namespace=BACKEND_NAMESPACE, **kwargs):
    """Fetch a jobboard backend with the given configuration (and any board
    specific kwargs) in the given entrypoint namespace and create it with the
    given name.
    """
    if isinstance(conf, six.string_types):
        conf = {'board': conf}
    board = conf['board']
    try:
        pieces = misc.parse_uri(board)
    except (TypeError, ValueError):
        pass
    else:
        board = pieces['scheme']
        conf = misc.merge_uri(pieces, conf.copy())
    LOG.debug('Looking for %r jobboard driver in %r', board, namespace)
    try:
        mgr = driver.DriverManager(namespace, board,
                                   invoke_on_load=True,
                                   invoke_args=(name, conf),
                                   invoke_kwds=kwargs)
        return mgr.driver
    except RuntimeError as e:
        raise exc.NotFound("Could not find jobboard %s" % (board), e)
开发者ID:ziziwu,项目名称:openstack,代码行数:24,代码来源:__init__.py

示例14: test_ipv6_host

 def test_ipv6_host(self):
     url = "rsync://[2001:db8:0:1]:873"
     parsed = misc.parse_uri(url)
     self.assertEqual('rsync', parsed.scheme)
     self.assertEqual('2001:db8:0:1', parsed.hostname)
     self.assertEqual(873, parsed.port)
开发者ID:codybum,项目名称:OpenStackInAction,代码行数:6,代码来源:test_utils.py

示例15: test_multi_params

 def test_multi_params(self):
     url = "mysql://www.yahoo.com:3306/a/b/?c=d&c=e"
     parsed = misc.parse_uri(url, query_duplicates=True)
     self.assertEqual({'c': ['d', 'e']}, parsed.params)
开发者ID:codybum,项目名称:OpenStackInAction,代码行数:4,代码来源:test_utils.py


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