/usr/lib/python2.6/site-packages/oslo_config
NameSizeModeActions
tests/-0755rm
cfg.py925640644editdlrm
cfg.pyc1015810644editdlrm
cfgfilter.py131730644editdlrm
cfgfilter.pyc148280644editdlrm
fixture.py77740644editdlrm
fixture.pyc78200644editdlrm
generator.py94890644editdlrm
generator.pyc94660644editdlrm
iniparser.py42070644editdlrm
iniparser.pyc48450644editdlrm
sphinxconfiggen.py23250644editdlrm
sphinxconfiggen.pyc19270644editdlrm
sphinxext.py52990644editdlrm
sphinxext.pyc59560644editdlrm
types.py125930644editdlrm
types.pyc149540644editdlrm
version.py6590644editdlrm
version.pyc2650644editdlrm
_list_opts.py8760644editdlrm
_list_opts.pyc5830644editdlrm
__init__.py00644editdlrm
__init__.pyc1440644editdlrm
Edit: /usr/lib/python2.6/site-packages/oslo_config/cfg.pyc (101581B)
yDVc@sKdZddkZddkZddkZddkZddkZddkZddkZddkZddk Z ddk Z ddk Z ddk Z ddk l Z ddklZddklZeieZdefdYZdefd YZd efd YZd eefd YZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZ defdYZ!defdYZ"d Z#e$d!Z%d"d#Z&e$e$d$d%Z'd&Z(d'Z)d(Z*d)e+fd*YZ,e i-oei.e,Z,nd+e+fd,YZ/d-e,fd.YZ0d/e,fd0YZ1d1e,fd2YZ2d3e,fd4YZ3d5e,fd6YZ4d7e,fd8YZ5d9e,fd:YZ6d;e,fd<YZ7d=e7fd>YZ8d?e,fd@YZ9dAe,fdBYZ:dCe,fdDYZ;dEe+fdFYZ<dGei=fdHYZ=dIei>fdJYZ?dKe+fdLYZ@dMeiAfdNYZBdOeiCfdPYZDdQeiEfdRYZFeFZGdS(Sso" Configuration options may be set on the command line or in config files. The schema for each option is defined using the :class:`Opt` class or its sub-classes, for example: :: from oslo_config import cfg from oslo_config import types PortType = types.Integer(1, 65535) common_opts = [ cfg.StrOpt('bind_host', default='0.0.0.0', help='IP address to listen on.'), cfg.Opt('bind_port', type=PortType, default=9292, help='Port number to listen on.') ] Option Types ------------ Options can have arbitrary types via the ``type`` constructor to ``Opt``. The type constructor is a callable object that takes a string and either returns a value of that particular type or raises ValueError if the value can not be converted. There are predefined types in :class:`oslo_config.cfg` : strings, integers, floats, booleans, lists, 'multi strings' and 'key/value pairs' (dictionary) :: enabled_apis_opt = cfg.ListOpt('enabled_apis', default=['ec2', 'osapi_compute'], help='List of APIs to enable by default.') DEFAULT_EXTENSIONS = [ 'nova.api.openstack.compute.contrib.standard_extensions' ] osapi_compute_extension_opt = cfg.MultiStrOpt('osapi_compute_extension', default=DEFAULT_EXTENSIONS) Registering Options ------------------- Option schemas are registered with the config manager at runtime, but before the option is referenced:: class ExtensionManager(object): enabled_apis_opt = cfg.ListOpt(...) def __init__(self, conf): self.conf = conf self.conf.register_opt(enabled_apis_opt) ... def _load_extensions(self): for ext_factory in self.conf.osapi_compute_extension: .... A common usage pattern is for each option schema to be defined in the module or class which uses the option:: opts = ... def add_common_opts(conf): conf.register_opts(opts) def get_bind_host(conf): return conf.bind_host def get_bind_port(conf): return conf.bind_port An option may optionally be made available via the command line. Such options must be registered with the config manager before the command line is parsed (for the purposes of --help and CLI arg validation):: cli_opts = [ cfg.BoolOpt('verbose', short='v', default=False, help='Print more verbose output.'), cfg.BoolOpt('debug', short='d', default=False, help='Print debugging output.'), ] def add_common_opts(conf): conf.register_cli_opts(cli_opts) Loading Config Files -------------------- The config manager has two CLI options defined by default, --config-file and --config-dir:: class ConfigOpts(object): def __call__(self, ...): opts = [ MultiStrOpt('config-file', ...), StrOpt('config-dir', ...), ] self.register_cli_opts(opts) Option values are parsed from any supplied config files using oslo_config.iniparser. If none are specified, a default set is used for example glance-api.conf and glance-common.conf:: glance-api.conf: [DEFAULT] bind_port = 9292 glance-common.conf: [DEFAULT] bind_host = 0.0.0.0 Option values in config files and those on the command line are parsed in order. The same option can appear many times, in config files or on the command line. Later values always override earlier ones. The order of configuration files inside the same configuration directory is defined by the alphabetic sorting order of their file names. The parsing of CLI args and config files is initiated by invoking the config manager for example:: conf = ConfigOpts() conf.register_opt(BoolOpt('verbose', ...)) conf(sys.argv[1:]) if conf.verbose: ... Option Groups ------------- Options can be registered as belonging to a group:: rabbit_group = cfg.OptGroup(name='rabbit', title='RabbitMQ options') rabbit_host_opt = cfg.StrOpt('host', default='localhost', help='IP/hostname to listen on.'), rabbit_port_opt = cfg.IntOpt('port', default=5672, help='Port number to listen on.') def register_rabbit_opts(conf): conf.register_group(rabbit_group) # options can be registered under a group in either of these ways: conf.register_opt(rabbit_host_opt, group=rabbit_group) conf.register_opt(rabbit_port_opt, group='rabbit') If no group attributes are required other than the group name, the group need not be explicitly registered for example:: def register_rabbit_opts(conf): # The group will automatically be created, equivalent calling:: # conf.register_group(OptGroup(name='rabbit')) conf.register_opt(rabbit_port_opt, group='rabbit') If no group is specified, options belong to the 'DEFAULT' section of config files:: glance-api.conf: [DEFAULT] bind_port = 9292 ... [rabbit] host = localhost port = 5672 use_ssl = False userid = guest password = guest virtual_host = / Command-line options in a group are automatically prefixed with the group name:: --rabbit-host localhost --rabbit-port 9999 Accessing Option Values In Your Code ------------------------------------ Option values in the default group are referenced as attributes/properties on the config manager; groups are also attributes on the config manager, with attributes for each of the options associated with the group:: server.start(app, conf.bind_port, conf.bind_host, conf) self.connection = kombu.connection.BrokerConnection( hostname=conf.rabbit.host, port=conf.rabbit.port, ...) Option Value Interpolation -------------------------- Option values may reference other values using PEP 292 string substitution:: opts = [ cfg.StrOpt('state_path', default=os.path.join(os.path.dirname(__file__), '../'), help='Top-level directory for maintaining nova state.'), cfg.StrOpt('sqlite_db', default='nova.sqlite', help='File name for SQLite.'), cfg.StrOpt('sql_connection', default='sqlite:///$state_path/$sqlite_db', help='Connection string for SQL database.'), ] .. note:: Interpolation can be avoided by using `$$`. .. note:: You can use `.` to delimit option from other groups, e.g. ${mygroup.myoption}. Special Handling Instructions ----------------------------- Options may be declared as required so that an error is raised if the user does not supply a value for the option:: opts = [ cfg.StrOpt('service_name', required=True), cfg.StrOpt('image_id', required=True), ... ] Options may be declared as secret so that their values are not leaked into log files:: opts = [ cfg.StrOpt('s3_store_access_key', secret=True), cfg.StrOpt('s3_store_secret_key', secret=True), ... ] Global ConfigOpts ----------------- This module also contains a global instance of the ConfigOpts class in order to support a common usage pattern in OpenStack:: from oslo_config import cfg opts = [ cfg.StrOpt('bind_host', default='0.0.0.0'), cfg.IntOpt('bind_port', default=9292), ] CONF = cfg.CONF CONF.register_opts(opts) def start(server, app): server.start(app, CONF.bind_port, CONF.bind_host) Positional Command Line Arguments --------------------------------- Positional command line arguments are supported via a 'positional' Opt constructor argument:: >>> conf = ConfigOpts() >>> conf.register_cli_opt(MultiStrOpt('bar', positional=True)) True >>> conf(['a', 'b']) >>> conf.bar ['a', 'b'] Sub-Parsers ----------- It is also possible to use argparse "sub-parsers" to parse additional command line arguments using the SubCommandOpt class: >>> def add_parsers(subparsers): ... list_action = subparsers.add_parser('list') ... list_action.add_argument('id') ... >>> conf = ConfigOpts() >>> conf.register_cli_opt(SubCommandOpt('action', handler=add_parsers)) True >>> conf(args=['list', '10']) >>> conf.action.name, conf.action.id ('list', '10') iN(tmoves(t iniparser(ttypestErrorcBs#eZdZddZdZRS(sBase class for cfg exceptions.cCs ||_dS(N(tmsg(tselfR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt__init__XscCs|iS(N(R(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt__str__[sN(t__name__t __module__t__doc__tNoneRR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRUs tNotInitializedErrorcBseZdZdZRS(s(Raised if parser is not initialized yet.cCsdS(Ns.call expression on parser has not been invoked((R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRbs(RR R R(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR _stArgsAlreadyParsedErrorcBseZdZdZRS(s0Raised if a CLI opt is registered after parsing.cCs)d}|io|d|i7}n|S(Nsarguments already parseds: (R(Rtret((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRis (RR R R(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR fstNoSuchOptErrorcBs#eZdZddZdZRS(s3Raised if an opt which doesn't exist is referenced.cCs||_||_dS(N(topt_nametgroup(RRR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRss cCs7|idjo d|iSd|ii|ifSdS(Nsno such option: %ssno such option in group %s: %s(RR Rtname(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRws  N(RR R R RR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRps tNoSuchGroupErrorcBs eZdZdZdZRS(s4Raised if a group which doesn't exist is referenced.cCs ||_dS(N(t group_name(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRscCs d|iS(Nsno such group: %s(R(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs(RR R RR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs tDuplicateOptErrorcBs eZdZdZdZRS(s:Raised if multiple opts with the same name are registered.cCs ||_dS(N(R(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRscCs d|iS(Nsduplicate option: %s(R(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs(RR R RR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs tRequiredOptErrorcBs#eZdZddZdZRS(sERaised if an option is required but no value is supplied by the user.cCs||_||_dS(N(RR(RRR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs cCs7|idjo d|iSd|ii|ifSdS(Nsvalue required for option: %ss value required for option: %s.%s(RR RR(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs  N(RR R R RR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs tTemplateSubstitutionErrorcBseZdZdZRS(sBRaised if an error occurs substituting a variable in an opt value.cCs d|iS(Nstemplate substitution error: %s(R(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs(RR R R(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRstConfigFilesNotFoundErrorcBs eZdZdZdZRS(s1Raised if one or more config files are not found.cCs ||_dS(N(t config_files(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRscCsddi|iS(Ns$Failed to find some config files: %st,(tjoinR(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs(RR R RR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs t ConfigFilesPermissionDeniedErrorcBs eZdZdZdZRS(s4Raised if one or more config files are not readable.cCs ||_dS(N(R(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRscCsddi|iS(Ns$Failed to open some config files: %sR(RR(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs(RR R RR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs tConfigDirNotFoundErrorcBs eZdZdZdZRS(s0Raised if the requested config-dir is not found.cCs ||_dS(N(t config_dir(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRscCs d|iS(Ns(Failed to read config file directory: %s(R(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs(RR R RR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs tConfigFileParseErrorcBs eZdZdZdZRS(s2Raised if there is an error parsing a config file.cCs||_||_dS(N(t config_fileR(RR R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs cCsd|i|ifS(NsFailed to parse %s: %s(R R(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs(RR R RR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs tConfigFileValueErrorcBseZdZRS(s:Raised if a config file value does not match its opt type.(RR R (((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR!scCstiitii|S(s3Apply tilde expansion and absolutization to a path.(tostpathtabspatht expanduser(tp((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt_fixpathscCsr|o ttiidd|ndtd|otiid|nddg}ttit|S(s3Return a list of directories where config files may be located. :param project: an optional project name If a project is specified, following directories are returned:: ~/.${project}/ ~/ /etc/${project}/ /etc/ Otherwise, these directories:: ~/ /etc/ t~t.s/etcN( R'R"R#RR tlistRtfiltertbool(tprojecttcfg_dirs((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt_get_config_dirss *   tcCsLxE|D]=}tii|d||f}tii|o|SqWdS(sSearch a list of directories for a given filename. Iterator over the supplied directories, returning the first file found with the supplied name and extension. :param dirs: a list of directories :param basename: the filename, for example 'glance-api' :param extension: the file extension, for example '.conf' :returns: the path to a matching file, or None s%s%sN(R"R#Rtexists(tdirstbasenamet extensiontdR#((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt _search_dirss s.confcCs|djotiitid}nt|}g}|o|it|||n|it|||t t i t |S(s Return a list of default configuration files. :param project: an optional project name :param prog: the program name, defaulting to the basename of sys.argv[0] :param extension: the type of the config file We default to two config files: [${project}.conf, ${prog}.conf] And we look for those config files in the following directories:: ~/.${project}/ ~/ /etc/${project}/ /etc/ We return an absolute path for (at most) one of each the default config files, for the topmost directory it exists in. For example, if project=foo, prog=bar and /etc/foo/foo.conf, /etc/bar.conf and ~/.foo/bar.conf all exist, then we return ['/etc/foo/foo.conf', '~/.foo/bar.conf'] If no project name is supplied, we only look for ${prog.conf}. iN( R R"R#R3tsystargvR/tappendR6R*RR+R,(R-tprogR4R.R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pytfind_config_files s  cCsH|i|jo0||id|jot|intStSdS(sCheck whether an opt with the same name is already registered. The same opt may be registered multiple times, with only the first registration having any effect. However, it is an error to attempt to register a different opt with the same name. :param opts: the set of opts already registered :param opt: the opt to be registered :returns: True if the opt was previously registered, False otherwise :raises: DuplicateOptError if a naming conflict is detected toptN(tdestRRtTruetFalse(toptsR<((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt_is_opt_registered0s cKs9x2|D]*}|i|jo||i|_qqWdS(N(R=tdefault(R@tkwargsR<((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt set_defaultsDscCs|djo|S|iS(NtDEFAULT(tlower(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt_normalize_group_nameJs tOptcBseZdZeZddddeddeeddddedZdZdZdZ dZ e i Z dZ ddZdedd Zd Zd Zd Zdd ZdZRS(sBase class for all configuration options. The only required parameter is the option's name. However, it is common to also supply a default and help string for all options. :param name: the option's name :param type: the option's type. Must be a callable object that takes string and returns converted and validated value :param dest: the name of the corresponding ConfigOpts property :param short: a single character CLI option name :param default: the default value of the option :param positional: True if the option is a positional CLI argument :param metavar: the option argument to show in --help :param help: an explanation of how the option is used :param secret: true if the value should be obfuscated in log output :param required: true if a value must be supplied for this option :param deprecated_name: deprecated name option. Acts like an alias :param deprecated_group: the group containing a deprecated alias :param deprecated_opts: array of DeprecatedOpt(s) :param sample_default: a default string for sample config files :param deprecated_for_removal: indicates whether this opt is planned for removal in a future release An Opt object has no public methods, but has a number of public properties: .. py:attribute:: name the name of the option, which may include hyphens .. py:attribute:: type a callable object that takes string and returns converted and validated value. Default types are available from :class:`oslo_config.types` .. py:attribute:: dest the (hyphen-less) ConfigOpts property which contains the option value .. py:attribute:: short a single character CLI option name .. py:attribute:: default the default value of the option .. py:attribute:: sample_default a sample default value string to include in sample config files .. py:attribute:: positional True if the option is a positional CLI argument .. py:attribute:: metavar the name shown as the argument to a CLI option in --help output .. py:attribute:: help a string explaining how the option's value is used cCs|idotd|fn||_|djoti}nt|ptdn||_|djo|ii dd|_ n ||_ ||_ ||_ ||_ ||_||_||_| |_| |_||_t|_| dj o| i dd} nti| pg|_| dj p | dj o |iit| d| n|idS(Nt_sillegal name %s with prefix _stype must be callablet-R(t startswitht ValueErrorRR RtStringtcallablet TypeErrorttypetreplaceR=tshortRBtsample_defaultt positionaltmetavarthelptsecrettrequiredtdeprecated_for_removalR?t_logged_deprecationtcopytdeepcopytdeprecated_optsR9t DeprecatedOptt_assert_default_is_of_opt_type(RRRPR=RRRBRTRURVRWRXtdeprecated_nametdeprecated_groupR]RSRY((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs8                 cCsFt|itio,|iiddidd}d|jStS(s/Check if default is a reference to another var.s\$R0s$$t$(t isinstanceRBtsixt string_typesRQR?(Rttmpl((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt_default_is_refs! cCs|idj o|i ot|ido|ii|i okdig}|iiD]}||iq_~}t i dh|d6|id6t|iid6ndS(Nt is_base_types, sVExpected default value of type(s) %(extypes)s but got %(default)r of type %(deftypes)stextypesRBtdeftypes( RBR RgthasattrRPRhRt BASE_TYPESRtLOGtdebug(Rt_[1]tttexpected_types((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR_s-   cCst|t|jS(N(tvars(Rtanother((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt__ne__scCst|t|jS(N(Rr(RRs((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt__eq__sc Cs||ifg}||if}xh|iD]]}|i|i}}|p|o6|i|o|n||o|n|ifq+q+W|i||i|i|}|io;|i o0t |_ |pd} t i d|i| n|S(sRetrieves the option value from a _Namespace object. :param namespace: a _Namespace object :param group_name: a group name REshOption "%s" from group "%s" is deprecated for removal. Its value may be silently ignored in the future.( R=RR]RR9t _get_valuetmultiRTRYRZR>Rmtwarning( Rt namespaceRtnamest current_nameR<tdnametdgrouptvaluet pretty_group((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt_get_from_namespaces  #    c Cs|i||}|i|}|id|o |ind}g}xG|iD]<}|i|i|i}|dj o|i|qTqTW|i |||i|i |||i |dS(s}Makes the option available in the command line interface. This is the method ConfigOpts uses to add the opt to the CLI interface as appropriate for the opt type. Some opt types may extend this method, others may just extend the helper methods it uses. :param parser: the CLI option parser :param group: an optional OptGroup object R0N( t_get_argparse_containert_get_argparse_kwargst_get_argparse_prefixRR R]t_get_deprecated_cli_nameRR9t_add_to_argparseRRRT( RtparserRt containerRCtprefixtdeprecated_namesR<R`((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt _add_to_clis #    R0c sfd} | d||g} |o| i| d|nx%|D]} | i| d| qOW|i|| |dS(sAdd an option to an argparse parser or group. :param container: an argparse._ArgumentGroup object :param name: the opt name :param short: the short opt name :param kwargs: the keyword arguments for add_argument() :param prefix: an optional prefix to prepend to the opt name :param positional: whether the option is a positional CLI argument csp|SdS(NR0((targ(RT(s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pythyphenss--RJN(R9tadd_parser_argument( RRRRRRRCRRTRRtargsR`((RTs4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR s cCs#|dj o|i|S|SdS(sReturns an argparse._ArgumentGroup. :param parser: an argparse.ArgumentParser :param group: an (optional) OptGroup object :returns: an argparse._ArgumentGroup if group is given, else parser N(R t_get_argparse_group(RRR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR s cKsy|ip9|i}|dj o|id|}n||d dgroup + '-' + dname dname -> dname dgroup -> dgroup + '-' + self.name neither -> None :param dname: a deprecated name, which can be None :param dgroup: a deprecated group, which can be None :param prefix: an prefix to append to (for example 'no' or '') :returns: a CLI argument name REN(R RR(RR|R}R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRRs    cCst|t|jS(N(thash(RRs((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt__lt__msN(RR R R?RwR RRgR_RtRutobjectt__hash__RRRRRRRR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRHPs*@   #          R^cBs5eZdZddZdZdZdZRS(sRepresents a Deprecated option. Here's how you can use it:: oldopts = [cfg.DeprecatedOpt('oldopt1', group='group1'), cfg.DeprecatedOpt('oldopt2', group='group2')] cfg.CONF.register_group(cfg.OptGroup('group1')) cfg.CONF.register_opt(cfg.StrOpt('newopt', deprecated_opts=oldopts), group='group1') For options which have a single value (like in the example above), if the new option is present ("[group1]/newopt" above), it will override any deprecated options present ("[group1]/oldopt1" and "[group2]/oldopt2" above). If no group is specified for a DeprecatedOpt option (i.e. the group is None), lookup will happen within the same group the new option is in. For example, if no group was specified for the second option 'oldopt2' in oldopts list:: oldopts = [cfg.DeprecatedOpt('oldopt1', group='group1'), cfg.DeprecatedOpt('oldopt2')] cfg.CONF.register_group(cfg.OptGroup('group1')) cfg.CONF.register_opt(cfg.StrOpt('newopt', deprecated_opts=oldopts), group='group1') then lookup for that option will happen in group 'group1'. If the new option is not present and multiple deprecated options are present, the option corresponding to the first element of deprecated_opts will be chosen. Multi-value options will return all new and deprecated options. So if we have a multi-value option "[group1]/opt1" whose deprecated option is "[group2]/opt2", and the conf file has both these options specified like so:: [group1] opt1=val10,val11 [group2] opt2=val21,val22 Then the value of "[group1]/opt1" will be ['val11', 'val12', 'val21', 'val22']. cCs||_||_dS(sConstructs an DeprecatedOpt object. :param name: the name of the option :param group: the group of the option N(RR(RRR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs cCs|i|ifS(N(RR(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt__keyscCs|i|ijS(N(t_DeprecatedOpt__key(Rtother((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRuscCst|iS(N(RR(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRsN(RR R R RRRuR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR^us /  tStrOptcBseZdZddZRS(sOption with String type Option with ``type`` :class:`oslo_config.types.String` `Kept for backward-compatibility with options not using Opt directly`. :param choices: Optional sequence of valid values. cKs/tt|i|dtid||dS(NRPtchoices(tsuperRRRRM(RRRRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRsN(RR R R R(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRstBoolOptcBs8eZdZdZddZdZddZRS(sBoolean options. Bool opts are set to True or False on the command line using --optname or --noopttname respectively. In config files, boolean values are cast with Boolean type. cKsFd|jotdntt|i|dti|dS(NRTs%positional boolean args not supportedRP(RLRRRRtBoolean(RRRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs cCs-tt|i|||i||dS(s<Extends the base class method to add the --nooptname option.N(RRRt_add_inverse_to_argparse(RRR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRsc Cs|i||}|i|dd}|id|o |ind}g}xM|iD]B}|i|i|idd}|dj o|i|qZqZWd|i|d<|i |||id|||i |dS(s0Add the --nooptname option to the option parser.tactiont store_falsetnoRsThe inverse of --RVN( RRRRR R]RRR9RRT( RRRRRCRRR<R`((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs#     t store_truecKsYtt|i||}d|jo |d=nd|jo |d=n||d<|S(s;Extends the base argparse keyword dict for boolean options.RPRUR(RRR(RRRRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs     N(RR R RR RRR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs    tIntOptcBseZdZdddZRS(sOption with Integer type Option with ``type`` :class:`oslo_config.types.Integer` `Kept for backward-compatibility with options not using Opt directly`. cKs/tt|i|dti|||dS(NRP(RRRRtInteger(RRtmintmaxRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs$N(RR R R R(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRstFloatOptcBseZdZdZRS(sOption with Float type Option with ``type`` :class:`oslo_config.types.Float` `Kept for backward-communicability with options not using Opt directly`. cKs)tt|i|dti|dS(NRP(RRRRtFloat(RRRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs(RR R R(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR stListOptcBseZdZdZRS(sOption with List(String) type Option with ``type`` :class:`oslo_config.types.List` `Kept for backward-compatibility with options not using Opt directly`. cKs)tt|i|dti|dS(NRP(RRRRtList(RRRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR#s(RR R R(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRstDictOptcBseZdZdZRS(sOption with Dict(String) type Option with ``type`` :class:`oslo_config.types.Dict` `Kept for backward-compatibility with options not using Opt directly`. cKs)tt|i|dti|dS(NRP(RRRRtDict(RRRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR0s(RR R R(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR'stIPOptcBseZdZddZRS(sOpt with IPAddress type Option with ``type`` :class:`oslo_config.types.IPAddress` :param version: one of either ``4``, ``6``, or ``None`` to specify either version. cKs,tt|i|dti||dS(NRP(RRRRt IPAddress(RRtversionRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR>s!N(RR R R R(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR4stMultiOptcBs&eZdZeZdZdZRS(s*Multi-value option. Multi opt values are typed opts which may be specified multiple times. The opt value is a list containing all the values specified. :param name: Name of the config option :param item_type: Type of items (see :class:`oslo_config.types`) For example:: cfg.MultiOpt('foo', item_type=types.Integer(), default=None, help="Multiple foo option") The command line ``--foo=1 --foo=2`` would result in ``cfg.CONF.foo`` containing ``[1,2]`` cKs tt|i|||dS(N(RRR(RRt item_typeRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRYscKs>tt|i|}|ipd|dRwRR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRCs t MultiStrOptcBseZdZdZRS(sMultiOpt with a MultiString ``item_type``. MultiOpt with a default :class:`oslo_config.types.MultiString` item type. `Kept for backwards-compatibility for options that do not use MultiOpt directly`. cKs)tt|i|dti|dS(NR(RRRRt MultiString(RRRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRrs (RR R R(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRfs t SubCommandOptcBs2eZdZddddddZddZRS(sSub-command options. Sub-command options allow argparse sub-parsers to be used to parse additional command line arguments. The handler argument to the SubCommandOpt constructor is a callable which is supplied an argparse subparsers object. Use this handler callable to add sub-parsers. The opt value is SubCommandAttr object with the name of the chosen sub-parser stored in the 'name' attribute and the values of other sub-parser arguments available as additional attributes. cCsMtt|i|dtid|d|||_||_||_dS(sConstruct an sub-command parsing option. This behaves similarly to other Opt sub-classes but adds a 'handler' argument. The handler is a callable which is supplied an subparsers object when invoked. The add_parser() method on this subparsers object can be used to register parsers for sub-commands. :param name: the option's name :param dest: the name of the corresponding ConfigOpts property :param title: title of the sub-commands group in help output :param description: description of the group in help output :param help: a help string giving an overview of available sub-commands RPR=RVN(RRRRRMthandlerttitlet description(RRR=RRRRV((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs !   c Cs|i}|dj o|id|}n|id|d|id|id|i}t|_|i dj o|i |ndS(s7Add argparse sub-parsers and invoke the handler method.RIR=RRRVN( R=R Rtadd_subparsersRRRVR>RXR(RRRR=t subparsers((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs      N(RR R R RR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRxst_ConfigFileOptcBs9eZdZdeifdYZdZdZRS(sThe --config-file option. This is an private option type which handles the special processing required for --config-file options. As each --config-file option is encountered on the command line, we parse the file and store the parsed values in the _Namespace object. This allows us to properly handle the precedence of --config-file options over previous command line arguments, but not over subsequent arguments. tConfigFileActioncBseZdZddZRS(s/An argparse action for --config-file. As each --config-file option is encountered, this action adds the value to the config_file attribute on the _Namespace object but also parses the configuration file and stores the values found also in the _Namespace object. cCsft||iddjot||ignt||i}|i|ti||dS(s{Handle a --config-file command line argument. :raises: ConfigFileParseError, ConfigFileValueError N(tgetattrR=R tsetattrR9t ConfigParsert _parse_file(RRRytvaluest option_stringtitems((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt__call__s  N(RR R R R(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRscKs#tt|i|d|dS(NcSs|S(((tx((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyts(RRR(RRRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRscKs)tt|i|}|i|d<|S(s?Extends the base argparse keyword dict for the config file opt.R(RRRR(RRRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs (RR R targparsetActionRRR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs  t _ConfigDirOptcBs9eZdZdeifdYZdZdZRS(sThe --config-dir option. This is an private option type which handles the special processing required for --config-dir options. As each --config-dir option is encountered on the command line, we parse the files in that directory and store the parsed values in the _Namespace object. This allows us to properly handle the precedence of --config-dir options over previous command line arguments, but not over subsequent arguments. tConfigDirActioncBseZdZddZRS(s An argparse action for --config-dir. As each --config-dir option is encountered, this action sets the config_dir attribute on the _Namespace object but also parses the configuration files and stores the values found also in the _Namespace object. cCst||i|tii|}tii|pt|ntii|d}x-tt i |D]}t i ||qsWdS(sHandle a --config-dir command line argument. :raises: ConfigFileParseError, ConfigFileValueError, ConfigDirNotFoundError s*.confN( RR=R"R#R%R1RRtsortedtglobRR(RRRyRRtconfig_dir_globR ((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRsN(RR R R R(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRscKs)tt|i|dti|dS(NRP(RRRRRM(RRRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRscKs)tt|i|}|i|d<|S(sAExtends the base argparse keyword dict for the config dir option.R(RRRR(RRRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR s (RR R RRRRR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs  tOptGroupcBsDeZdZdddZedZdZdZdZ RS(sRepresents a group of opts. CLI opts in the group are automatically prefixed with the group name. Each group corresponds to a section in config files. An OptGroup object has no public methods, but has a number of public string properties: .. py:attribute:: name the name of the group .. py:attribute:: title the group title as displayed in --help .. py:attribute:: help the group description as displayed in --help cCsI||_|djo d|n||_||_h|_d|_dS(sConstructs an OptGroup object. :param name: the group name :param title: the group title for --help :param help: the group description for --help s %s optionsN(RR RRVt_optst_argparse_group(RRRRV((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR+s  !  cCs:t|i|otSh|d6|d6|i|i(RR<R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt _register_opt9scCs(|i|ijo|i|i=ndS(sJRemove an opt from this group. :param opt: an Opt object N(R=R(RR<((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt_unregister_optHscCs6|idjo|i|i|i|_n|iS(N(RR tadd_argument_groupRRV(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRPs cCs d|_dS(s(Clear this group's option parsing state.N(R R(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt_clearWsN( RR R R RR?RRRR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs    t ParseErrorcBseZdZdZRS(cCs)tt|i|||||_dS(N(RRRtfilename(RRtlinenotlineR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR]scCs d|i|i|i|ifS(Nsat %s:%d, %s: %r(RRRR(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRas(RR RR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR\s RcBsYeZdZdZdZdZdZddZdZ e dZ RS( cCs;tt|i||_||_d|_d|_dS(N(RRRRtsectionsR t _normalizedtsection(RRR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRgs    cCs ||_dS(N(R(Rt normalized((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt_add_normalizednscCsFt|iii}z#|~}tt|i|SWdQXdS(N(topenRt__exit__t __enter__RRtparse(RRotf((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRqs&cCsS||_|ii|ih|idj o |iit|ihndS(N(RRt setdefaultRR RG(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt new_sectionus  cs|ip|indifd}||i|i|idj o||it|indS(Ns cs-||ig||idS(N(RR9(RR(R~tkey(s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR9s(Rterror_no_sectionRRRR RG(RRR~R9((R~Rs4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt assignment}s cCst||||iS(N(RR(RRRR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt parse_excscCs|id|iS(Ns)Section must be started before assignment(RR(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs cCst|}h}h}|||}|i|y|iWntij o!}t|it|nctj oV}|i t i jo|i |dS|i t i jo|i |dSnX|i||dS(sParse a config file and store any values in the namespace. :raises: ConfigFileParseError, ConfigFileValueError N(R'RRRRRRtstrtIOErrorterrnotENOENTt_file_not_foundtEACCESt_file_permission_deniedt_add_parsed_config_file(tclsR RyRRRtpeterr((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs$    N( RR RRRRRR RRt classmethodR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRfs       tMultiConfigParsercBsPeZdZdZdZdZedZeeddZ dZ RS(sKOption "%s" from group "%s" is deprecated. Use option "%s" from group "%s".cCs"g|_g|_t|_dS(N(tparsedRtsett_emitted_deprecations(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs  cCsg}xz|D]r}h}h}t||}|i|y|iWntj o q nX|i|||i|q W|S(N(RRRRRR9(RRtread_okRRRR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pytreads cCs*|iid||iid|dS(sAdd a parsed config file to the list of parsed files. :param sections: a mapping of section name to dicts of config values :param normalized: sections mapping with section names normalized :raises: ConfigFileValueError iN(RtinsertR(RRR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRscCs|i|d|S(NRw(t_get(RRzRw((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pytgetsc s%g}fd}g}|D]\}} |||| fq ~}xo |in|iD]} x|D]\}} || joqpn| | |joY|p|d}|i|| f||d| || } |o| |}q| SqpqpWqcW|o|gjo|StdS(sFetch a config file value from the parsed files. :param names: a list of (section, name) tuples :param multi: a boolean indicating whether to return multiple values :param normalized: whether to normalize group names to lowercase cso t|S|S(N(RG(R(R(s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt normalizesiiN(RRt_check_deprecatedtKeyError( RRzRwRR{trvalueRRoRRRtval((Rs4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs(3   cCstd|D}|dpd|df}||jok||ijo[|ii||dpd|df}ti|i|d|d|d|dndS(sSCheck for usage of deprecated names. :param name: A tuple of the form (group, name) representing the group and name where an opt value was found. :param current: A tuple of the form (group, name) representing the current name for an option. :param deprecated: A list of tuples with the same format as the name param which represent any deprecated names for an option. If the name param matches any entries in this list a deprecation warning will be logged. css,x%|]\}}|pd|fVqWdS(REN((t.0tgtn((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pys s iREiN(RRtaddRmRxt_deprecated_opt_message(RRtcurrentt deprecatedR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRsN( RR R RRRR?RR RR(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs   t _NamespacecBsMeZdZdZdZdZdZdZdZdZ RS(seAn argparse namespace which also stores config file values. As we parse command line arguments, the values get set as attributes on a namespace object. However, we also want to parse config files as they are specified on the command line and collect the values alongside the option values parsed from the command line. Note, we don't actually assign values from config files as attributes on the namespace because config file options be registered after the command line has been parsed, so we may not know how to properly parse or convert a config file value at this point. cCs+||_t|_g|_g|_dS(N(t_confRt_parsert_files_not_foundt_files_permission_denied(Rtconf((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR s   c CsWt|i}|ii||x.|iiD]\}}|dj o |ind}y|i||}WnItj o q2n5t j o(}t d|it |fnX|djo |i } n|d|i } |i oMt|| ddjot|| gnt|| } | i|q2t|| |q2WdS(sParse CLI options from a config file. CLI options are special - we require they be registered before the command line is parsed. This means that as we parse config files, we can go ahead and apply the appropriate option-type specific conversion to the values in config files for CLI options. We can't do this for non-CLI options, because the schema describing those options may not be registered until after the config files are parsed. This method relies on that invariant in order to enforce proper priority of option values - i.e. that the order in which an option value is parsed, whether the value comes from the CLI or a config file, determines which value specified for a given option wins. The way we implement this ordering is that as we parse each config file, we look for values in that config file for CLI options only. Any values for CLI options found in the config file are treated like they had appeared on the command line and set as attributes on the namespace objects. Values in later config files or on the command line will override values found in this file. s$Value for option %s is not valid: %sRIN(R R RRt _all_cli_optsR RRRRLR!RR=RwRRtextend( RRRRyR<RRR~tveR=R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt _parse_cli_opts_from_config_file&s,    cCs'|i|||ii||dS(sAdd a parsed config file to the list of parsed files. :param sections: a mapping of section name to dicts of config values :param normalized: sections mapping with section names normalized :raises: ConfigFileValueError N(RRR(RRR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRWscCs|ii|dS(ssRecord that we were unable to open a config file. :param config_file: the path to the failed file N(RR9(RR ((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRascCs|ii|dS(szRecord that we have no permission to open a config file. :param config_file: the path to the failed file N(RR9(RR ((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRhscCs}xp|D]h\}}|djo|n |d|}t||d}|dj o|o| oqn|SqWtdS(sFetch a CLI option value. Look up the value of a CLI option. The value itself may have come from parsing the command line or parsing config files specified on the command line. Type conversion have already been performed for CLI options at this point. :param names: a list of (section, name) tuples :param positional: whether this is a positional option RIN(R RR(RRzRTRRR~((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt_get_cli_valueos  "  c Csy|i||SWntj onXg}|D]-\}}||dj o|nd|fq5~}|ii|d|dtd|}|o|S|dS(sFetch a value from config files. Multiple names for a given configuration option may be supplied so that we can transparently handle files containing deprecated option names or groups. :param names: a list of (section, name) tuples :param multi: a boolean indicating whether to return multiple values :param positional: whether this is a positional option RERwRR{iN(RRR RRR>( RRzRwRTR{RoRRR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRvs A ( RR R RRRRRRRv(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR s   1   t_CachedArgumentParsercBsVeZdZdddZdZdZdddZddZddZ RS(sZclass for caching/collecting command line arguments. It also sorts the arguments before initializing the ArgumentParser. We need to do this since ArgumentParser by default does not sort the argument options and the only way to influence the order of arguments in '--help' is to ensure they are added in the sorted order. cKs)tt|i|||h|_dS(N(RRRt _args_cache(RR:tusageRC((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRscOsSg}||ijo|i|}n|ih|d6|d6||i|tlenRt add_argumentRt ArgumentErrorR(RRRtindexthas_positionaltargumenttsizete((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pytinitialize_parser_argumentss&    cCs#|itt|i||S(N(R$RRt parse_args(RRRy((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR%s cCs$|itt|i|dS(N(R$RRt print_help(Rtfile((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR&s cCs$|itt|i|dS(N(R$RRt print_usage(RR'((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR(s N( RR R R RRR$R%R&R((((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs    t ConfigOptscBseZdZdZdZdZdZd6d6d6d6d6d6edZ dZ dZ dZ d Z d Zd Zed Zd Zed6edZed6dZed6dZed6dZdZed6dZed6dZd6dZdZed6edZed6dZed6dZed6dZdZdZ dZ!dZ"dZ#d6d Z$d6d!Z%d6d6d"Z&d6d6d#Z'd6d6d$Z(d%e)i*fd&YZ*d'Z+ed(Z,d6d)Z-d6d*Z.d+Z/d,Z0d-Z1ed.Z2d/Z3d0e4i5fd1YZ6d2e7fd3YZ8d4e7fd5YZ9RS(7sConfig options which may be set on the command line or in config files. ConfigOpts is a configuration option manager with APIs for registering option schemas, grouping options, parsing option values and retrieving the values of options. cCs[h|_h|_d|_d|_d|_h|_g|_ti |_ t |_ dS(sConstruct a ConfigOpts object.N( Rt_groupsR t_argst_oparsert _namespacet_ConfigOpts__cachet _config_optst collectionstdequet _cli_optsR?t_validate_default_values(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRs       cCs|djotiitid}n|djot||}ntd|d||_|ii |idddd|||fS(s7Initialize a ConfigCliParser object for option parsing.iR:Rs --versionRRN( R R"R#R3R7R8R;RR,R(RR-R:RRtdefault_config_files((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt _pre_setups  cCsztdd|ddddtddddd g|_|i|i||_||_||_||_||_d S( s2Initialize a ConfigOpts object for option parsing.s config-fileRBRUtPATHRVsPath to a config file to use. Multiple config files can be specified, with values in later files taking precedence. The default files used are: %(default)s.s config-dirtDIRs0Path to a config directory to pull *.conf files from. This file set is sorted, so as to provide a predictable parse order if individual options are over-ridden. The set is parsed after the file(s) specified via previous --config-file, arguments hence over-ridden options in the directory take precedence.N( RRR/tregister_cli_optsR-R:RRR4(RR-R:RRR4((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt_setups       cs"tifd}|S(NcsK|idto$|||}|ii|S|||SdS(Nt clear_cache(tpopR>R.tclear(RRRCtresult(R(s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt__inners  (t functoolstwraps(Rt_ConfigOpts__inner((Rs4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt __clear_caches cCs|i||_|i|||||\}}|i||||||i|dj o|n tid|_|ii ot |ii n|ii ot |ii n|i dS(sParse command line arguments and config files. Calling a ConfigOpts object causes the supplied command line arguments and config files to be parsed, causing opt values to be made available as attributes of the object. The object may be called multiple times, each time causing the previous set of values to be overwritten. Automatically registers the --config-file option with either a supplied list of default config files, or a list from find_config_files(). If the --config-dir option is set, any *.conf files from this directory are pulled in, after all the file(s) specified by the --config-file option. :param args: command line arguments (defaults to sys.argv[1:]) :param project: the toplevel project name, used to locate config files :param prog: the name of the program (defaults to sys.argv[0] basename) :param version: the program version (for --version) :param usage: a usage string (%prog will be expanded) :param default_config_files: config files to use by default :param validate_default_values: whether to validate the default values :returns: the list of arguments left over after parsing options :raises: SystemExit, ConfigFilesNotFoundError, ConfigFileParseError, ConfigFilesPermissionDeniedError, RequiredOptError, DuplicateOptError iN(R<R3R5R9t_parse_cli_optsR R7R8R-RRRRt_check_required_opts(RRR-R:RRR4tvalidate_default_values((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR(s $     cCsLy|i|SWn4tj o n tj ot|nXdS(sLook up an option value and perform string substitution. :param name: the opt name (or 'dest', more precisely) :returns: the option value (after string substitution) or a GroupAttr :raises: ValueError or NoSuchOptError N(RRLt ExceptionR(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt __getattr__bs cCs |i|S(s8Look up an option value and perform string substitution.(RG(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt __getitem__pscCs||ijp ||ijS(s<Return True if key is the name of a registered opt or group.(RR*(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt __contains__tsccs8x1ti|ii|iiD] }|Vq%WdS(s0Iterate over all registered opt and group names.N(t itertoolstchainRtkeysR*(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt__iter__xs%cCst|it|iS(s/Return the number of options and option groups.(RRR*(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt__len__}scCs|i|idS(s8Clear the object state and unset overrides and defaults.N(t_unset_defaults_and_overridesR<(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pytresets cCs\d|_d|_d|_t|_|i|ix!|ii D]}|i qDWdS(sClear the state of the object to before it was called. Any subparsers added using the add_cli_subparsers() will also be removed as a side-effect of this method. N( R R+R,R-R?R3tunregister_optsR/R*RR(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR<s    cCsqh|d6|d6|ijodS|io"|iih|d6|d6n|iih|d6|d6dS(NR<R(R2RTR9t appendleft(RR<R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt _add_cli_opts  "cCs|dj oA|i|dt}|o|i||n|i||S|o|i|dnt|i|otSh|d6|d6|i|iRSRRARR?R=(RR<RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt register_opts cCs+x$|D]}|i||dtqWdS(s)Register multiple option schemas at once.R:N(RVR?(RR@RR<((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt register_optsscCs<|idj otdn|i||dtdtS(sRegister a CLI option schema. CLI option schemas must be registered before the command line and config files are parsed. This is to ensure that all CLI options are shown in --help and option validation works as expected. :param opt: an instance of an Opt sub-class :param group: an optional OptGroup object or group name :return: False if the opt was already registered, True otherwise :raises: DuplicateOptError, ArgsAlreadyParsedError scannot register CLI optionRR:N(R+R R RVR>R?(RR<R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pytregister_cli_opts cCs+x$|D]}|i||dtqWdS(s-Register multiple CLI option schemas at once.R:N(RXR?(RR@RR<((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR8scCs5|i|ijodSti||i|i scCsD|io)g}|D]}||i|q~S|i|SdS(sePerform value type conversion. Converts values using option's type. Handles cases when value is actually a list of values (for example for multi opts). :param value: the string value, or list of string values :param opt: option definition (instance of Opt class or its subclasses) :returns: converted value N(RwRP(RR~R<Rotv((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRdA s )cCst|to|nd}|o |in|}||ijo8|pt|n|i|p td|n|i|S(sLooks up a OptGroup object. Helper function to return an OptGroup given a parameter which can either be the group's name or an OptGroup object. The OptGroup object returned is from the internal dict of OptGroup objects, which will be a copy of any OptGroup object that users of the API have access to. If autocreate is True, the group will be created if it's not found. If group is an instance of OptGroup, that same instance will be registered, otherwise a new instance of OptGroup will be created. :param group_or_name: the group's name or the OptGroup object itself :param autocreate: whether to auto-create the group if it's not found :raises: NoSuchGroupError RN(RcRR RR*RRY(Rt group_or_nameRTRR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRUP s!cCsZ|djo |i}n|i|}|i}||jot||n||S(sReturn the (opt, override, default) dict for an opt. :param opt_name: an opt name/dest :param group: an optional group name or OptGroup object :raises: NoSuchOptError, NoSuchGroupError N(R RRUR(RRRR@((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR_m s    cCsx|iD]z\}}|d}|ioZd|jp d|joq n|i|i||djot|i|qq q WdS(sCheck that all opts marked as required have values specified. :param namespace: the namespace object be checked the required options :raises: RequiredOptError R<RBRcN(RlRXRR=R RR(RRyRkRR<((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRD s   cCsC||_x-|iD]\}}|i|i|qW|iS(swParse command line options. Initializes the command line option parser and parses the supplied command line arguments. :param args: the command line arguments :returns: a _Namespace object containing the parsed option values :raises: SystemExit, DuplicateOptError ConfigFileParseError, ConfigFileValueError (R+RRR,t_parse_config_files(RRR<R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRC s  cCst|}xW|iD](}|djp|idoPqqWx!|iD]}ti||qLW|ii|i||i||S(sParse configure files options. :raises: SystemExit, ConfigFilesNotFoundError, ConfigFileParseError, ConfigFilesPermissionDeniedError, RequiredOptError, DuplicateOptError s --config-files--config-file=( R R+RKR4RRR,R%t_validate_cli_options(RRyRR ((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR s     c Csxt|iddD]\}}|o |ind}y|i||}Wntj o qnX|i|d|d|}y|i||Wqtj o6t i i d|i t |i|ftqXqWdS(NRcSs |diS(i(R(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR sRRys$argument --%s: Invalid %s value: %s (RRRR RRRzRdRLR7tstderrtwriteR=treprRPt SystemExit(RRyR<RRR~((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR s  cCsyW|i}|iot|in|iot|in|i|WnNtj o}tid|i t St j o}tid|t SX||_ t SdS(sReload configure files and parse all options :return False if reload configure files failed or else return True sDCaught SystemExit while reloading configure files with exit code: %ds0Caught Error while reloading configure files: %sN(RRRRRRDRRmtwarntcodeR?RR-R>(RRytexcR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pytreload_config_files s$       ccs4x-|iiiD]}x|D] }|VqWqWdS(sList all sections from the configuration. Returns an iterator over all section names found in the configuration files, whether declared beforehand or not. N(R-RR(RRR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pytlist_all_sections s RtcBsDeZdZdZdZdZdZdZdZRS(sdHelper class. Represents the option values of a group as a mapping and attributes. cCs||_||_dS(sConstruct a GroupAttr object. :param conf: a ConfigOpts object :param group: an OptGroup object N(R t_group(RRR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR s cCs|ii||iS(s:Look up an option value and perform template substitution.(R RR(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRG scCs |i|S(s8Look up an option value and perform string substitution.(RG(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRH scCs||iijS(s<Return True if key is the name of a registered opt or group.(RR(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRI sccs&x|iiiD] }|VqWdS(s0Iterate over all registered opt and group names.N(RRRL(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRM scCst|iiS(s/Return the number of options and option groups.(RRR(R((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRN s( RR R RRGRHRIRMRN(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRt s    R|cBs eZdZdZdZRS(s\Helper class. Represents the name and arguments of an argparse sub-parser. cCs||_||_||_dS(sConstruct a SubCommandAttr object. :param conf: a ConfigOpts object :param group: an OptGroup object :param dest: the name of the sub-parser N(R Rt_dest(RRRR=((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR s  cCs|djoE|i}|idj o|iid|}nt|ii|S||ijot|nyt|ii|SWntj ot |nXdS(s,Look up a sub-parser name or argument value.RRIN( RRR RRR R-RtAttributeErrorR(RR((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRG$ s  (RR R RRG(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR| s RcBs&eZdZdddZdZRS(sUHelper class. Exposes opt values as a dict for string substitution. cCs||_||_||_dS(s\Construct a StrSubWrapper object. :param conf: a ConfigOpts object N(RRyR(RRRRy((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR; s  c Csy|idd\}}Wn"tj o|i}|}nXtd|}y%|ii|d|d|i}Wn.tj o"|ii|d|i}nXt||ii ot d|n|S(sLook up an opt value from the ConfigOpts object. :param key: an opt name :returns: an opt value R)iRRRys#substituting group %s not supported( tsplitRLRRRRRyRRcRtR(RRRtoptionRR~((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyRHD s   N(RR R R RRH(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR4 s N(:RR R RR5R9t_ConfigOpts__clear_cacheR R?RRGRHRIRMRNRPR<RSRVRWRXR8RYR]RQRaRbRgRhRiRjRlRRORpRxR(R&RRyRztstringR}RdRUR_RDRCRRRRR0tMappingRtRR|R(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyR)s     3                $  :        %"(HR RR0R[RR?RRJtloggingR"RR7RdRt oslo_configRRt getLoggerRRmRFRR R RRRRRRRRRRR!R'R R/R6R;RARDRGRRHtPY3ttotal_orderingR^RRRRRRRRRRRRRRt BaseParserRRt NamespaceR tArgumentParserRRR)tCONF(((s4/tmp/pip-build-lt8jXN/oslo.config/oslo_config/cfg.pyt>s                       &   " D6   #8.5I Ib: