Ë
    i©¹dï*  ã                   óú   — d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZmZ d dlmZ 	  e ej$                  «       j&                  d«      Z G d	„ d
e«      Z G d„ d«      Zy# e$ r dZY Œw xY w)é    N)ÚOrderedDict)ÚSoSComponent)Úimport_policy)ÚPlugin)ÚboldÚImporterHelper)Úfilléx   c                   óz   ‡ — e Zd ZdZdZdZdZdZddiZˆ fd„Z	e
d„ «       Zd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zˆ xZS )Ú	SoSHelperz‡Provide better, more in-depth help for specific parts of sos than is
    provided in either standard --help output or in manpages.
    zDetailed help infomationFÚtopicÚ c                 óf   •— t         t        | �  |||«       | j                  j                  | _        y )N)Úsuperr   Ú__init__Úoptsr   )ÚselfÚparserÚargsÚcmdlineÚ	__class__s       €ú3/usr/lib/python3/dist-packages/sos/help/__init__.pyr   zSoSHelper.__init__+   s%   ø€ ÜŒi˜Ñ'¨°°gÔ>Ø—Y‘Y—_‘_ˆ�
ó    c                 ób   — d|_         |j                  dd«      }|j                  ddddd¬	«       y )
Nzsos help TOPIC [options]zHelp 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_optionszSoSHelper.add_parser_options/   sA   € à1ˆŒØ×,Ñ,Ø&ØJó
ˆð 	×Ñ˜g¨wÀÈ#ð%/ð 	õ 	1r   c                 óÚ   — | j                   j                  j                  d«      d   }ddddœ}||v r9| j                   j                  j                  |||   «      | j                   _        y y )Nú.r   ÚcleanerÚ	collector)ÚcleanÚmaskÚcollect)r   r   Ú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ð r   c                 óF  — | j                   j                  s%| j                  «        t        j                  d«       | j                  «        	 | j                  «       }r-	 t        «       }|j                  |«       |j                  «        y t        d| j                   j                  z  «       y # t        $ rD}t        d| j                   j                  ›d|›�«       t        j                  d«       Y d }~Œšd }~ww xY w# t        $ r}t        d|z  «       Y d }~y d }~ww xY w)Nr   zCould not load help for 'z': é   zError loading help: %szNo help section found for '%s')r   r   Údisplay_self_helpÚsysÚexitr2   Úget_obj_for_topicÚ	ExceptionÚprintÚHelpSectionÚdisplay_helpÚdisplay)r   ÚklassÚerrÚhts       r   ÚexecutezSoSHelper.executeD   sÛ   € Ø�y‰y�ŠØ×"Ñ"Ô$Ü�H‰H�QŒKð 	×%Ñ%Ô'ð	Ø×*Ñ*Ó,ˆEñ
 ð6Ü “]�Ø×"Ñ" 2Ô&Ø—
‘
•ô Ð2°T·Y±Y·_±_ÑDÕEøô ò 	Ý¸¿	¹	¿»ÉÐMÔNÜ�H‰H�Q�K‰Kûð	ûô ò 6ÜÐ.°Ñ4×5Ñ5ûð6ús0   ÁB/ Á +C? Â/	C<Â8:C7Ã7C<Ã?	D ÄDÄD c                 óÀ  — ddddddddœ}d	}| j                   j                  |v rQt        j                  d
| j                   j                  z   «      }t	        ||| j                   j                     «      }|S | j
                  | j                  | j                  | j                  dœ}|D ]4  }| j                   j                  j                  |«      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*   zcollector.transportszcollector.clustersÚpoliciesNúsos.)zreport.plugins.z	policies.zcollector.transports.zcollector.clusters.)
r   r   Ú	importlibÚimport_moduleÚgetattrÚ_get_plugin_variantÚ_get_policy_by_nameÚ_get_collect_transportÚ_get_collect_clusterÚ
startswith)r   Ú
static_mapr$   ÚmodÚ_helpÚ_secs         r   r8   zSoSHelper.get_obj_for_topic\   sä   € ð
 "Ø&Ø#Ø'Ø$5Ø"+Ø ñ
