| Server IP : 54.37.205.81 / Your IP : 216.73.216.76 Web Server : nginx/1.22.1 System : Linux vps-249481fa 6.1.0-50-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.176-1 (2026-07-02) x86_64 User : debian ( 1000) PHP Version : 8.2.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/tornado/__pycache__/ |
Upload File : |
�
��b[f � �L � d Z ddlZddlZddlZddlZddlZddlZddlmZm Z ddl
mZ ddlm
Z
mZ ddlmZmZmZmZmZmZmZmZmZmZ G d� de� � Z G d � d
e� � Z G d� de� � Z G d
� de� � Z e� � Z d#de!dedee" dee! dee! de#dee! deeegdf ddfd�Z$ d$deee! de#dee! fd�Z%d%de!de#ddfd�Z&d&d ee ddfd!�Z'deg df ddfd"�Z( ee � � dS )'a� A command line parsing module that lets modules define their own options.
This module is inspired by Google's `gflags
<https://github.com/google/python-gflags>`_. The primary difference
with libraries such as `argparse` is that a global registry is used so
that options may be defined in any module (it also enables
`tornado.log` by default). The rest of Tornado does not depend on this
module, so feel free to use `argparse` or other configuration
libraries if you prefer them.
Options must be defined with `tornado.options.define` before use,
generally at the top level of a module. The options are then
accessible as attributes of `tornado.options.options`::
# myapp/db.py
from tornado.options import define, options
define("mysql_host", default="127.0.0.1:3306", help="Main user DB")
define("memcache_hosts", default="127.0.0.1:11011", multiple=True,
help="Main user memcache servers")
def connect():
db = database.Connection(options.mysql_host)
...
# myapp/server.py
from tornado.options import define, options
define("port", default=8080, help="port to listen on")
def start_server():
app = make_app()
app.listen(options.port)
The ``main()`` method of your application does not need to be aware of all of
the options used throughout your program; they are all automatically loaded
when the modules are loaded. However, all modules that define options
must have been imported before the command line is parsed.
Your ``main()`` method can parse the command line or parse a config file with
either `parse_command_line` or `parse_config_file`::
import myapp.db, myapp.server
import tornado.options
if __name__ == '__main__':
tornado.options.parse_command_line()
# or
tornado.options.parse_config_file("/etc/server.conf")
.. note::
When using multiple ``parse_*`` functions, pass ``final=False`` to all
but the last one, or side effects may occur twice (in particular,
this can result in log messages being doubled).
`tornado.options.options` is a singleton instance of `OptionParser`, and
the top-level functions in this module (`define`, `parse_command_line`, etc)
simply call methods on it. You may create additional `OptionParser`
instances to define isolated sets of options, such as for subcommands.
.. note::
By default, several options are defined that will configure the
standard `logging` module when `parse_command_line` or `parse_config_file`
are called. If you want Tornado to leave the logging configuration
alone so you can manage it yourself, either pass ``--logging=none``
on the command line or do the following to disable it in code::
from tornado.options import options, parse_command_line
options.logging = None
parse_command_line()
.. note::
`parse_command_line` or `parse_config_file` function should called after
logging configuration and user-defined command line flags using the
``callback`` option definition, or these configurations will not take effect.
.. versionchanged:: 4.3
Dashes and underscores are fully interchangeable in option names;
options can be defined, set, and read with any mix of the two.
Dashes are typical for command-line usage while config files require
underscores.
� N)�_unicode�
native_str)�define_logging_options)�basestring_type�exec_in)
�Any�Iterator�Iterable�Tuple�Set�Dict�Callable�List�TextIO�Optionalc � � e Zd ZdZdS )�Errorz1Exception raised by errors in the options module.N)�__name__�
__module__�__qualname__�__doc__� � �1/usr/lib/python3/dist-packages/tornado/options.pyr r s � � � � � �;�;��Dr r c �D � e Zd ZdZd(d�Zdedefd�Zdedefd�Zdededdfd �Z de
fd
�Zdedefd�Z
dedefd�Zdededdfd
�Zdeeeef fd�Zdee fd�Zdedeeef fd�Zdeeef fd�Z d)dededee dee dee dedee deeegdf ddfd�Z d*deee dedee fd�Zd+dededdfd �Zd,d!ee ddfd"�Z deddfd#�Z!deg df ddfd$�Z"d(d%�Z#d-d'�Z$dS ).�OptionParserz�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.
�returnNc �t � i | j d<