HEX
Server: LiteSpeed
System: Linux oxygen.shetabanhost.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: rasapedi (1695)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyc
�
�S4bc@sddlZddlZddlZddlmZmZmZddlZddlm	Z	m
Z
mZdefd��YZdefd��YZ
defd	��YZd
efd��YZdddd
�Zd�Zddd�Zd�Zd�ZdS(i����N(tArgumentParsert_SubParsersActiontRawDescriptionHelpFormatter(tCommandDefinitionErrort
UsageErrortCommandErrort_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	R
Rtwritetexit(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(RRt
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	(RRt__call__R
t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,R1R-R.((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyt__init__9s						cCstdtjjtjd�dt�}|jddt�|j	dddd|�|j
dd�|jr�|j
d	d
dd�}t|_n|}|j|d
|�|j�\}}|r�|jj�d}|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(RtostpathtbasenameR
targvRtregisterRtadd_argumenttset_defaultsRR/tadd_subparserstTruetrequiredtapply_parserRR4tsplitR!RR9(RR8R!tstargstleftovertcmdname((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pytexecuteMs(	cCs-g|jD]}|djd�r
|^q
S(sK
        :return: Returns all options that are marked as 'inherit'
        itinherit(R0tget(Rtoption((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pytget_inheritable_optionslscCs�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(
R2tcalledR1RR!R	RtformatRR(RRJte((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyRSrs			
+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-R5R.sDescription:

R4R9R6R7R:sAvailable subcommandsR;R+R2(R2R!t
add_parserR,R-RR.RCR4RSRARRQR0RBR/RDRRG(RtsparserR2R!tinheritabletcurrentRJtkwargstinternaltsubsR,tcmd((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyRG�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	TypeErrorR2R/R,(RR]((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pytadd_sub�s	cOs||d<t||�S(NR2(R<(RRJRZ((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR�s
cOs/|jdi�}|jj|||f�dS(NR[(tpopR0tappend(RRJRZR[((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-R6R[twrappedRN(tlstriptlenRtinsertRd(RR,t
short_nameR-tis_flagRNt
value_typeRkR6R;RiRjtnamesRZ((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:
        Ret_R-RhR[Rk(Rdtreplacetstr(RR,RqR-Rk((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyRB�s	N(RRRRR3RMRQRSRGRaRRdtFalseRvRsRB(((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR*5s			(			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-R1R.(thasattrR*R<R,R-R.R1Ra(tf(R.R-R,R2(s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pytwrappers((R,R-R.R2Rz((R.R-R,R2s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR<s
cs"tj���fd��}|S(Ncs+t|d�s!td�|_n�|�S(NR<R+(RxR*R<(Ry(Rk(s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyRz)s(tsixtwraps(RkRz((Rks6/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(NRqR-Rk(R<RB(Ry(R-R,Rq(s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyRz9s(R}(R,RqR-Rz((R-R,Rqs6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pytcommand_arg1scst��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(NRk(R<Rs(Ry(RZR,(s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyRzHs(R}(R,RZRz((RZR,s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pytcommand_optAscCs8d}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(RxR{R|t	functoolstWRAPPER_ASSIGNMENTS(Ryt
additional((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pytcommand_aware_wrapsOs	(R�R=R
targparseRRRR{tleapp.exceptionsRRRRRRtobjectR*RR<R}R~RR�(((s6/usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyt<module>s