ˆ
ð ˆà�9‰9�?‰?˜jÑ(Ü×)Ñ)¨&°4·9±9·?±?Ñ*BÓCˆCÜ˜#˜z¨$¯)©)¯/©/Ñ:Ó;ˆCð ˆ
ð $(×#;Ñ#;Ø!×5Ñ5Ø)-×)DÑ)DØ'+×'@Ñ'@ñ	ˆEð ò �Ø—9‘9—?‘?×-Ñ-¨dÕ3Ø%˜% ™+›-�CØØˆ
ð	ð ˆ
r   c                 ór   — ddl m} | j                  j                  j	                  d«      d   }||v r||   S y )Nr   )Ú
TRANSPORTSr(   éÿÿÿÿ)Úsos.collector.sosnoderZ   r   r   r.   )r   rZ   Ú
_transports      r   rR   z SoSHelper._get_collect_transport|   s:   € Ý4Ø—Y‘Y—_‘_×*Ñ*¨3Ó/°Ñ3ˆ
Ø˜Ñ#Ø˜jÑ)Ð)ð $r   c                 óÜ   — ddl m} dd l}|j                  |j                  j
                  d«      }|D ]7  }|d   | j                  j                  j                  d«      d   k(  sŒ2|d   c S  y )Nr   )rE   Úclustersr(   r[   r4   )	Úsos.collectorrE   Úsos.collector.clustersÚ_load_modulesr*   r_   r   r   r.   )r   rE   Úsosr_   Úclusters        r   rS   zSoSHelper._get_collect_cluster‚   sd   € Ý.Û%Ø×-Ñ-¨c¯m©m×.DÑ.DØ.8ó:ˆàò 	"ˆGØ�q‰z˜TŸY™YŸ_™_×2Ñ2°3Ó7¸Ñ;Ó;Ø˜q‘zÒ!ñ	"r   c                 ó¢  — t        j                  d| j                  j                  z   «      }| j	                  «        t        j                  |t
        j                  «      }|D �cg c]  }t        |d   t        «      sŒ|d   ‘Œ }}|D ]?  }|j                  «       sŒ| j                  j                  |j                  «       «      }|c S  y c c}w )NrL   r4   )rM   rN   r   r   Úload_local_policyÚinspectÚ
getmembersÚisclassÚ
issubclassr   Ú__subclasses__ÚpolicyÚmatch_plugin)r   rV   ÚmemsÚmÚpluginsÚpluginr$   s          r   rP   zSoSHelper._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�Ø’
ñ	ùò Cs   Á%CÁ>Cc                 óN  — | j                   j                  j                  d«      d   }dd l}t	        |j
                  j                  «      }|j                  «       D ]G  }t        |«      D ]7  }|j                  j                  «       j                  dd«      }||k(  sŒ3|c c S  ŒI y )Nr(   r[   r   rl   r   )r   r   r.   Úsos.policies.distrosr   rK   ÚdistrosÚget_modulesr   Ú__name__Úlowerr/   )r   Ú_topicrc   Ú_helperrV   rl   Ú_ps          r   rQ   zSoSHelper._get_policy_by_name•   s�   € Ø—‘—‘×&Ñ& sÓ+¨BÑ/ˆó 	$Ü  §¡×!5Ñ!5Ó6ˆØ×&Ñ&Ó(ò 	"ˆCÜ'¨Ó,ò "�Ø—_‘_×*Ñ*Ó,×4Ñ4°X¸rÓB�Ø˜“<Ø!”Mñ"ñ	"r   c                 óÖ  — t        dd«      }|j                  dt        d«      z  «       |j                  d«      }t        d«      }|j                  d|z  «       t        d«      }|j                  d	|z  «       |j                  d
«      }|j                  d«       dddddddœ}|D ]1  }|j                  dj	                  t        |«      ||   «      d¬«       Œ3 |j                  «        y)zhDisplays the help information for this component directly, that is
        help for `sos help`.
        zDetailed 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.ah  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 %s (formerly sosreport) which is used to collect troubleshooting information into an archive for review by sysadmins or technical support teams.z
