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


Python options.name方法代码示例

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


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

示例1: group_dict

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def group_dict(self, group):
        """The names and values of options in a group.

        Useful for copying options into Application settings::

            from tornado.options import define, parse_command_line, options

            define('template_path', group='application')
            define('static_path', group='application')

            parse_command_line()

            application = Application(
                handlers, **options.group_dict('application'))

        .. versionadded:: 3.1
        """
        return dict(
            (opt.name, opt.value()) for name, opt in self._options.items()
            if not group or group == opt.group_name) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:22,代码来源:options.py

示例2: parse_config_file

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def parse_config_file(self, path, final=True):
        """Parses and loads the Python config file at the given path.

        If ``final`` is ``False``, parse callbacks will not be run.
        This is useful for applications that wish to combine configurations
        from multiple sources.

        .. versionchanged:: 4.1
           Config files are now always interpreted as utf-8 instead of
           the system default encoding.
        """
        config = {}
        with open(path, 'rb') as f:
            exec_in(native_str(f.read()), config, config)
        for name in config:
            normalized = self._normalize_name(name)
            if normalized in self._options:
                self._options[normalized].set(config[name])

        if final:
            self.run_parse_callbacks() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:23,代码来源:options.py

示例3: mockable

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def mockable(self):
        """Returns a wrapper around self that is compatible with
        `mock.patch <unittest.mock.patch>`.

        The `mock.patch <unittest.mock.patch>` function (included in
        the standard library `unittest.mock` package since Python 3.3,
        or in the third-party ``mock`` package for older versions of
        Python) is incompatible with objects like ``options`` that
        override ``__getattr__`` and ``__setattr__``.  This function
        returns an object that can be used with `mock.patch.object
        <unittest.mock.patch.object>` to modify option values::

            with mock.patch.object(options.mockable(), 'name', value):
                assert options.name == value
        """
        return _Mockable(self) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:18,代码来源:options.py

示例4: run_tests

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def run_tests():
    url = options.url + '/getCaseCount'
    control_ws = yield websocket_connect(url, None)
    num_tests = int((yield control_ws.read_message()))
    logging.info('running %d cases', num_tests)
    msg = yield control_ws.read_message()
    assert msg is None

    for i in range(1, num_tests + 1):
        logging.info('running test case %d', i)
        url = options.url + '/runCase?case=%d&agent=%s' % (i, options.name)
        test_ws = yield websocket_connect(url, None, compression_options={})
        while True:
            message = yield test_ws.read_message()
            if message is None:
                break
            test_ws.write_message(message, binary=isinstance(message, bytes))

    url = options.url + '/updateReports?agent=%s' % options.name
    update_ws = yield websocket_connect(url, None)
    msg = yield update_ws.read_message()
    assert msg is None
    IOLoop.instance().stop() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:25,代码来源:client.py

示例5: set

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def set(self, value):
        if self.multiple:
            if not isinstance(value, list):
                raise Error("Option %r is required to be a list of %s" %
                            (self.name, self.type.__name__))
            for item in value:
                if item is not None and not isinstance(item, self.type):
                    raise Error("Option %r is required to be a list of %s" %
                                (self.name, self.type.__name__))
        else:
            if value is not None and not isinstance(value, self.type):
                raise Error("Option %r is required to be a %s (%s given)" %
                            (self.name, self.type.__name__, type(value)))
        self._value = value
        if self.callback is not None:
            self.callback(self._value)

    # Supported date/time formats in our options 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:20,代码来源:options.py

示例6: group_dict

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def group_dict(self, group: str) -> Dict[str, Any]:
        """The names and values of options in a group.

        Useful for copying options into Application settings::

            from tornado.options import define, parse_command_line, options

            define('template_path', group='application')
            define('static_path', group='application')

            parse_command_line()

            application = Application(
                handlers, **options.group_dict('application'))

        .. versionadded:: 3.1
        """
        return dict(
            (opt.name, opt.value())
            for name, opt in self._options.items()
            if not group or group == opt.group_name
        ) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:24,代码来源:options.py

示例7: mockable

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def mockable(self) -> "_Mockable":
        """Returns a wrapper around self that is compatible with
        `mock.patch <unittest.mock.patch>`.

        The `mock.patch <unittest.mock.patch>` function (included in
        the standard library `unittest.mock` package since Python 3.3,
        or in the third-party ``mock`` package for older versions of
        Python) is incompatible with objects like ``options`` that
        override ``__getattr__`` and ``__setattr__``.  This function
        returns an object that can be used with `mock.patch.object
        <unittest.mock.patch.object>` to modify option values::

            with mock.patch.object(options.mockable(), 'name', value):
                assert options.name == value
        """
        return _Mockable(self) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:18,代码来源:options.py

示例8: define

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def define(
    name: str,
    default: Any = None,
    type: type = None,
    help: str = None,
    metavar: str = None,
    multiple: bool = False,
    group: str = None,
    callback: Callable[[Any], None] = None,
) -> None:
    """Defines an option in the global namespace.

    See `OptionParser.define`.
    """
    return options.define(
        name,
        default=default,
        type=type,
        help=help,
        metavar=metavar,
        multiple=multiple,
        group=group,
        callback=callback,
    ) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:26,代码来源:options.py

示例9: group_dict

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def group_dict(self, group):
        """The names and values of options in a group.

        Useful for copying options into Application settings::

            from tornado.options import define, parse_command_line, options

            define('template_path', group='application')
            define('static_path', group='application')

            parse_command_line()

            application = Application(
                handlers, **options.group_dict('application'))

        .. versionadded:: 3.1
        """
        return dict(
            (name, opt.value()) for name, opt in self._options.items()
            if not group or group == opt.group_name) 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:22,代码来源:options.py

示例10: parse_config_file

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def parse_config_file(self, path, final=True):
        """Parses and loads the Python config file at the given path.

        If ``final`` is ``False``, parse callbacks will not be run.
        This is useful for applications that wish to combine configurations
        from multiple sources.
        """
        config = {}
        with open(path) as f:
            exec_in(f.read(), config, config)
        for name in config:
            if name in self._options:
                self._options[name].set(config[name])

        if final:
            self.run_parse_callbacks() 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:18,代码来源:options.py

示例11: _normalize_name

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def _normalize_name(self, name):
        return name.replace('_', '-') 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:4,代码来源:options.py

示例12: __getattr__

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def __getattr__(self, name):
        name = self._normalize_name(name)
        if isinstance(self._options.get(name), _Option):
            return self._options[name].value()
        raise AttributeError("Unrecognized option %r" % name) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:7,代码来源:options.py

示例13: __setattr__

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def __setattr__(self, name, value):
        name = self._normalize_name(name)
        if isinstance(self._options.get(name), _Option):
            return self._options[name].set(value)
        raise AttributeError("Unrecognized option %r" % name) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:7,代码来源:options.py

示例14: __iter__

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def __iter__(self):
        return (opt.name for opt in self._options.values()) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:4,代码来源:options.py

示例15: __contains__

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import name [as 别名]
def __contains__(self, name):
        name = self._normalize_name(name)
        return name in self._options 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:5,代码来源:options.py


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