MOON
Server: Apache
System: Linux server2.shieldcogroup.com 3.10.0-1160.119.1.el7.tuxcare.els12.x86_64 #1 SMP Fri Nov 8 05:49:38 UTC 2024 x86_64
User: jacom (1029)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python2.7/site-packages/leapp/utils/clicmd.pyc
�
g��fc@sddlZddlZddlZddlmZmZmZddlZddlm	Z	m
Z
mZmZdefd��YZ
defd��YZdefd	��YZd
efd��YZdddd
�Zd�Zddd�Zd�Zd�ZdS(i����N(tArgumentParsertRawDescriptionHelpFormattert_SubParsersAction(tCommandDefinitionErrortCommandErrortUnknownCommandErrort
UsageErrort_LeappArgumentParsercBseZd�Zd�ZRS(cCs tt|�jdtj�dS(Ntfile(tsuperRt
print_helptsyststderr(tself((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR

scCs/|j�tjjd|�tjd�dS(Ns
error: %s
i(R
RRtwritetexit(R
tmessage((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyterrors
(t__name__t
__module__R
R(((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyRs	t_LeappHelpFormattercBseZdZd�ZRS(s9
    Capitalizes section headings in the help output
    cCstt|�j|j��S(N(R	Rt
start_sectiont
capitalize(R
theading((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyRs(RRt__doc__R(((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyRst_SubParserActionOverridecBseZdZdd�ZRS(s�
    This class implements a workaround for an issue fixed in 2.7.9.
    See https://bugs.python.org/issue9351

    TL;DR: Before, 2.7.9 argparse._SubParserAction did not propagate sub parser default values
    to the global namespace when they were already defined .
    This implementation is a workaround to override those values additionally.

    The additional code will not be executed if python 2.7.9 or higher is found.
    c
Cs�tt|�j||||�tjdkr2dS|d}|d}|j|}|j|d�\}}x0t|�j	�D]\}}	t
|||	�q~WdS(Niii	ii(iii	(R	Rt__call__Rtversion_infot_name_parser_maptparse_known_argstNonetvarstitemstsetattr(
R
tparsert	namespacetvaluest
option_stringtparser_nametarg_stringst
sub_namespacetkeytvalue((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR+s


N(RRRRR(((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyRs
tCommandcBs�eZdZdddd�Zd�Zd�Zd�Zddd�Zd�Z	d�Z
d	�Zddeee
dddddd
�
Zdddd�ZRS(
sW
    Command implements a convenient command-based argument parsing the framework.
    tcCsR||_||_|p||_i|_g|_||_d|_d|_dS(si
        :param name: Name of the sub command
        :type name: str
        :param target: Function called when the command is invoked
        :type target: Callable
        :param help: Shows a help message
        :type help: str
        :param description: Extended description of the command (the default is `help`)
        :type description: str
        N(	tnamethelptdescriptiont
_sub_commandst_optionsttargetRtparentR"(R
R-R2R.R/((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyt__init__<s						cCs:tdtjjtjd�dt�}|jddt�|j	dddd|�|j
dd�|jr�|j
d	d
dd�}t|_n|}|j|d
|�|j�\}}|r)|jj�d}||jkr�|d}n||jkrt|��n|j|jj|�n|j|�dS(s�
        Entry point to the command execution. It is used for the main entry function of an application.

        :param version: Version string to display for --version calls
        :type version: str
        :return: None
        tprogitformatter_classtactiontparserss	--versiontversiontfuncttitlesRequired argumentstmetavartcommandR"i����N(RtostpathtbasenameRtargvRtregisterRtadd_argumenttset_defaultsRR0tadd_subparserstTruetrequiredtapply_parserRR5tsplitRR"RR:(R
R9R"tstargstleftovertcmdname((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pytexecutePs$(	
cCs-g|jD]}|djd�r
|^q
S(sK
        :return: Returns all options that are marked as 'inherit'
        itinherit(R1tget(R
toption((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pytget_inheritable_optionsqscCs�y9|jr|jj|�n|jr8|j|�nWn�tk
r�}|jj�|jjddddjd|j��n;t	k
r�}|jjddddjd|j��nXdS(sb
        The actual call is dispatched through this method. It ensures that the parent is also called
        to allow generic handling of some flags (especially inherited flags).

        :param args: Arguments object that is a result of the `argparse` commandline parser
        :type args: :py:class:`argparse.Namespace`
        :return: None
        tstatusiRs
UsageError: {message}
s
Error: {message}
N(
R3tcalledR2RR"R
RtformatRR(R
RKte((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyRTws			
+c	Csy|j|k	rdS|r%||_n1|j|jd|jdtdd|j�|_|jjd|jjd|j	�|jj
dd	t�g}|j}x#|r�||j�7}|j}q�Wx1|j
|D]"\}}}|jj||�q�W|jru|s9|jjd|jjd
dd|jdd
�}	n|}	x3|jj�D]\}
}|j|	d|�qOWndS(sb
        :param sparser: ArgumentParser.add_subparsers
        :type sparser: _SubParserActionOverride
        :param parent: Instance of :py:class:`_Command`
        :type parent: _Command
        :param parser: ArgumentParser instance usually received from sparser.add_parser
        :type parser: argparse.ArgumentParser
        :return: None
        NR.R6R/sDescription:

R5R:R7R8R;sAvailable subcommandsR<R,R3(R3R"t
add_parserR-R.RR/RDR5RTRBRRRR1RCR0RER RH(R
tsparserR3R"tinheritabletcurrentRKtkwargstinternaltsubsR-tcmd((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyRH�s."		
		cCsbt|t�sEtt|dd�t�r6|j}qEtd��n||_||j|j<|S(s�
        Adds a sub command to this command

        :param cmd: The sub command object
        :type cmd: :py:class:`leapp.utils.clicmd.Command`
        :return: self
        R=sGExpected instance of Command or decorated command function as parameterN(	t
isinstanceR+tgetattrRR=t	TypeErrorR3R0R-(R
R^((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pytadd_sub�s	cOs||d<t||�S(NR3(R=(R
RKR[((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR�s
cOs/|jdi�}|jj|||f�dS(NR\(tpopR1tappend(R
RKR[R\((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyt_add_opt�sc	Cs
|jd�}d|g}i}
|ro|jd�}t|�dkrXtd��n|jdd|�n|s�d}|r�d}q�|r�||
d<q�n|	r�|	|
d	<n|
r�|
|
d
<n|r�||
d<n|jd|d
|di|d6|d6||
�|S(s�
        Add an option

        :param name: Name of the option
        :type name: str
        :param short_name: Short name of the option (one letter)
        :type short_name: str
        :param help: Help string for the option
        :type help: str
        :param is_flag: Decides if it is a flag
        :type is_flag: bool
        :param inherit: Decides if this option should be inherited by sub commands
        :type inherit: bool
        :param value_type: Type of the value by default string
        :param wrapped: Function that is wrapped (aka the target)
        :type wrapped: Callable
        :param action: ArgumentParser actions to take (e.g. store)
        :type action: str
        :param metavar: Changes the display name of arguments in generated help messages.
                        It has no influence on the attribute name from the generated arguments namespace.
        :type metavar: str
        :param choices: range of values that the argument is allowed to take
        :type choices: list
        :param choices: default value of the argument if nothing is specified
        :type choices: str
        :return: self
        t-s--is$Short name should be one letter onlyitstoret
store_truettypeR<tchoicestdefaultR.R7R\twrappedRO(tlstriptlenRtinsertRe(R
R-t
short_nameR.tis_flagROt
value_typeRlR7R<RjRktnamesR[((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyt
add_option�s.
	


!cCs<|j|jdd�d|d|p'tdi|d6�|S(sx

        :param name:
        :param value_type:
        :param help:
        :param wrapped:
        :return:
        Rft_R.RiR\Rl(Retreplacetstr(R
R-RrR.Rl((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyRCs	N(RRRRR4RNRRRTRHRbRRetFalseRwRtRC(((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR+7s	!		(			4R,cs����fd�}|S(s�
    Decorator to mark a function as a sub command

    :param name: Sub command name
    :type name: str
    :param help: Help string for the sub command
    :type help: str
    :param description: Extended description for the sub command defaults to help if it is not set
    :type description: str
    :param parent: Instance to the parent command if it is a sub-command
    :type parent: Command
    cs�t|d�s3t�d�d|d��|_n6�|j_�|j_�pT�|j_||j_�r��j|j�n|S(NR=R.R2R/(thasattrR+R=R-R.R/R2Rb(tf(R/R.R-R3(s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pytwrappers((R-R.R/R3R{((R/R.R-R3s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR=s
cs"tj���fd��}|S(Ncs+t|d�s!td�|_n�|�S(NR=R,(RyR+R=(Rz(Rl(s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR{.s(tsixtwraps(RlR{((Rls6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyt_ensure_command-scst���fd��}|S(s�
    Decorator wrapping functions to add command line arguments to the sub command to be invoked

    :param name: Name of the argument
    :param value_type: Type of the argument
    :param help: Help string for the argument
    cs&|jj�d�d�d|�|S(NRrR.Rl(R=RC(Rz(R.R-Rr(s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR{>s(R~(R-RrR.R{((R.R-Rrs6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pytcommand_arg6scst��fd��}|S(s�
    Decorator wrapping functions to add command line options to the sub command to be invoked

    :param name: Name of the option
    :param kwargs: parameters as specified in :py:func:`leapp.utils.clicmd.Command.add_option`
    cs|jj�d|��|S(NRl(R=Rt(Rz(R[R-(s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR{Ms(R~(R-R[R{((R[R-s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pytcommand_optFscCs8d}t|d�rd}ntj|dtj|�S(s�
    Decorator passing the command attribute of the wrapped function to the wrapper

    This needs to be used by decorators that are trying to wrap clicmd decorated command functions.
    R=tassigned((scommand(RyR|R}t	functoolstWRAPPER_ASSIGNMENTS(Rzt
additional((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pytcommand_aware_wrapsTs	(R�R>RtargparseRRRR|tleapp.exceptionsRRRRRRRtobjectR+RR=R~RR�R�(((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyt<module>s"
	