
    -_g                          d Z dZddlZddlZddlZddlmZ ddlmZ dZ	dZ
 ej                  e
e	       d ZeZ G d	 d
      Zy)zu
This module houses the i18n setup and message function. The default is to use
gettext to internationalize messages.
z4.8.2    N)ArgumentParser)SosListOptionz/usr/share/localesosc                 6    t        j                  t        |       S N)gettextdgettextgettext_app)msgs    ./usr/lib/python3/dist-packages/sos/__init__.py_defaultr      s    K--    c                   (    e Zd ZdZd Zd Zd Zd Zy)SoSaR  Main entrypoint for sos from the command line

    Upon intialization, this class loads the basic option parser which will
    include the options shared by support components/subcommands. This is also
    where all subcommands present in the local installation are discovered,
    loaded, and if a matching one is found, intialized.
    c                    || _         dd l}dd l}dd l}|j                  j
                  dgf|j                  j                  ddgf|j                  j                  g fd| _
        	 dd l}|j                  j                  dgf| j                  d<   d
}| j                  j+                         D ]H  \  }}|d   }|j-                  d|       dj/                  |      }|d   j0                  }	|d|d|	 dz  }J d}
|
|z   }
d}t3        |
|      | _        | j4                  j7                  ddt8               | j4                  j;                  ddd      | _        d| j<                  _        | j                  j+                         D ]  \  }}| j<                  jA                  ||d   d|       }d| d|_!        |j7                  ddt8               | jE                  |       |d   jG                  |       |jI                  |        | j4                  jK                  | j                         | _&        | jO                          y # t        $ r}dd l}dt!        |j"                        v r&|j$                  j&                  g f| j                  d<   n>d	t!        |j"                        v r&|j$                  j(                  g f| j                  d<   n Y d }~@d }~ww xY w)Nr   repcleanermask)reportcleanhelp	collectorcollectzsos.collectorpexpect    z, 	z<30
z6%(prog)s <component> [options]

Available components:
z1See `sos <component> --help` for more information)usageepilogactionextend	componentzsos component to run)destmetavarr   Tzsos )aliasesprogz
 [options])parser)r#   )(cmdline
sos.reportsos.cleanersos.helpr   	SoSReportr   
SoSCleanerr   	SoSHelper_componentssos.collectorr   SoSCollectorModuleNotFoundErrorsos.missingstrr   missingMissingCollectMissingPexpectitemsinsertjoindescr   r(   registerr   add_subparsers
subparsersrequired
add_parserr   _add_common_optionsadd_parser_optionsset_defaults
parse_argsargs_init_component)selfrF   r   err_com_stringcomvaluer&   _comr<   usage_stringr    comp_com_subparsers                 r   __init__zSoS.__init__/   s    	zz++eW5kk,,y&.ABXX'',
	 +.==+E+E,7=+:DY' **002 	5JCAhGNN1c"99W%D8==Dbc
4&34K	52#k1D$<GXx?++44' 5 

 $(   ++113 
	8KD%!__77aD6] 8 N
 &*$z#:N ##HhF$$^4!H''~'>''$'7
	8 KK**4<<8	_ # 
	#cgg,./2{{/I/I2.N  +c#''l*/2{{/I/I2.N  + 
	s   %*I 	K
A?KKc           	      d   |j                  d      }|j                  dddd       |j                  dt        dd	d
d       |j                  dddd       |j                  dddddd       |j                  dddddd       |j                  ddddd       |j                  dddd d!t        d"#       |j                  d$d%d&d'd(d)       |j                  d*d+d,g d-d./       |j	                         }|j                  d0ddd1       |j                  d2d34       |j                  d5d64       y)7z@Adds the options shared across components to the parser
        zGlobal Optionsz--batchF
store_truezDo not prompt interactively)defaultr!   r   z--config-filestoreconfig_filez/etc/sos/sos.confz$specify alternate configuration file)typer!   r$   rT   r   z--debugdebugz6enable interactive debugging using the python debugger)r!   r$   r   z-qz--quietquietzonly print fatal errors)r!   r$   rT   r   z-sz	--sysrootsysrootNz!system rootdir path (default='/')z	--tmp-dirtmp_dirz%specify alternate temporary directoryz-tz	--threadsthreads   zNumber of threads to use)r!   r$   rT   rW   r   z-vz	--verbosecount	verbosityr   zincrease verbosityz-zz--compression-typecompression_type)autogzipxzzcompression technology to use)r$   choicesr   z	--encryptz_Encrypt the archive, either prompting for a password/key or referencing an environment variablez--encrypt-keyz(Encrypt the archive using a GPG key-pair)r   z--encrypt-passz$Encrypt the archive using a password)add_argument_groupadd_argumentr5   intadd_mutually_exclusive_group)rH   r(   
global_grpencrypt_grps       r   rB   zSoS._add_common_optionsv   s    ../?@
	5%B 	  	Dc'%2(;%K 	  	M 		,W&7 	  	8 	i%,e%> 	  	@ 	k'%.%H 	  	J 	G)(,%L 	  	N 	k'%.%? 	  	A 	k'%0!%9 	  	; 	&:%7(>%D 	  	F !==?  e(4(A 	! 	C
 	  '1 	! 	2 	  !1&L 	! 	Nr   c                    | j                   j                  }|| j                  vrt        d| d       	 | j                  |   d   }|j                  r"t        j                         dk(  st        d       || j                  | j                   | j                        | _
        y# t        $ rH}t        d| d|        | j                   j                  r|t        j                  d       Y d}~yd}~ww xY w)	znDetermine which component has been requested by the user, and then
        initialize that component.
        zUnknown subcommand 'z' specifiedr   z*Component must be run with root privilegeszCould not initialize 'z': r   N)rF   r#   r0   printroot_requiredosgetuid	Exceptionr(   r)   
_componentrX   sysexit)rH   rM   _to_loadrI   s       r   rG   zSoS._init_component   s     yy""t'''(k:;
	''-a0H%%biikQ.> LMM&t{{DIIt||LDO 	*4&C59:yy	HHQKK		s   A-B# #	C4,>C//C4c                 8    | j                   j                          y r   )rq   execute)rH   s    r   rv   zSoS.execute   s    !r   N)__name__
__module____qualname____doc__rQ   rB   rG   rv    r   r   r   r   &   s    EN-N^&"r   r   )rz   __version__rn   rr   r   argparser   sos.optionsr   gettext_dirr
   bindtextdomainr   _sosr   r{   r   r   <module>r      sT     	 
  # %!   {K 0. S" S"r   