sos reportzHow to search using sos helpz$component.$topic.$subtopicz<To get more information on a given topic, use the form '%s'.zsos help report.plugins.kernelz\For example '%s' will provide more information on the kernel plugin for the report function.zAvailable 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)rI   rJ   zreport.plugins.$pluginr+   r-   rK   z		{:<36}{}F)ÚnewlineN)r;   Úadd_textr   Úadd_sectionÚformatr=   )r   Ú	self_helpÚsubsectr!   Úrep_exÚ
avail_helpÚsectionsÚsects           r   r5   zSoSHelper.display_self_help¡   s+  € ô  Ø(ðJó
ˆ	ð 	×Ñð7ô �<Ó ñ!ô	
ð ×'Ñ'Ð(FÓGˆÜÐ2Ó3ˆØ×ÑØLØñô	
ô
 Ð6Ó7ˆØ×Ñð FØHNñOô 	Pð ×*Ñ*Ð+DÓEˆ
Ø×Ñðô	
ð >ØGØ&IØ<Ø>ØEñ
ˆð ò 	ˆDØ×ÑØ×#Ñ#¤D¨£J°¸±Ó?Øð  õ ð	ð 	×ÑÕr   )rv   Ú
__module__Ú__qualname__Ú__doc__ÚdescÚconfigure_loggingÚload_policyÚ
load_probeÚarg_defaultsr   Úclassmethodr&   r2   rA   r8   rR   rS   rP   rQ   r5   Ú__classcell__)r   s   @r   r   r      sq   ø„ ñð &€DØÐØ€KØ€Jð 	�ð€Lô%ð ñ1ó ð1òLòFò0ò@*ò"òò
"ö5r   r   c                   ó<   — e Zd ZdZd	d„Zd„ Zd
d„Zdd„Zdd„Zd„ 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Úindentr   r„   ©r   r’   r“   r”   s       r   r   zHelpSection.__init__Þ   s"   € ð ˆŒ
ØˆŒØˆŒÜ#›ˆ�r   c                 ó   — || _         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’   )r   r’   s     r   Ú	set_titlezHelpSection.set_titleð   s   € ð ˆ�
r   c                 ó\   — | j                   r|rdnd}||z   }| xj                   |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“   )r   r“   r|   Úlns       r   r}   zHelpSection.add_textø   s+   € ð �<Š<Ù"‘¨ˆBØ˜7‘lˆGØ�Š˜ÑŽr   c                 óF   — | j                  |||«       | j                  |   S )ac  Add 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       r   r~   zHelpSection.add_section  s%   € ð$ 	×Ñ˜% ¨&Ô1Ø�}‰}˜UÑ#Ð#r   c                 ój   — || j                   v rt        d«      ‚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„   r9   r;   r•   s       r   rœ   zHelpSection._add_section  s3   € ð �D—M‘MÑ!ÜÐFÓGÐGÜ*¨5°'¸6ÓBˆ�‰�eÒr   c                 ón  — t        t        t        | j                  «      t        | j
                  ¬«      «       | j                  j                  «       D ]'  }t        t        |t        | j
                  ¬«      «       Œ) | j                  D ]*  }t        d«       | j                  |   j                  «        Œ, y)zWPrint the HelpSection contents, including any subsections, to
        console.
        )ÚwidthÚinitial_indentr   N)
r:   r	   r   r’   ÚTERMSIZEr”   r“   Ú
splitlinesr„   r=   )r   rš   Úsections      r   r=   zHelpSection.display#  s‹   € ô 	ŒdÜ�—‘Ó¤H¸T¿[¹[ô
ô 	ð —,‘,×)Ñ)Ó+ò 	HˆBÜ”$�r¤¸$¿+¹+ÔFÕGð	Hà—}‘}ò 	-ˆGÜ�"ŒIØ�M‰M˜'Ñ"×*Ñ*Õ,ñ	-r   N)r   r   r   )T)r   r   )
rv   r†   r‡   rˆ   r   r—   r}   r~   rœ   r=   © r   r   r;   r;   Ù   s&   „ ñó&ò$ó
 ó$ó*Có-r   r;   )rg   rM   r6   ÚosÚcollectionsr   Úsos.componentr   Úsos.policiesr   Úsos.report.pluginsr   Úsos.utilitiesr   r   Útextwrapr	   ÚminÚget_terminal_sizeÚcolumnsr¡   r9   r   r;   r¤   r   r   ú<module>r¯      sz   ðó Û Û 
Û 	å #Ý &Ý &Ý %ß .Ý ðÙÐ'�2×'Ñ'Ó)×1Ñ1°3Ó7€Hô
y�ô y÷xU-ò U-øðA ò Ø‚Hðús   ¸"A0 Á0A:Á9A: