HEX
Server: Apache
System: Linux server.instantlogomakers.com 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: s2spw (1156)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3.9/site-packages/sos/__pycache__/options.cpython-39.opt-1.pyc
a

G%@i�3�@sXddlmZddlmZdd�Zdd�ZGdd�d�ZGd	d
�d
e�ZGdd�d�Zd
S)�)�Action)�ConfigParsercCst|�}|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_seq
sr
cCs$|��}|dvrdS|dvr dSdS)N)�trueZonZyesT)ZfalseZoff�noF)�lower)rZ_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||�rP|sP||jvrLt|�rP|r|t|||�|rn|j�|�q�|j�|�nt|�r�t||||�dS)NcSs|dkp|duS)N�r)rrrr	�_unset sz%SoSOptions._merge_opt.<locals>._unset)�hasattr�getattr�_nondefaultr
�setattr�discard�add)�self�opt�src�
is_default�
prefer_newrZnewvalueZoldvaluerrr	�
_merge_opts&


����zSoSOptions._merge_optcCs2t|t�st|�}|jD]}|�||||�qdS�N)�
isinstance�dict�vars�	arg_namesr)rrrr�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|�d�n|�qS)�')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(�))r1r2r3r4r6r'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�items�append)rr;�kwargsr#�kwargrrr	�__init___s

zSoSOptions.__init__cCs,tfit|��d|i��}|�|dd�|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;TF)rr!r$)�clsr5r;Zoptsrrr	�	from_argsws	zSoSOptions.from_argscsRd}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�--csg|]}d����qS)rHr)r&�d�rrr	r(�r)z+SoSOptions._opt_to_args.<locals>.<listcomp>r�=)�range�int)rCrrZno_value�countrrJr	�_opt_to_args�szSoSOptions._opt_to_argscCs�t|j|t|��r|St|j|t�r6t|�d��St|j|t�rpt|�}|durltd|�d|�d���|St|j|t�r�t|�S|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
        r*Nz
Value of 'z' in z# must be True or False or analagous)	rr;rr�split�boolr�	ExceptionrM)r�keyrZconfrrr	�_convert_to_type�s
�zSoSOptions._convert_to_typec	
s��fdd�}t�}z<t�dd��}|�|��Wd�n1sD0YWn>ty�}z&td��d|jd���WYd}~n
d}~00|d	|�|||�|�d
�r�t�d�r�t�d�r�|�d
�D]0\}}|�	d
�d�j
vr̈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]b\}}t|t	�r�|d	kr�|�d
d�}|�j
vr�td|�d
|�d��q���||��}t
�||�q�dS)NrG�	verbosityZlabel�plugoptsZprofiles)�nameZ
plugin_optionZprofile�-�_�keywordsr%rzUnknown option 'z' in section 'r.)�has_sectionr r>r<rM�popr�replacerr/r;�printrTr)�section�config�odictZrename_optsrSr��config_filerrr	�_update_from_section�s*
�
z9SoSOptions.update_from_conf.<locals>._update_from_sectionzutf-8)�encodingNz+WARNING: Unable to read configuration file z : ��globalZplugin_optionsrV�skip_plugins�.rrK)
r�openZ	read_file�OSErrorr^r5r[rr>rPrhrVr?)	rrcZ	componentrdr`�f�erSrrrbr	�update_from_conf�s&	".��

�zSoSOptions.update_from_confTcCs@|jD]4}t||�sqt||�dus(|s|j||d|d�qdS)a�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.
            :param prefer_new: ``False`` if new default is not preferred.
        NF)r)r"rrr)rrZskip_defaultrr#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_filterrar#�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 ``sos report`` 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''�0FrVT)r;r/)rWrqZnull_valuesr'rr	�	has_values
z%SoSOptions.to_args.<locals>.has_valuecs*|dvrdS|dvr |dkr dS�||�S)z8 Filter out preset and null-valued options.
            rpF)Zlog_sizeZplugin_timeoutZcmd_timeoutrTr)rWrq)rurr	�
filter_opt$s�z&SoSOptions.to_args.<locals>.filter_optcSs||�d�rdt|�d}|S|�dd�}t|�r<d�|�n|}|durX|�d|��}n|}t|�dkrpd	|nd|}|S)
zD Convert sos option notation to command line arguments.
            rUrXr-rYr*Tr%rfrH)�
startswithrMr]r
r+�len)rWrqr#rrrr	�argify/s
z"SoSOptions.to_args.<locals>.argifycSs|dS)Nrr)�xrrr	�<lambda>Cr)z$SoSOptions.to_args.<locals>.<lambda>)rScs$g|]\}}�||�r�||��qSrr)r&�nr-)ryrvrr	r(Dr)z&SoSOptions.to_args.<locals>.<listcomp>)�sortedr r>)rZ	opt_itemsr)ryrvrurr	�to_argss
	
zSoSOptions.to_argsN)Fr%rr)TF)T)�__name__�
__module__�__qualname__rr$r7r8r:rB�classmethodrDrOrTrnror r~rrrr	rs

>

rc@seZdZdZddd�ZdS)�
SosListOptionz0Allow to specify comma delimited list of pluginsNcCs<t|�d��}t||j�r*|t||j�7}t||j|�dS)Nr*)rrPr�destr)r�parser�	namespace�values�
option_stringr>rrr	�__call__KszSosListOption.__call__)N)rr�r��__doc__r�rrrr	r�Gsr�c@seZdZdZddd�ZdS)�
ClusterOptionz6Used to store/manipulate options for cluster profiles.NcCs"||_||_||_||_||_dSr)rWrq�opt_type�cluster�description)rrWrqr�r�r�rrr	rBUs
zClusterOption.__init__)N)rr�r�r�rBrrrr	r�Rsr�N)	�argparserZconfigparserrr
rrr�r�rrrr	�<module>	s	,