Public Member Functions | Private Member Functions
tornado.options.OptionParser Class Reference

List of all members.

Public Member Functions

def __getattr__
def __getitem__
def __init__
def __iter__
def __setattr__
def add_parse_callback
def as_dict
def define
def group_dict
def groups
def items
def mockable
def parse_command_line
def parse_config_file
def print_help
def run_parse_callbacks

Private Member Functions

def _help_callback

Detailed Description

A collection of options, a dictionary with object-like access.

Normally accessed via static functions in the `tornado.options` module,
which reference a global instance.

Definition at line 93 of file options.py.


Constructor & Destructor Documentation

Definition at line 99 of file options.py.


Member Function Documentation

def tornado.options.OptionParser.__getattr__ (   self,
  name 
)

Definition at line 106 of file options.py.

def tornado.options.OptionParser.__getitem__ (   self,
  item 
)

Definition at line 119 of file options.py.

Definition at line 116 of file options.py.

def tornado.options.OptionParser.__setattr__ (   self,
  name,
  value 
)

Definition at line 111 of file options.py.

def tornado.options.OptionParser._help_callback (   self,
  value 
) [private]

Definition at line 314 of file options.py.

def tornado.options.OptionParser.add_parse_callback (   self,
  callback 
)
Adds a parse callback, to be invoked when option parsing is done.

Definition at line 319 of file options.py.

The names and values of all options.

.. versionadded:: 3.1

Definition at line 157 of file options.py.

def tornado.options.OptionParser.define (   self,
  name,
  default = None,
  type = None,
  help = None,
  metavar = None,
  multiple = False,
  group = None,
  callback = None 
)
Defines a new command line option.

If ``type`` is given (one of str, float, int, datetime, or timedelta)
or can be inferred from the ``default``, we parse the command line
arguments based on the given type. If ``multiple`` is True, we accept
comma-separated values, and the option value is always a list.

For multi-value integers, we also accept the syntax ``x:y``, which
turns into ``range(x, y)`` - very useful for long integer ranges.

``help`` and ``metavar`` are used to construct the
automatically generated command line help string. The help
message is formatted like::

   --name=METAVAR      help string

``group`` is used to group the defined options in logical
groups. By default, command line options are grouped by the
file in which they are defined.

Command line option names must be unique globally. They can be parsed
from the command line with `parse_command_line` or parsed from a
config file with `parse_config_file`.

If a ``callback`` is given, it will be run with the new value whenever
the option is changed.  This can be used to combine command-line
and file-based options::

    define("config", type=str, help="path to config file",
   callback=lambda path: parse_config_file(path, final=False))

With this definition, options in the file specified by ``--config`` will
override options set earlier on the command line, but can be overridden
by later flags.

Definition at line 165 of file options.py.

def tornado.options.OptionParser.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

Definition at line 136 of file options.py.

The set of option-groups created by ``define``.

.. versionadded:: 3.1

Definition at line 129 of file options.py.

A sequence of (name, value) pairs.

.. versionadded:: 3.1

Definition at line 122 of file options.py.

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

Definition at line 327 of file options.py.

def tornado.options.OptionParser.parse_command_line (   self,
  args = None,
  final = True 
)
Parses all options given on the command line (defaults to
`sys.argv`).

Note that ``args[0]`` is ignored since it is the program name
in `sys.argv`.

We return a list of all arguments that are not parsed as options.

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

Definition at line 225 of file options.py.

def tornado.options.OptionParser.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.

Definition at line 268 of file options.py.

def tornado.options.OptionParser.print_help (   self,
  file = None 
)
Prints all the command line options to stderr (or another file).

Definition at line 285 of file options.py.

Definition at line 323 of file options.py.


The documentation for this class was generated from the following file:


rosbridge_server
Author(s): Jonathan Mace
autogenerated on Thu Jun 6 2019 21:51:51