Ë
    i©¹d,5  ã                   ór   — d dl mZ d dlmZmZmZmZ d„ Zd„ Z G d„ d«      Z	 G d„ de«      Z
 G d	„ d
«      Zy)é    )ÚAction)ÚConfigParserÚParsingErrorÚErrorÚDuplicateOptionErrorc                 ó<   — t        | «      }|t        u xs |t        u S )z@Return true if val is an instance of a known sequence type.
    )ÚtypeÚlistÚtuple)ÚvalÚval_types     ú-/usr/lib/python3/dist-packages/sos/options.pyÚ_is_seqr      s"   € ô �C‹y€HØ”tÐÒ0˜x¬5Ð0Ð0ó    c                 ó8   — | j                  «       }|dv ry|dv ryy )N)ÚtrueÚonÚyesT)ÚfalseÚoffÚnoF)Úlower)r   Ú_vals     r   Ústr_to_boolr      s(   € Ø�9‰9‹;€DØÐ$Ñ$ØØ	Ð'Ñ	'Øàr   c                   ó|   — e Zd Zd„ Zd„ Zdd„Zd„ Zd„ Zi fd„Ze	i fd„«       Z
e	d„ «       Zd	„ Zd
„ Zdd„Zdd„Zd„ Zy)Ú
SoSOptionsc                 óp  — d„ }t        ||«      r§t        ||«      }t        | |«      } ||«      r ||«      r|s|| j                  vrRt        |«      sGt	        | ||«       |r| j                  j                  |«       y | j                  j                  |«       y t        |«      rt	        | |||z   «       y y y )Nc                 ó   — | dk(  xs | d u S )NÚ © )r   s    r   Ú_unsetz%SoSOptions._merge_opt.<locals>._unset"   s   € Ø˜2‘IÒ, ¨ Ð-r   )ÚhasattrÚgetattrÚ_nondefaultr   ÚsetattrÚdiscardÚadd)ÚselfÚoptÚsrcÚ
is_defaultr!   ÚnewvalueÚoldvalues          r   Ú
_merge_optzSoSOptions._merge_opt!   s®   € ò	.ô �3˜ÔÜ˜s CÓ(ˆHÜ˜t SÓ)ˆHñ
 �xÔ ©°Ô)9ÙØ˜D×,Ñ,Ñ,´w¸xÔ7Hä˜˜c 8Ô,ÙØ×$Ñ$×,Ñ,¨SÕ1à×$Ñ$×(Ñ(¨Õ-Ü˜Ô"ä˜˜c 8¨hÑ#6Õ7ð #ð! r   c                 ó‚   — t        |t        «      st        |«      }| j                  D ]  }| j	                  |||«       Œ y ©N)Ú
isinstanceÚdictÚvarsÚ	arg_namesr.   )r(   r*   r+   Úargs       r   Ú_merge_optszSoSOptions._merge_opts9   s8   € Ü˜#œtÔ$Ü�s“)ˆCØ—>‘>ò 	2ˆCØ�O‰O˜C  jÕ1ñ	2r   c                 ó¬  — |}d}| j                   D ]  }|||z   |z   z  }Œ |j                  |«       | j                   D �cg c]  }t        | |«      ‘Œ }}|s,|D �	cg c]   }	t        |	«      rdj	                  |	«      n|	‘Œ" }}	n$|D �	cg c]  }	t        |	t        «      rd|	z  n|	‘Œ }}	|t        |«      z  j                  |«      |z   S c c}w c c}	w c c}	w )aI  Format 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')r4   Ústripr#   r   Újoinr1   Ústrr   )
r(   ÚquoteÚsepÚprefixÚsuffixÚargsÚarg_fmtr5   ÚvalsÚvs
             r   Ú__strzSoSOptions.__str?   sß   € ð ˆØˆØ—>‘>ò 	(ˆCØ�C˜'‘M CÑ'Ñ'‰Dð	(à�
‰
�3Œà.2¯n©nÖ= s”˜˜cÕ"Ð=ˆÐ=Ùà>BÖC¸¤7¨1¤:�C—H‘H˜Q”K°1Ñ4ÐCˆDÑCð FJÖJÀ¤*¨Q´Ô"4�F˜Q’J¸!Ñ;ÐJˆDÐJà”u˜T“{Ñ"×)Ñ)¨#Ó.°Ñ7Ð7ùò >ùò Dùò Ks   Á CÁ%CÂCc                 ó"   — | j                  «       S r0   ©Ú_SoSOptions__str©r(   s    r   Ú__str__zSoSOptions.__str__X   s   € Ø�z‰z‹|Ðr   c                 ó,   — | j                  dddd¬«      S )NTz, zSoSOptions(ú))r<   r=   r>   r?   rF   rH   s    r   Ú__repr__zSoSOptions.__repr__[   s!   € Ø�z‰z ¨$°}Ø!$ð ó &ð 	&r   c                 óB  — || _         t        |j                  «       «      | _        t	        «       | _        | j                   D ]  }t        | || j                   |   «       Œ |j                  «       D ]-  }| j                  j                  |«       t        | |||   «       Œ/ y)aô  Initialise 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
   Úkeysr4   Úsetr$   r%   Úappend)r(   rN   Úkwargsr5   s       r   Ú__init__zSoSOptions.__init___   s�   € ð )ˆÔÜ˜l×/Ñ/Ó1Ó2ˆŒÜ›5ˆÔà×$Ñ$ò 	7ˆCÜ�D˜#˜t×0Ñ0°Ñ5Õ6ð	7ð —;‘;“=ò 	,ˆCØ�N‰N×!Ñ! #Ô&Ü�D˜#˜v c™{Õ+ñ	,r   c                 óZ   — t        di t        |«      ¤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
        rN   Tr    )r   r3   r6   )Úclsr@   rN   Úoptss       r   Ú	from_argszSoSOptions.from_argsw   s/   € ô ÑBœD ›JÑB°\ÒBˆØ×Ñ˜˜tÔ$Øˆr   c                 ó”   — d}d}||v rd|z  gS ||v r&t        dt        |«      «      D �cg c]  }d|z  ‘Œ	 c}S d|z   dz   |z   gS c c}w )zçConvert 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).
        )Ú
alloptionszallow-system-changeszall-logsÚbatchÚbuildÚdebugÚexperimentalzlist-pluginszlist-presetszlist-profilesz	no-reportzno-env-varsÚquietÚverify)Úverbosez--%sr   ú--ú=)ÚrangeÚint)rU   r)   r   Úno_valueÚcountÚds         r   Ú_opt_to_argszSoSOptions._opt_to_args„   sf   € ð
ˆð
 ˆØ�(‰?Ø˜S‘L�>Ð!Ø�%‰<Ü*/°´3°s³8Ó*<Ö= Q�F˜S“LÒ=Ð=Ø�s‘
˜SÑ  3Ñ&Ð'Ð'ùò >s   ªAc                 óÜ  — t        | j                  |   t        |«      «      r|S t        | j                  |   t        «      r|j	                  d«      D �cg c]  }|‘Œ c}S t        | j                  |   t
        «      r!t        |«      }|€t        d|›d|›d�«      ‚|S t        | j                  |   t        «      r	 t        |«      S |S c c}w # t        $ r t        d|›d|›d�«      ‚w xY w)a¦  Ensure 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
        r8   z
Value of 'z' in z# must be True or False or analagousz must be integer)
r1   rN   r	   r
   ÚsplitÚboolr   Ú	Exceptionrd   Ú
ValueError)r(   Úkeyr   ÚconfrC   s        r   Ú_convert_to_typezSoSOptions._convert_to_type—   sé   € ô �d×'Ñ'¨Ñ,¬d°3«iÔ8ØˆJÜ�d×'Ñ'¨Ñ,¬dÔ3Ø"Ÿy™y¨›~Ö.˜!’AÒ.Ð.Ü�d×'Ñ'¨Ñ,¬dÔ3Ü˜cÓ"ˆCØˆ{ÝâšDð"ó#ð #ð �
Ü�d×'Ñ'¨Ñ,¬cÔ2ð/Ü˜3“x�ð ˆ
ùò /øô ò /ÝÚ#&ªð!.ó /ð /ð/ús   Á	C
Â=
C ÃC+c           	      óÈ  ‡ ‡— ˆˆ fd„}t        «       }	 	 t        ‰«      5 }|j                  |‰«       ddd«        |d
|«        |||«       |j                  d«      rit        ‰ d«      r\|j                  d«      D ]G  \  }}	|j!                  d«      d   ‰ j"                  vsŒ'‰ j$                  j'                  |dz   |	z   «       ŒI yyy# 1 sw Y   Œ–xY w# t        $ r-}t	        d|j
                  ›d|j                  ›d‰›�«      ‚d}~wt        t        f$ r t	        d‰z  «      ‚w xY w# t        t        f$ r)}t        d‰›d|j                  d	   ›�«       Y d}~�Œ!d}~ww xY w)zúRead 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
        c                 ór  •— |j                  | «      �r$t        |j                  | «      «      }d|j                  «       v rt	        |j                  d«      «      |d<   ddddœ}t        |«      D ]F  }d|v r$|j                  |«      ||j                  dd«      <   ||v sŒ0|j                  |«      |||   <   ŒH |j                  «       D ]m  \  }}t        |t        «      r|d	k7  r|j                  d
