File manager - Edit - /usr/local/CyberCP/lib/python3.10/site-packages/tornado/__pycache__/options.cpython-310.pyc
Back
o �h�f � @ s� d Z ddlZddlZddlZddlZddlZddlZddlmZm Z ddl mZ ddlm Z mZ ddlmZmZmZmZmZmZmZmZmZmZ G dd� de�ZG d d � d e�ZG dd� de�ZG d d� de�Ze� Z d(de!dedee" dee! dee! de#dee! deeegdf ddfdd�Z$ d)deee! de#dee! fdd�Z%d*d e!de#ddfd!d"�Z&d+d#ee ddfd$d%�Z'deg df ddfd&d'�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 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 @ s e Zd ZdZdS )�Errorz1Exception raised by errors in the options module.N)�__name__� __module__�__qualname__�__doc__� r r �B/usr/local/CyberCP/lib/python3.10/site-packages/tornado/options.pyr s r c @ s� e Zd ZdZd<dd�Zdedefdd�Zdedefd d �Zdededdfdd �Z de fdd�Zdedefdd�Z dedefdd�Zdededdfdd�Zdeeeef fdd�Zdee fdd�Zdedeeef fdd�Zdeeef fdd�Z d=ded ed!ee d"ee d#ee d$edee d%eeegdf ddfd&d'�Z (d>d)eee d*edee fd+d,�Zd?d-ed*eddfd.d/�Zd@d0ee ddfd1d2�Z deddfd3d4�Z!d%eg df ddfd5d6�Z"d<d7d8�Z#dAd:d;�Z$dS )B�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 C s, i | j d<