HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/usr/lib/python3.9/site-packages/sos/__pycache__/options.cpython-39.opt-1.pyc
a

^��c5�@sdddlmZddlmZmZmZmZdd�Zdd�ZGdd�d�Z	Gd	d
�d
e�Z
Gdd�d�Zd
S)�)�Action)�ConfigParser�ParsingError�Error�DuplicateOptionErrorcCst|�}|tup|tuS)z@Return true if val is an instance of a known sequence type.
    )�type�list�tuple)�valZval_type�r�//usr/lib/python3.9/site-packages/sos/options.py�_is_seqsr
cCs(|��}|dvrdS|dvr dSdSdS)N)�trueZonZyesT)ZfalseZoff�noF)�lower)r
Z_valrrr�str_to_boolsrc@s�eZdZdd�Zdd�Zd dd	�Zd
d�Zdd
�Zifdd�Ze	ifdd��Z
e	dd��Zdd�Zdd�Z
d!dd�Zd"dd�Zdd�ZdS)#�
SoSOptionscCs�dd�}t||�r�t||�}t||�}||�r6||�rL|sL||jvrxt|�sxt|||�|rj|j�|�q�|j�|�nt|�r�t||||�dS)NcSs|dkp|duS)N�r)r
rrr�_unset"sz%SoSOptions._merge_opt.<locals>._unset)�hasattr�getattr�_nondefaultr
�setattr�discard�add)�self�opt�src�
is_defaultrZnewvalueZoldvaluerrr�
_merge_opt!s"


���zSoSOptions._merge_optcCs0t|t�st|�}|jD]}|�|||�qdS�N)�
isinstance�dict�vars�	arg_namesr)rrr�argrrr�_merge_opts9s

zSoSOptions._merge_optsF� rc	sz|}d}�jD]}||||7}q|�|��fdd��jD�}|sVdd�|D�}ndd�|D�}|t|��|�|S)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=%scsg|]}t�|��qSr)r)�.0r%�rrr�
<listcomp>N�z$SoSOptions.__str.<locals>.<listcomp>cSs"g|]}t|�rd�|�n|�qS)�,)r
�join�r(�vrrrr*Qr+cSs"g|]}t|t�rd|n|�qS)z'%s')r!�strr.rrrr*Tr+)r$�stripr	)	r�quote�sep�prefix�suffix�argsZarg_fmtr%Zvalsrr)rZ__str?s	

zSoSOptions.__strcCs|��Sr ��_SoSOptions__strr)rrr�__str__XszSoSOptions.__str__cCs|jddddd�S)NTz, zSoSOptions(�))r2r3r4r5r7r)rrr�__repr__[s
�zSoSOptions.__repr__cKsh||_t|���|_t�|_|jD]}t|||j|�q"|��D] }|j�|�t||||�qBdS)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�keysr$�setrr�append)rr<�kwargsr%rrr�__init___s

zSoSOptions.__init__cCs*tfit|��d|i��}|�|d�|S)aInitialise 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
        r<T)rr#r&)�clsr6r<Zoptsrrr�	from_argsws	zSoSOptions.from_argscsPd}d}�|vrd�gS�|vr>�fdd�tdt|��D�Sd�d|gS)	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).
        )Z
alloptionszallow-system-changeszall-logsZbatchZbuild�debugZexperimentalzlist-pluginszlist-presetsz
list-profilesz	no-reportzno-env-vars�quietZverify)�verbose�--%scsg|]}d��qS)rGr)r(�d�rrrr*�r+z+SoSOptions._opt_to_args.<locals>.<listcomp>r�--�=)�range�int)rBrr
Zno_value�countrrIr�_opt_to_args�s
zSoSOptions._opt_to_argscCs�t|j|t|��r|St|j|t�r<dd�|�d�D�St|j|t�rrt|�}|durntd||f��n|St|j|t�r�z
t|�WSt	y�td||f��Yn0|S)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
        cSsg|]}|�qSrrr.rrrr*�r+z/SoSOptions._convert_to_type.<locals>.<listcomp>r,Nz6Value of '%s' in %s must be True or False or analagousz#Value of '%s' in %s must be integer)
r!r<rr�split�boolr�	ExceptionrM�
ValueError)r�keyr
Zconfrrr�_convert_to_type�s*
��
�zSoSOptions._convert_to_typec