d«      }|‰j                  vrt        d|›d| ›d�«       ŒN‰j                  ||‰«      }t        ‰||«       Œo y y )Nr`   Ú	verbosityÚlabelÚplugoptsÚprofiles)ÚnameÚplugin_optionÚprofileú-Ú_Úkeywordsú r   zUnknown option 'ú' in section 'ú')Úhas_sectionr2   ÚitemsrO   rd   Úpopr
   Úreplacer1   r;   rN   Úprintrp   r%   )ÚsectionÚconfigÚodictÚrename_optsrn   r   Úconfig_filer(   s         €€r   Ú_update_from_sectionz9SoSOptions.update_from_conf.<locals>._update_from_section¾   s>  ø€ Ø×!Ñ! 'Õ*Ü˜VŸ\™\¨'Ó2Ó3�à §
¡
£Ñ,Ü),¨U¯Y©Y°yÓ-AÓ)B�E˜+Ñ&ð
 $Ø%/Ø)ñ�ô
   ›;ò A�CØ˜c‘zØ7<·y±yÀ³~˜˜cŸk™k¨#¨sÓ3Ñ4Ø˜kÒ)Ø27·)±)¸C³.˜˜k¨#Ñ.Ò/ð	Að !&§¡£ò ,‘H�C˜ô " #¤sÔ+°°zÒ0AØ!Ÿk™k¨#¨rÓ2˜Ø $×"3Ñ"3Ñ3õ Ú!$¢gð/ô 0à Ø×/Ñ/°°S¸+ÓF�CÜ˜D # sÕ+ñ,ð' +r   NzDuplicate option 'r~   z
' in file z%Failed to parse configuration file %sz+WARNING: Unable to read configuration file z : é   ÚglobalÚplugin_optionsru   ú.r   rb   )r   ÚopenÚ	read_filer   ÚexitÚoptionr…   r   r   ÚOSErrorÚIOErrorr„   r@   r€   r"   r�   rj   Úskip_pluginsru   rQ   )
r(   r‰   Ú	componentrŠ   r†   ÚfÚerrÚern   r   s
   ``        r   Úupdate_from_confzSoSOptions.update_from_confµ   sb  ù€ õ!	,ôF “ˆð	ð*Ü˜+Ó&ð 5¨!Ø×$Ñ$ Q¨Ô4÷5ñ 	˜X vÔ.Ù˜Y¨Ô/Ø×ÑÐ.Ô/´G¸DÀ*Ô4MØ"ŸL™LÐ)9Ó:ò :‘��SØ—y‘y “~ aÑ(¨D×,=Ñ,=Ò=Ø—M‘M×(Ñ(¨¨s©°S©Õ9ñ:ð 5NÐ/÷!5ð 5ûä'ò EÝØ!Ÿj›j¨#¯+«+±{ðDó Eð Eûä ¤%Ð(ò *ÜÐBØ(ñ)ó *ð *ð*ûô œÐ!ò 	Ýâ §¡ q¢	ð+÷ò ûð	úsE   •C  C³C ÃCÃC Ã	D&Ã(DÄ!D&Ä&D) Ä)E!Ä8EÅE!c                 ó„   — | j                   D ]1  }t        ||«      sŒt        ||«      €|rŒ| j                  ||d«       Œ3 y)aN  Merge another set of ``SoSOptions`` into this object.

            Merge two ``SoSOptions`` objects by setting unset or default
            values to their value in the ``src`` object.

            :param src: the ``SoSOptions`` object to copy from
            :param is_default: ``True`` if new default values are to be set.
        NF)r4   r"   r#   r.   )r(   r*   Úskip_defaultr5   s       r   ÚmergezSoSOptions.mergeù   sC   € ð —>‘>ò 	1ˆCÜ˜3 Ô$ØÜ�s˜CÓ Ð,²LØ—‘  S¨%Õ0ñ		1r   c                 ó^   — i }| j                   D ]  }t        | |«      }|r|dv rd}|||<   Œ |S )z²Return this ``SoSOptions`` option values as a dictionary of
            argument name to value mappings.

            :returns: a name:value dictionary of option values.
        ©Ú
add_presetÚ
del_presetÚdescÚnoteN)r4   r#   )r(   Úpreset_filterr‡   r5   Úvalues        r   r2   zSoSOptions.dict  sI   € ð ˆØ—>‘>ò 	ˆCÜ˜D #Ó&ˆEáØÐFÑFØ �EØˆE�#ŠJð	ð ˆr   c                 óÌ   ‡ ‡— ˆ fd„Šˆfd„}d„ }t        ‰ j                  «       j                  «       d„ ¬«      }|D ��cg c]  \  }} |||«      sŒ |||«      ‘Œ c}}S c c}}w )zðReturn 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"]``

        c                 óŽ   •— d}|r||v ry| dk(  r|ry| ‰j                   v r%t        |«      t        ‰j                   |    «      k(  ryy)z. Test for non-null option values.
            )ÚFalseÚNonez[]z""z''Ú0Fru   T)rN   r;   )rw   r¥   Únull_valuesr(   s      €r   Ú	has_valuez%SoSOptions.to_args.<locals>.has_value!  sU   ø€ ð CˆKÙ˜E [Ñ0ØØ�zÒ!¡eØØ�t×(Ñ(Ñ(Ü�u“:¤ T×%6Ñ%6°tÑ%<Ó!=Ò=Ø Ør   c                 ó4   •— | dv ry| dv r|dk(  ry ‰| |«      S )z8 Filter out preset and null-valued options.
            rŸ   F)Úlog_sizeÚplugin_timeoutÚcmd_timeoutr   Tr    )rw   r¥   r¬   s     €r   Ú
filter_optz&SoSOptions.to_args.<locals>.filter_opt.  s1   ø€ ð ÐCÑCØàÐDÑDØ˜A’:ØÙ˜T 5Ó)Ð)r   c                 óþ   — | j                  d«      rdt        |«      dz  z   }|S | j                  dd«      } t        |«      rdj	                  |«      n|}|dur| ›d|›�}n| }t        |«      dkD  rd	|z   }|S d|z   }|S )
zD Convert sos option notation to command line arguments.
            rs   rz   rC   r{   r8   Tr}   r‹   ra   )Ú
startswithrd   rƒ   r   r:   Úlen)rw   r¥   r5   r)   s       r   Úargifyz"SoSOptions.to_args.<locals>.argify9  sŒ   € ð �‰˜{Ô+ØœC ›J¨Ñ,Ñ,�Ø�
à—<‘<  SÓ)ˆDä'.¨u¤~�C—H‘H˜U”O¸5ˆEà˜DÑ Ú!%¡uÐ-‘à�ä # C£¨1¢�$˜‘*ˆCØˆJð 36¸±)ˆCØˆJr   c                 ó   — | d   S )Nr   r    )Úxs    r   ú<lambda>z$SoSOptions.to_args.<locals>.<lambda>M  s
   € ¸aÀ¹d€ r   )rn   )Úsortedr2   r�   )r(   r±   rµ   Ú	opt_itemsÚnrC   r¬   s   `     @r   Úto_argszSoSOptions.to_args  sV   ù€ ô	ô		*ò	ô( ˜4Ÿ9™9›;×,Ñ,Ó.±NÔCˆ	Ø+4×I¡ ! Q¹
À1ÀaÕ8H‘�q˜!•ÓIÐIùÓIs   ¿A ÁA N)Fr}   r   r   )T)Ú__name__Ú
__module__Ú__qualname__r.   r6   rG   rI   rL   rS   ÚclassmethodrW   rh   rp   rš   r�   r2   r¼   r    r   r   r   r      sl   „ ò8ò02ó8ò2ò&ð %'ó ,ð0 Ø*,ò 
ó ð
ð ñ(ó ð(ò$ò<B:óH1óó 6Jr   r   c                   ó   — e Zd ZdZdd„Zy)ÚSosListOptionz0Allow to specify comma delimited list of pluginsNc                 óÖ   — |j                  d«      D �cg c]  }|‘Œ }}t        || j                  «      r|t        || j                  «      z  }t        || j                  |«       y c c}w )Nr8   )rj   r#   Údestr%   )r(   ÚparserÚ	namespaceÚvaluesÚoption_stringr)   r�   s          r   Ú__call__zSosListOption.__call__U  sV   € Ø &§¡¨SÓ 1Ö2˜’Ð2ˆÐ2Ü�9˜dŸi™iÔ(Ø”W˜Y¨¯	©	Ó2Ñ2ˆEÜ�	˜4Ÿ9™9 eÕ,ùò 3s   ”	A&r0   )r½   r¾   r¿   Ú__doc__rÉ   r    r   r   rÂ   rÂ   Q  s
   „ á:ô-r   rÂ   c                   ó   — e Zd ZdZdd„Zy)ÚClusterOptionz6Used to store/manipulate options for cluster profiles.Nc                 óJ   — || _         || _        || _        || _        || _        y r0   )rw   r¥   Úopt_typeÚclusterÚdescription)r(   rw   r¥   rÎ   rÏ   rÐ   s         r   rS   zClusterOption.__init___  s&   € ØˆŒ	ØˆŒ
Ø ˆŒØˆŒØ&ˆÕr   r0   )r½   r¾   r¿   rÊ   rS   r    r   r   rÌ   rÌ   \  s
   „ Ù@ô'r   rÌ   N)Úargparser   Úconfigparserr   r   r   r   r   r   r   rÂ   rÌ   r    r   r   ú<module>rÓ      sC   ðõ ÷0ó 0ò1ò÷oJñ oJôd	-�Fô -÷'ò 'r   