當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。