sZ��fdd�}t�}z�z6t���}|�|�Wd�n1s@0YWnZty�}z"td|j|j�f��WYd}~n*d}~0ttfy�td���Yn0Wn>t	t
fy�}z"td�|jdf�WYd}~n
d}~00|d|�|||�|�
d	��rVt�d
��rV|�d	�D]4\}}	|�d�d�jv�r �j�|d
|	��q dS)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
        cs�|�|�r�t|�|��}d|��vr6t|�d��|d<dddd�}t|�D]<}d|vrl|�|�||�dd�<||vrJ|�|�|||<qJ|��D]\\}}t|t	�r�|d	kr�|�d
d�}|�j
vr�td||f�q���||��}t
�||�q�dS)
NrF�	verbosityZlabel�plugoptsZprofiles)�nameZ
plugin_optionZprofile�-�_�keywordsr'rz#Unknown option '%s' in section '%s')�has_sectionr"�itemsr=rM�popr�replacer!r0r<�printrUr)�section�config�odictZrename_optsrTr
��config_filerrr�_update_from_section�s.
�
�z9SoSOptions.update_from_conf.<locals>._update_from_sectionNz0Duplicate option '%s' in section '%s' in file %sz%Failed to parse configuration file %sz2WARNING: Unable to read configuration file %s : %s��globalZplugin_optionsrW�.rrK)r�openZreadfpr�exit�optionrarr�OSError�IOErrorr`r6r\rr]rPZskip_pluginsrWr?)
rreZ	componentrfrb�f�err�erTr
rrdr�update_from_conf�s4	#
,����

zSoSOptions.update_from_confTcCs<|jD]0}t||�sqt||�dus(|s|�||d�qdS)aNMerge 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)r$rrr)rrZskip_defaultr%rrr�merge�s
	

zSoSOptions.mergecCs6i}|jD]&}t||�}|r(|dvr(d}|||<q
|S)z�Return this ``SoSOptions`` option values as a dictionary of
            argument name to value mappings.

            :returns: a name:value dictionary of option values.
        �Z
add_presetZ
del_presetZdescZnoteN)r$r)rZ
preset_filterrcr%�valuerrrr"s


zSoSOptions.dictcsL�fdd���fdd��dd��t�����dd�d	�}��fd
d�|D�S)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"]``

        csLd}|r||vrdS|dkr$|r$dS|�jvrHt|�t�j|�krHdSdS)z. Test for non-null option values.
            )�False�Nonez[]z""z''�0FrWT)r<r0)rXruZnull_valuesr)rr�	has_value!s
z%SoSOptions.to_args.<locals>.has_valuecs*|dvrdS|dvr |dkr dS�||�S)z8 Filter out preset and null-valued options.
            rtF)Zlog_sizeZplugin_timeoutZcmd_timeoutrTr)rXru)ryrr�
filter_opt.s�z&SoSOptions.to_args.<locals>.filter_optcSsz|�d�rdt|�d}|S|�dd�}t|�r<d�|�n|}|durVd||f}n|}t|�dkrnd	|nd|}|S)
zD Convert sos option notation to command line arguments.
            rVrYr/rZr,Tz%s %srgrJ)�
startswithrMr_r
r-�len)rXrur%rrrr�argify9s
z"SoSOptions.to_args.<locals>.argifycSs|dS)Nrr)�xrrr�<lambda>Mr+z$SoSOptions.to_args.<locals>.<lambda>)rTcs$g|]\}}�||�r�||��qSrr)r(�nr/)r}rzrrr*Nr+z&SoSOptions.to_args.<locals>.<listcomp>)�sortedr"r])rZ	opt_itemsr)r}rzryrr�to_argss
	
zSoSOptions.to_argsN)Fr'rr)T)T)�__name__�
__module__�__qualname__rr&r8r9r;rA�classmethodrCrOrUrrrsr"r�rrrrrs

D

rc@seZdZdZddd�ZdS)�
SosListOptionz0Allow to specify comma delimited list of pluginsNcCsBdd�|�d�D�}t||j�r0|t||j�7}t||j|�dS)NcSsg|]}|�qSrr)r(rrrrr*Vr+z*SosListOption.__call__.<locals>.<listcomp>r,)rPr�destr)r�parser�	namespace�values�
option_stringr]rrr�__call__UszSosListOption.__call__)N)r�r�r��__doc__r�rrrrr�Qsr�c@seZdZdZddd�ZdS)�
ClusterOptionz6Used to store/manipulate options for cluster profiles.NcCs"||_||_||_||_||_dSr )rXru�opt_type�cluster�description)rrXrur�r�r�rrrrA_s
zClusterOption.__init__)N)r�r�r�r�rArrrrr�\sr�N)�argparserZconfigparserrrrrr
rrr�r�rrrr�<module>	s
4