
    ~ gk+                         S SK r S SKrS SKrS SKrS SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJrJr   \" \R$                  " 5       R&                  S5      r " S	 S
\	5      r " S S5      rg! \ a    Sr N f = f)    N)OrderedDict)fill)SoSComponent)import_policy)Plugin)boldImporterHelperx   c                      ^  \ rS rSrSrSrSrSrSrSS0r	U 4S jr
\S 5       rS	 rS
 rS rS rS rS rS rS rSrU =r$ )	SoSHelper   z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                 \   > [         TU ]  XU5        U R                  R                  U l        g )N)super__init__optsr   )selfparserargscmdline	__class__s       3/usr/lib/python3/dist-packages/sos/help/__init__.pyr   SoSHelper.__init__+   s!    w/YY__
    c                 \    SUl         UR                  SS5      nUR                  SSSSSS	9  g )
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_optionsSoSHelper.add_parser_options/   sA    1,,&J
 	gw#%/ 	 	1r   c                     U R                   R                  R                  S5      S   nSSSS.nX;   a8  U R                   R                  R                  XU   5      U R                   l        g g )N.r   cleaner	collector)cleanmaskcollect)r   r   splitreplace)r   _com_replaces      r   sanitize_topic_component"SoSHelper.sanitize_topic_component:   s^    yy$$S)!,"

 "iioo55dTNKDIIO r   c                 d   U R                   R                  (       d&  U R                  5         [        R                  " S5        U R                  5          U R                  5       nW(       a-   [        5       nUR                  U5        UR                  5         g [        SU R                   R                   S35        g ! [         aE  n[        SU R                   R                   SU 35        [        R                  " S5         S nANS nAff = f! [         a  n[        SU 35         S nAg S nAff = f)Nr   zCould not load help for 'z':    zError loading help: zNo help section found for '')r   r   display_self_helpsysexitr5   get_obj_for_topic	ExceptionprintHelpSectiondisplay_helpdisplay)r   klasserrhts       r   executeSoSHelper.executeD   s    yy""$HHQK 	%%'	**,E
 4 ]""2&

 /		/@BC  	-diioo->c#GHHHQKK	  4,SE2334s0   B; ++D ;
D
;DD

D/D**D/c           	         SSSSSSSSS	.nS
nU R                   R                  U;   aQ  [        R                  " SU R                   R                  -   5      n[	        X1U R                   R                     5      nU$ U R
                  U R                  U R                  U R                  S.nUR                  5        H9  u  pVU R                   R                  R                  U5      (       d  M1  U" 5       n  U$    U$ )zBased 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	SoSUpload)reportreport.pluginsr,   r-   zcollector.transportszcollector.clusterspoliciesuploadN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items
startswith)r   
static_mapr&   mod_help_secvalues          r   r=   SoSHelper.get_obj_for_topic\   s    
 "&#'$5"+ !	

 99??j())&499??*BCC#$))//:;C 
 $(#;#;!55)-)D)D'+'@'@	E  %{{}99??--d33'C
	  - 
r   c                 r    SSK Jn  U R                  R                  R	                  S5      S   nX!;   a  X   $ g )Nr   )
TRANSPORTSr+   )sos.collector.sosnodere   r   r   r1   )r   re   
_transports      r   rZ    SoSHelper._get_collect_transport}   s4    4YY__**3/3
#))r   c                     SSK Jn  SS KnUR                  UR                  R
                  S5      nU H9  nUS   U R                  R                  R                  S5      S   :X  d  M4  US   s  $    g )Nr   )rK   clustersr+   rf   r8   )	sos.collectorrK   sos.collector.clusters_load_modulesr-   rk   r   r   r1   )r   rK   sosrk   clusters        r   r[   SoSHelper._get_collect_cluster   sd    .%--cmm.D.D.8:GqzTYY__2237;;qz!   r   c                    [         R                  " SU R                  R                  -   5      nU R	                  5         [
        R                  " U[
        R                  5      nU Vs/ s H"  n[        US   [        5      (       d  M  US   PM$     nnU HE  nUR                  5       (       d  M  U R                  R                  UR                  5       5      nUs  $    g s  snf )NrT   r8   )rU   rV   r   r   load_local_policyinspect
getmembersisclass
issubclassr   __subclasses__policymatch_plugin)r   r_   memsmpluginspluginr&   s          r   rX   SoSHelper._get_plugin_variant   s    %%ftyy&>? !!#w7!%BAAaD&)A41Q4BF$$&&kk..v/D/D/FG
   Cs   'C	Cc                 V   U R                   R                  R                  S5      S   nSS Kn[	        UR
                  R                  5      nUR                  5        HJ  n[        U5       H8  nUR                  R                  5       R                  SS5      nXa:X  d  M4  Us  s  $    ML     g )Nr+   rf   r   ry   r   )r   r   r1   sos.policies.distrosr	   rR   distrosget_modulesr   __name__lowerr2   )r   _topicro   _helperr_   ry   _ps          r   rY   SoSHelper._get_policy_by_name   s    &&s+B/ 	$ !5!56&&(C',__**,44XrB<!M - )
 r   c                    [        SS5      nUR                  S[        S5       S35        UR                  S5      n[        S5      nUR                  SU S	35        [        S
5      nUR                  SU S35        UR                  S5      nUR                  S5        SSSSSSSS.nUR	                  5        H$  u  pxUR                  S[        U5      S U 3SS9  M&     UR                  5         g)zXDisplays the help information for this component directly, that is
help for `sos help`.
zDetailed help for sos helpzThe '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.zSoS - 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.zHow to search using sos helpz$component.$topic.$subtopicz8To get more information on a given topic, use the form 'z'.zsos help report.plugins.kernelzFor example 'zM' will provide more information on the kernel plugin for the report function.zAvailable Help SectionszThe 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#Detailed help on the upload commandz+How sos operates on different distributions)rP   rQ   zreport.plugins.$pluginr.   r0   rS   rR   	z<36F)newlineN)r@   add_textr   add_sectionr\   rB   )	r   	self_helpsubsectr#   rep_ex
avail_helpsectionssectrb   s	            r   r:   SoSHelper.display_self_help   s9     (J
	 	& '+<&8%9 :JJ	
 ''(FG23s	

 67= 1% % 	& **+DE
	
 >G&I<>;E
 $>>+KD"T$Z$4UG <eL , 	r   )r   )r   
__module____qualname____firstlineno____doc__descconfigure_loggingload_policy
load_probearg_defaultsr   classmethodr(   r5   rF   r=   rZ   r[   rX   rY   r:   __static_attributes____classcell__)r   s   @r   r   r      sv     &DKJ 	L% 1 1LD0B	3 3r   r   c                   L    \ rS rSrSrSS jrS rSS jrSS jrSS jr	S r
S	rg
)r@      z}This class is used to build the output displayed by `sos help` in a
standard fashion that provides easy formatting controls.
c                 F    Xl         X l        X0l        [        5       U l        g)aK  
: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   HelpSection.__init__   s     
#r   c                     Xl         g)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_titleHelpSection.set_title   s	     
r   c                 n    U R                   (       a  U(       a  SOSnX1-   nU =R                   U-  sl         g)zAdd 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   HelpSection.add_text   s)     <<"BlGr   c                 D    U R                  XU5        U R                  U   $ )a  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   HelpSection.add_section  s#    $ 	%&1}}U##r   c                 j    XR                   ;   a  [        S5      e[        XU5      U R                   U'   g)zInternal 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       r   r   HelpSection._add_section  s/     MM!FGG*56Ber   c           	      j   [        [        [        U R                  5      [        U R
                  S95        U R                  R                  5        H%  n[        [        U[        U R
                  S95        M'     U R                   H+  n[        S5        U R                  U   R                  5         M-     g)zGPrint the HelpSection contents, including any subsections, to
console.
)widthinitial_indentr   N)
r?   r   r   r   TERMSIZEr   r   
splitlinesr   rB   )r   r   sections      r   rB   HelpSection.display&  s     	dHT[[
 	 ,,))+B$r$++FG ,}}G"IMM'"**, %r   )r   r   r   r   N)r   r   r   )T)r   r   )r   r   r   r   r   r   r   r   r   r   rB   r    r   r   r@   r@      s&    &$
 $*C-r   r@   )rt   rU   r;   oscollectionsr   textwrapr   sos.componentr   sos.policiesr   sos.report.pluginsr   sos.utilitiesr   r	   minget_terminal_sizecolumnsr   r>   r   r@   r   r   r   <module>r      sw      
 	 #  & & % .2'')1137H
| |~U- U-G  Hs   "A0 0A;:A;