Current File : //usr/lib/python3/dist-packages/sos/help/__pycache__/__init__.cpython-312.pyc
�

-�_g
+���ddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZmZ	eej$�j&d�ZGd	�d
e	�ZGd�d�Zy#e$rdZY�wxYw)
�N)�OrderedDict)�fill)�SoSComponent)�
import_policy)�Plugin)�bold�ImporterHelper�xc�z��eZdZdZdZdZdZdZddiZ�fd�Z	e
d��Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Z�xZS)�	SoSHelperz�Provide better, more in-depth help for specific parts of sos than is
    provided in either standard --help output or in manpages.
    zDetailed help infomationF�topic�c�^��t�|�|||�|jj|_y)N)�super�__init__�optsr
)�self�parser�args�cmdline�	__class__s    ��3/usr/lib/python3/dist-packages/sos/help/__init__.pyrzSoSHelper.__init__+s#���
�����w�/��Y�Y�_�_��
�c�b�d|_|jdd�}|jddddd�	�y)
Nzsos help TOPIC [options]zHelp Information Optionsz<These options control what detailed information is displayedr
�TOPICr�?z/name of the topic or component to show help for)�metavar�default�nargs�help)�usage�add_argument_group�add_argument)�clsr�help_grps   r�add_parser_optionszSoSHelper.add_parser_options/sA��1����,�,�&�J�
��	���g�w��#�%/�	�	1rc���|jjjd�d}dddd�}||vr9|jjj|||�|j_yy)N�.r�cleaner�	collector)�clean�mask�collect)rr
�split�replace)r�_com�_replaces   r�sanitize_topic_componentz"SoSHelper.sanitize_topic_component:sb���y�y���$�$�S�)�!�,����"�
��
�8��"�i�i�o�o�5�5�d�H�T�N�K�D�I�I�O�rc�H�|jjs%|j�tjd�|j�	|j
�}r-	t�}|j|�|j�ytd|jj�d��y#t$rD}td|jj�d|���tjd�Yd}~��d}~wwxYw#t$r}td|���Yd}~yd}~wwxYw)NrzCould not load help for 'z': �zError loading help: zNo help section found for '�')rr
�display_self_help�sys�exitr2�get_obj_for_topic�	Exception�print�HelpSection�display_help�display)r�klass�err�hts    r�executezSoSHelper.executeDs����y�y����"�"�$��H�H�Q�K�	
�%�%�'�	��*�*�,�E�
�
4� �]���"�"�2�&��
�
��
�/��	�	���/@��B�C���	��-�d�i�i�o�o�->�c�#��G�H��H�H�Q�K�K��	���
4��,�S�E�2�3�3��
4�s0�
B0� +D�0	C=�9:C8�8C=�	D!�	D�D!c���dddddddd�}d	}|jj|vrQtjd
|jjz�}t	|||jj�}|S|j
|j|j|jd�}|j�D]4\}}|jjj|�s�,|�}|S|S)z�Based on the help topic we're after, try to smartly decide which
        object we need to manipulate in order to get help information.
        �	SoSReportr�
SoSCleaner�SoSCollector�RemoteTransport�Cluster�Policy)�report�report.pluginsr)r*zcollector.transportszcollector.clusters�policiesN�sos.)zreport.plugins.z	policies.zcollector.transports.zcollector.clusters.)rr
�	importlib�
import_module�getattr�_get_plugin_variant�_get_policy_by_name�_get_collect_transport�_get_collect_cluster�items�
startswith)r�
static_mapr$�mod�_help�_sec�values       rr9zSoSHelper.get_obj_for_topic\s���
"�&�#�'�$5�"+� �
�
����9�9�?�?�j�(��)�)�&�4�9�9�?�?�*B�C�C��#�z�$�)�)�/�/�:�;�C��
�$(�#;�#;�!�5�5�)-�)D�)D�'+�'@�'@�	�E� %�{�{�}�
���e��9�9�?�?�-�-�d�3��'�C���
�	
��
rc�r�ddlm}|jjj	d�d}||vr||Sy)Nr)�
TRANSPORTSr(���)�sos.collector.sosnoder]rr
r.)rr]�
_transports   rrSz SoSHelper._get_collect_transport|s8��4��Y�Y�_�_�*�*�3�/��3�
���#��j�)�)�rc���ddlm}ddl}|j|jj
d�}|D]7}|d|jjjd�dk(s�2|dcSy)Nr)rF�clustersr(r^r4)	�
sos.collectorrF�sos.collector.clusters�
_load_modulesr*rbrr
r.)rrF�sosrb�clusters     rrTzSoSHelper._get_collect_cluster�si��.�%��-�-�c�m�m�.D�.D�.8�:���	"�G��q�z�T�Y�Y�_�_�2�2�3�7��;�;��q�z�!�	"�rc��tjd|jjz�}|j	�tj|t
j�}|D�cgc]}t|dt�s�|d��}}|D]?}|j�s�|jj|j��}|cSycc}w)NrMr4)
rNrOrr
�load_local_policy�inspect�
getmembers�isclass�
issubclassr�__subclasses__�policy�match_plugin)rrX�mems�m�plugins�pluginr$s       rrQzSoSHelper._get_plugin_variant�s����%�%�f�t�y�y���&>�?����� ��!�!�#�w���7��!%�B�A��A�a�D�&�)A�1�Q�4�B��B��	�F��$�$�&��k�k�.�.�v�/D�/D�/F�G���
�	���Cs�%C�>Cc�N�|jjjd�d}ddl}t	|j
j�}|j�D]G}t|�D]7}|jj�jdd�}||k(s�3|ccS�Iy)Nr(r^rror)rr
r.�sos.policies.distrosr	rL�distros�get_modulesr�__name__�lowerr/)r�_topicrf�_helperrXro�_ps       rrRzSoSHelper._get_policy_by_name�s��������&�&�s�+�B�/��	$� ����!5�!5�6���&�&�(�	"�C�'��,�
"���_�_�*�*�,�4�4�X�r�B����<�!�M�
"�	"�
rc���tdd�}|jdtd��d��|jd�}td�}|jd|�d	��td
�}|jd|�d��|jd
�}|jd�ddddddd�}|j	�D]'\}}|jdt|�d�|��d���)|j�y)zhDisplays the help information for this component directly, that is
        help for `sos help`.
        zDetailed help for sos helpz�The 'help' sub-command is used to provide more detailed information on different sub-commands available to sos as well as different components at play within those sub-commands.z�SoS - officially pronounced "ess-oh-ess" - is a diagnostic and supportability utility used by several Linux distributions as an easy-to-use tool for standardized data collection. The most known component of which is z
sos reportz� (formerly sosreport) which is used to collect troubleshooting information into an archive for review by sysadmins or technical support teams.zHow to search using sos helpz$component.$topic.$subtopicz8To get more information on a given topic, use the form 'z'.zsos help report.plugins.kernelz
For example 'zM' will provide more information on the kernel plugin for the report function.zAvailable Help Sectionsz�The following help sections are available. Additional help topics and subtopics may be displayed within their respective help section.
z#Detailed help on the report commandz'Information on the plugin design of sosz!Information on a specific $pluginz"Detailed help on the clean commandz$Detailed help on the collect commandz+How sos operates on different distributions)rJrKzreport.plugins.$pluginr+r-rL�	z<36F)�newlineN)r<�add_textr�add_sectionrUr>)	r�	self_help�subsectr!�rep_ex�
avail_help�sections�sectr[s	         rr6zSoSHelper.display_self_help�s?�� �(�J�
�	�	���
&�'+�<�&8�%9�:J�
J�	
��'�'�(F�G���2�3�����
���s�
�	
�
�6�7�����=���1%�%�	&��*�*�+D�E�
����
�	
�>�G�&I�<�>�E�

��$�>�>�+�	M�K�D�%����"�T�$�Z��$4�U�G� <�e��L�	M�	���r)ry�
__module__�__qualname__�__doc__�desc�configure_logging�load_policy�
load_probe�arg_defaultsr�classmethodr&r2rBr9rSrTrQrRr6�
__classcell__)rs@rrrsq����&�D����K��J�	���L�%��1��1�L�D�0�@��	��2rrc�<�eZdZdZd	d�Zd�Zd
d�Zdd�Zdd�Zd�Z	y)r<z�This class is used to build the output displayed by `sos help` in a
    standard fashion that provides easy formatting controls.
    c�L�||_||_||_t�|_y)a�
        :param title:   The title of the output section, will be prominently
                        displayed
        :type title:    ``str``

        :param content: The text content to be displayed with this section
        :type content:  ``str``

        :param indent:  If the section should be nested, set this to a multiple
                        of 4.
        :type indent:   ``int``
        N)�title�content�indentrr��rr�r�r�s    rrzHelpSection.__init__�s"����
�������#�
��
rc��||_y)z�Set or override the title for this help section

        :param title:   The name to set for this help section
        :type title:    ``str``
        N)r�)rr�s  r�	set_titlezHelpSection.set_title�s����
rc�\�|jr|rdnd}||z}|xj|z
c_y)z�Add body text to this section. If content for this section already
        exists, append the new ``content`` after a newline.

        :param content:     The text to add to the section
        :type content:      ``str``
        z

�
N)r�)rr�r��lns    rr�zHelpSection.add_text�s+���<�<�"���B��7�l�G������rc�F�|j|||�|j|S)acAdd a section of text to the help section that will be displayed
        when the HelpSection object is printed.

        Sections will be printed *in the order added*.

        This will return a subsection object with which block(s) of text may be
        added to the subsection associated with ``title``.

        :param title:   The title of the subsection being added
        :type title:    ``str``

        :param content: The text the new section should contain
        :type content:  ``str``

        :returns:   The newly created subsection for ``title``
        :rtype:     ``HelpSection``
        )�_add_sectionr�r�s    rr�zHelpSection.add_sections%��$	
���%��&�1��}�}�U�#�#rc�j�||jvrtd��t|||�|j|<y)z�Internal method used to add a new subsection to this help output

        :param title:   The title of the subsection being added
        :type title:    ``str`
        z(A section with that title already existsN)r�r:r<r�s    rr�zHelpSection._add_sections3���D�M�M�!��F�G�G�*�5�'�6�B��
�
�e�rc�n�ttt|j�t|j
���|jj�D]'}tt|t|j
����)|jD]*}td�|j|j��,y)zWPrint the HelpSection contents, including any subsections, to
        console.
        )�width�initial_indentrN)
r;rrr��TERMSIZEr�r��
splitlinesr�r>)rr��sections   rr>zHelpSection.display$s���	�d������H�T�[�[�
�	��,�,�)�)�+�	H�B��$�r��$�+�+�F�G�	H��}�}�	-�G��"�I��M�M�'�"�*�*�,�	-rN)rrr)T)rr)
ryr�r�r�rr�r�r�r�r>�rrr<r<�s&���&�$�
 �$�*C�-rr<)rjrNr7�os�collectionsr�textwrapr�
sos.componentr�sos.policiesr�sos.report.pluginsr�
sos.utilitiesrr	�min�get_terminal_size�columnsr�r:rr<r�rr�<module>r�sz����
�	�#��&�&�%�.���'�2�'�'�)�1�1�3�7�H�
z��z�zU-�U-��C���H��s�"A0�0A:�9A: