MOON
Server: Apache
System: Linux server.royaltuning.hu 4.18.0-425.13.1.el8_7.x86_64 #1 SMP Tue Feb 21 04:20:52 EST 2023 x86_64
User: royaltuning (1001)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3.6/site-packages/sos/__pycache__/options.cpython-36.opt-1.pyc
3

G%@i�3�@sXddlmZddlmZdd�Zdd�ZGdd�d�ZGd	d
�d
e�ZGdd�d�Zd
S)�)�Action)�ConfigParsercCst|�}|tkp|tkS)z@Return true if val is an instance of a known sequence type.
    )�type�list�tuple)�valZval_type�r�/usr/lib/python3.6/options.py�_is_seq
sr
cCs$|j�}|d	krdS|d
kr dSdS)N�true�on�yesT�false�off�noF)rrr
)rrr)�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||�}||�r8||�sT|sT||jkrPt|�sT|r�t|||�|rr|jj|�q�|jj|�nt|�r�t||||�dS)NcSs|dkp|dkS)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_optcCs6t|t�st|�}x|jD]}|j||||�qWdS)N)�
isinstance�dict�vars�	arg_namesr!)rrrr �argrrr	�_merge_opts9s
zSoSOptions._merge_optsF� rc	s~|}d}x�jD]}||||7}qW|j|��fdd��jD�}|sZdd�|D�}ndd�|D�}|t|�j|�|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>Nsz$SoSOptions.__str.<locals>.<listcomp>cSs"g|]}t|�rdj|�n|�qS)�,)r
�join)r)�vrrr	r*QscSs&g|]}t|t�rd|�d�n|�qS)�')r"�str)r)r-rrr	r*Ts)r%�stripr)	r�quote�sep�prefix�suffix�argsZarg_fmtr&�valsr)rr	Z__str?s	
zSoSOptions.__strcCs|j�S)N)�_SoSOptions__str)rrrr	�__str__XszSoSOptions.__str__cCs|jddddd�S)NTz, zSoSOptions(�))r1r2r3r4)r7)rrrr	�__repr__[s
zSoSOptions.__repr__cKsp||_t|j��|_t�|_x |jD]}t|||j|�q$Wx,|j�D] \}}|jj|�t|||�qHWdS)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&Zkwargrrr	�__init___s
zSoSOptions.__init__cCs(tft|�d|i��}|j|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}�|krd���gS�|kr@�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).
        �
alloptions�allow-system-changes�all-logs�batch�build�debug�experimental�list-plugins�list-presets�
list-profiles�	no-report�no-env-vars�quiet�verify�verbosez--csg|]}d����qS)z--r)r)�d)rrr	r*�sz+SoSOptions._opt_to_args.<locals>.<listcomp>r�=)rDrErFrGrHrIrJrKrLrMrNrOrPrQ)rR)�range�int)rBrrZno_value�countr)rr	�_opt_to_args�szSoSOptions._opt_to_argscCs�t|j|t|��r|St|j|t�r6t|jd��St|j|t�rpt|�}|dkrltd|�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)	r"r;rr�split�boolr�	ExceptionrV)r�keyrZconfrrr	�_convert_to_type�s
zSoSOptions._convert_to_typec	s���fdd�}t�}y(t�dd��}|j|��WdQRXWn<tk
rx}z td��d|jd���WYdd}~XnX|d	|�|||�|jd
�r�t�d�r�t�d�r�x>|jd
�D]0\}}|j	d
�d�j
kr��jj|d|�q�WdS)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|j|�r�t|j|��}d|j�kr6t|jd��|d<dddd�}xHt|�D]<}d|krn|j|�||jdd�<||krL|j|�|||<qLWxn|j�D]b\}}t|t	�r�|d	kr�|jd
d�}|�j
kr�td|�d
|�d��q��j||��}t
�||�q�WdS)NrR�	verbosityZlabel�plugoptsZprofiles)�nameZ
plugin_optionZprofile�-�_�keywordsr(rzUnknown option 'z' in section 'r.)�has_sectionr#r>r<rV�popr�replacer"r/r;�printr]r)Zsection�config�odictZrename_optsr\r)�config_filerrr	�_update_from_section�s(

z9SoSOptions.update_from_conf.<locals>._update_from_sectionzutf-8)�encodingNz+WARNING: Unable to read configuration file z : ��globalZplugin_optionsr_�skip_plugins�.rrT)
r�openZ	read_file�OSErrorrgr5rdrr>rYror_r?)	rrjZ	componentrkrh�f�er\rr)rjrr	�update_from_conf�s	"*


zSoSOptions.update_from_confTcCsFx@|jD]6}t||�sqt||�dk	s,|r|j||d|d�qWdS)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_defaultr r&rrr	�merge�s


zSoSOptions.mergecCs:i}x0|jD]&}t||�}|r*|dkr*d}|||<qW|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)rwrxryrz)r%r)rZ
preset_filterrir&�valuerrr	r#�s
zSoSOptions.dictcsL�fdd���fdd��dd��t�j�j�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"]``

        csNd
}|s||krdS|dkr&|r&d	S|�jkrJt|�t�j|�krJdSd	S)z. Test for non-null option values.
            �False�None�[]�""�''�0Fr_T)r|r}r~rr�r�)r;r/)r`r{Znull_values)rrr	�	has_values
z%SoSOptions.to_args.<locals>.has_valuecs*|dkrdS|dkr |d	kr d
S�||�S)
z8 Filter out preset and null-valued options.
            rwrxryrzF�log_size�plugin_timeout�cmd_timeoutrT)rwrxryrz)r�r�r�r)r`r{)r�rr	�
filter_opt$sz&SoSOptions.to_args.<locals>.filter_optcSs||jd�rdt|�d}|S|jdd�}t|�r<dj|�n|}|dk	rX|�d|��}n|}t|�dkrpd	|nd|}|S)
zD Convert sos option notation to command line arguments.
            r^rar-rbr+Tr(rmz--)�
startswithrVrfr
r,�len)r`r{r&rrrr	�argify/s
z"SoSOptions.to_args.<locals>.argifycSs|dS)Nrr)�xrrr	�<lambda>Csz$SoSOptions.to_args.<locals>.<lambda>)r\cs$g|]\}}�||�r�||��qSrr)r)�nr-)r�r�rr	r*Dsz&SoSOptions.to_args.<locals>.<listcomp>)�sortedr#r>)rZ	opt_itemsr)r�r�r�rr	�to_argss
	
zSoSOptions.to_argsN)Fr(rr)TF)T)�__name__�
__module__�__qualname__r!r'r7r8r:rA�classmethodrCrXr]rurvr#r�rrrr	rs
>

rc@seZdZdZddd�ZdS)�
SosListOptionz0Allow to specify comma delimited list of pluginsNcCs<t|jd��}t||j�r*|t||j�7}t||j|�dS)Nr+)rrYr�destr)r�parser�	namespace�valuesZ
option_stringr>rrr	�__call__KszSosListOption.__call__)N)r�r�r��__doc__r�rrrr	r�Gsr�c@seZdZdZddd�ZdS)�
ClusterOptionz6Used to store/manipulate options for cluster profiles.NcCs"||_||_||_||_||_dS)N)r`r{�opt_type�cluster�description)rr`r{r�r�r�rrr	rAUs
zClusterOption.__init__)N)r�r�r�r�rArrrr	r�Rsr�N)	�argparserZconfigparserrr
rrr�r�rrrr	�<module>	s	,