id,5rddlmZddlmZmZmZmZdZdZGddZ GddeZ Gd d Z y ) )Action) ConfigParser ParsingErrorErrorDuplicateOptionErrorc<t|}|tuxs|tuS)z@Return true if val is an instance of a known sequence type. )typelisttuple)valval_types -/usr/lib/python3/dist-packages/sos/options.py_is_seqrs"CyH t  0x500c8|j}|dvry|dvryy)N)trueonyesT)falseoffnoF)lower)r _vals r str_to_boolrs( 99;D $$ ' 'rc|eZdZdZdZddZdZdZifdZe ifdZ e dZ d Z d Z dd Zdd Zd Zy) SoSOptionscpd}t||rt||}t||}||r||r|s||jvrRt|sGt ||||r|jj |y|jj |yt|rt ||||zyyy)Nc|dk(xs|duS)N)r s r_unsetz%SoSOptions._merge_opt.._unset"s2I, -r)hasattrgetattr _nondefaultrsetattrdiscardadd)selfoptsrc is_defaultr!newvalueoldvalues r _merge_optzSoSOptions._merge_opt!s . 3 sC(HtS)H x )9D,,,wx7Hc8,$$,,S1$$((-"c8h#67#! rct|ts t|}|jD]}|j |||yN) isinstancedictvars arg_namesr.)r(r*r+args r _merge_optszSoSOptions._merge_opts9s8#t$s)C>> 2C OOCj 1 2rc|}d}|jD] }|||z|zz }|j||jDcgc]}t||}}|s,|D cgc] } t| rdj | n| "}} n$|D cgc]} t | t rd| zn| }} |t|zj||zScc}wcc} wcc} w)aIFormat a SoSOptions object as a human or machine readable string. :param quote: quote option values :param sep: list separator string :param prefix: arbitrary prefix string :param suffix: arbitrary suffix string :param literal: print values as Python literals z=%s,z'%s')r4stripr#rjoinr1strr ) r(quotesepprefixsuffixargsarg_fmtr5valsvs r__strzSoSOptions.__str?s>> (C C'MC' 'D ( 3.2nn=sc"==>BC71:CHHQK14CDCFJJ*Q"4FQJ!;JDJuT{"))#.77>DKsC%C Cc"|jSr0_SoSOptions__strr(s r__str__zSoSOptions.__str__Xszz|rc,|jddddS)NTz, z SoSOptions())r<r=r>r?rFrHs r__repr__zSoSOptions.__repr__[s!zz$}!$& &rc B||_t|j|_t |_|jD]}t |||j||jD]-}|jj|t ||||/y)aInitialise a new ``SoSOptions`` object from keyword arguments. Initialises the new object with values taken from keyword arguments matching the names of ``SoSOptions`` attributes. A ``ValueError`` is raised is any of the supplied keyword arguments does not correspond to a known ``SoSOptions` attribute name. :param *kwargs: a list of ``SoSOptions`` keyword args. :returns: the new ``SoSOptions`` object. N) arg_defaultsr keysr4setr$r%append)r(rNkwargsr5s r__init__zSoSOptions.__init___s)l//125$$ 7C D#t005 6 7;;= ,C NN ! !# & D#vc{ + ,rcZtdit|d|i}|j|d|S)a Initialise a new SoSOptions object from a ``Namespace`` obtained by parsing command line arguments. :param args: parsed command line arguments :returns: an initialised SoSOptions object :returntype: SoSOptions rNTr )rr3r6)clsr@rNoptss r from_argszSoSOptions.from_argsws/BDJB\B t$ rcd}d}||vrd|zgS||vr&tdt|Dcgc]}d|z c}Sd|zdz|zgScc}w)zConvert a named option and optional value to command line argument notation, correctly handling options that take no value or that have special representations (e.g. verify and verbose). ) alloptionszallow-system-changeszall-logsbatchbuilddebug experimentalz list-pluginsz list-presetsz list-profilesz no-reportz no-env-varsquietverify)verbosez--%sr--=)rangeint)rUr)r no_valuecountds r _opt_to_argszSoSOptions._opt_to_argssf   (?SL> ! %<*/3s8*<=QFSL= =s S 3&''>s Act|j|t|r|St|j|tr|j dDcgc]}|c}St|j|t r!t |}|td|d|d|St|j|tr t|S|Scc}w#t$rtd|d|dwxYw)aEnsure that the value read from a config file is the proper type for consumption by the component, as defined by arg_defaults. Params: :param key: The key in arg_defaults we need to match the type of :param val: The value to be converted to a particular type :param conf: File values are being loaded from r8z Value of 'z' in z# must be True or False or analagousz must be integer) r1rNr r splitboolr Exceptionrd ValueError)r(keyr confrCs r_convert_to_typezSoSOptions._convert_to_types d'',d3i 8J d'',d 3"yy~.!A. . d'',d 3c"C{D"## d'',c 2 /3x / /#&!.// /s C = CC+c fd}t} t5}|j|ddd|d |||||jd ritd r\|jd D]G\}} |j!d dj"vs'j$j'|dz| zIyyy#1swYxYw#t$r-}t d|j d|j dd}~wttf$rt dzwxYw#ttf$r)}tdd|jd Yd}~!d}~wwxYw)zRead the provided config_file and update options from that. Positional arguments: :param config_file: Filepath to the config file :param component: Which component (section) to load cr|j|r$t|j|}d|jvrt |j d|d<dddd}t |D]F}d|vr$|j |||jdd<||vs0|j ||||<H|jD]m\}}t|tr|d k7r|jd d }|jvrtd |d |dNj||}t||oyy)Nr` verbositylabelplugoptsprofiles)name plugin_optionprofile-_keywords rzUnknown option '' in section '') has_sectionr2itemsrOrdpopr replacer1r;rNprintrpr%)sectionconfigodict rename_optsrnr config_filer(s r_update_from_sectionz9SoSOptions.update_from_conf.._update_from_sections>!!'*V\\'23 ,),UYYy-A)BE+& $%/)  ;ACcz7> 1C3$sC ,LS%0  1rc^i}|jD]}t||}|r|dvrd}|||<|S)zReturn this ``SoSOptions`` option values as a dictionary of argument name to value mappings. :returns: a name:value dictionary of option values.  add_preset del_presetdescnoteN)r4r#)r( preset_filterrr5values rr2zSoSOptions.dictsI >> CD#&EFF EE#J   rcfdfd}d}tjjd}|Dcgc]\}}|||s|||c}}Scc}}w)zReturn command arguments for this object. Return a list of the non-default options of this ``SoSOptions`` object in ``sosreport`` command line argument notation: ``["--all-logs", "-vvv"]`` cd}|r||vry|dk(r|ry|jvr%t|tj|k(ryy)z. Test for non-null option values. )FalseNonez[]z""z''0FruT)rNr;)rwr null_valuesr(s r has_valuez%SoSOptions.to_args..has_value!sUCKE[0z!et(((u:T%6%6t%.filter_opt.s1CCDDA:T5) )rc|jdrdt|dzz}|S|jdd}t|rdj |n|}|dur|d|}n|}t |dkDrd |z}|Sd|z}|S) zD Convert sos option notation to command line arguments. rsrzrCr{r8Tr}rra) startswithrdrrr:len)rwrr5r)s rargifyz"SoSOptions.to_args..argify9s{+CJ,, <<S)D'.u~CHHUO5ED !%u- #C1 $*CJ36)CJrc |dS)Nrr )xs rz$SoSOptions.to_args..Ms adr)rn)sortedr2r)r(rr opt_itemsnrCrs` @rto_argszSoSOptions.to_argssV  * (499;,,.NC +4I!Q 1a8Hq! IIIs A  A N)Fr}rr)T)__name__ __module__ __qualname__r.r6rGrIrLrS classmethodrWrhrprrr2rr rrrrsl802 82&%',0*,  (($rsC001oJoJd -F-''r