File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/ext/tornado/__pycache__/options.cpython-310.pyc
Back
o ;j�S � @ s d Z ddlmZmZmZ ddlZddlZddlZddlZddl Z ddl Z ddlmZm Z ddlmZ ddlmZ ddlmZmZ G dd � d e�ZG d d� de�ZG dd � d e�ZG dd� de�Ze� Z ddd�Zddd�Zddd�Zddd�Zdd� Z ee� dS ) aT A command line parsing module that lets modules define their own options. Each module defines its own options which are added to the global option namespace, e.g.:: from salt.ext.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) ... 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:: tornado.options.parse_command_line() # or tornado.options.parse_config_file("/etc/server.conf") .. note: When using tornado.options.parse_command_line or tornado.options.parse_config_file, the only options that are set are ones that were previously defined with tornado.options.define. Command line formats are what you would expect (``--myoption=myvalue``). Config files are just Python files. Global names become options, e.g.:: myoption = "myvalue" myotheroption = "myothervalue" We support `datetimes <datetime.datetime>`, `timedeltas <datetime.timedelta>`, ints, and floats (just pass a ``type`` kwarg to `define`). We also accept multi-value options. See the documentation for `define()` below. `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 salt.ext.tornado.options import options, parse_command_line options.logging = None parse_command_line() .. 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. � )�absolute_import�division�print_functionN)�_unicode� native_str)�define_logging_options)� stack_context)�basestring_type�exec_inc @ s e Zd ZdZdS )�Errorz1Exception raised by errors in the options module.N)�__name__� __module__�__qualname__�__doc__� r r �L/opt/saltstack/salt/lib/python3.10/site-packages/salt/ext/tornado/options.pyr e s r c @ s� e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z dd� Zdd� Zdd� Z dd� Zdd� Z d-dd�Zd.dd �Zd/d!d"�Zd0d#d$�Zd%d&� Zd'd(� Zd)d*� Zd+d,� ZdS )1�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. c C s, i | j d<