JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/certbot/_internal/cli/__pycache__/helpful.cpython-39.pyc

a

}|�gyX�@sndZddlZddlZddlZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZddlZdd
l
mZddl
mZddl
mZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddl!m"Z#ddl$m%Z%ddl&m'Z'ddl&m(Z(Gdd�d�Z)dS)z$Certbot command line argument parser�N)�Any)�Dict)�Iterable)�List)�Optional)�Tuple)�Union)�crypto_util)�errors)�util)�	constants)�hooks)�COMMAND_OVERVIEW)�HELP_AND_VERSION_USAGE)�SHORT_USAGE)�add_domains)�CustomHelpFormatter)�flag_default)�HelpfulArgumentGroup)�set_test_server_options)�	VERB_HELP)�
VERB_HELP_MAP)�obj)�disco)�ArgumentSource)�NamespaceConfigc@s�eZdZdZeeeedd�dd�Zgd�Zed�dd	�Z	eee
eefed
�dd�Ze
dd
�dd�Zeeefd�dd�Zeejd�dd�Ze
d�dd�Ze
dd
�dd�Ze
dd
�dd�Zdd�dd�Zeeeee
eefd�dd�Zee
eeeefeedd �d!d"�Zee
eeeefeeejd �d#d$�Zeedd%�d&d'�Zd2eeeee d)�d*d+�Z!e"j#dd,�d-d.�Z$e
eefeeeefd/�d0d1�Z%dS)3�HelpfulArgumentParserz�Argparse Wrapper.

    This class wraps argparse, adding the ability to make --help less
    verbose, and request help on specific subcategories at a time, eg
    'certbot --help security' for security options.

    N)�args�plugins�returnc	Cs�ddlm}|j|j|j|j|j|j|j|j|j	|j
|j|j|j|j
|j|j|jd�|_t�tj�j|_g|_gd�}|t|j�|jdg7}t|�}||dg|_||_|jr�|jddkr�d|jd<|��|�d|j�}|�d|j�}|t|t ��rt|t ��r|�p||_!nt|t"��r*|n||_!|�#||j!�}|�$|j!�|_%i|_&t'j(d	|t)d
dgt*d�d
�+d�,t*d���d�|_-d|j-_.|dS)Nr)�main)�auth�certonly�run�installr�register�update_account�show_account�
unregister�renew�revoke�rollback�
everything�certificates�delete�enhance�reconfigure)�allZsecurity�pathsZ
automationZtestingZmanage�help�--help�-h�certbot�-c�--configZconfig_filesz"path to config file (default: {0})z and )�prog�usage�formatter_classZargs_for_setting_config_pathZdefault_config_filesZconfig_arg_help_messageF)/�certbot._internalr r"r#r$Zplugins_cmdr%r&r'r(r)r*r+r-r.r/r0�VERBS�display_objZNoninteractiveDisplay�sys�stdoutZnotification�notify�actions�list�COMMANDS_TOPICS�help_topicsr�determine_verb�prescan_for_flag�
isinstance�bool�help_arg�str�
_usage_string�determine_help_topics�visible_topics�groups�configargparseZ	ArgParserrr�format�join�parserZ_add_config_file_help)	�selfrrr ZHELP_TOPICSZplugin_namesZhelp1Zhelp2Zshort_usage�rU�A/usr/lib/python3.9/site-packages/certbot/_internal/cli/helpful.py�__init__-sd�
��
zHelpfulArgumentParser.__init__)ZcommandZcommandsZ
subcommand�subcommands�verbs)rcCsTtdd�tD��}d}tt�D](\}}|�dd�}|dj|||d�7}q|d7}|S)	Ncss|]}t|�VqdS�N)�len)�.0�vrUrUrV�	<genexpr>v�z:HelpfulArgumentParser._list_subcommands.<locals>.<genexpr>z,The full list of available SUBCOMMANDS is:

�short�z{0:<{length}}     {1}
)�lengthzG
You can get more help on a specific subcommand with --help SUBCOMMAND
)�maxr�sortedr�getrQ)rTZlongest�text�verbZprops�docrUrUrV�_list_subcommandsusz'HelpfulArgumentParser._list_subcommands)rrJrcCs�d|vrd}nd}d|vr d}nd}t}|durV|�|t||ft�t�d�nl||jvr~|�||���t�d�nD|d	kr�|t||f7}n*t|t	�r�t
�|i��d
d�}|r�|n|}|S)a#Make usage strings late so that plugins can be initialised late

        :param plugins: all discovered plugins
        :param help_arg: False for none; True for --help; "TOPIC" for --help TOPIC
        :rtype: str
        :returns: a short usage string for the top of --help TOPIC)
        ZnginxzH--nginx           Use the Nginx plugin for authentication & installationz+(the certbot nginx plugin is not installed)ZapachezI--apache          Use the Apache plugin for authentication & installationz,(the certbot apache plugin is not installed)Trr1r:N)rrArrr?�exitrDrirHrKrre)rTrrJZ	nginx_docZ
apache_docr:ZcustomrUrUrVrL�s&

z#HelpfulArgumentParser._usage_string)�configrcCs2|jdusJ�|jdtjkr.|jdkr.g|_dS)z8Make "certbot renew" safe if domains are set in cli.ini.N�domainsr))Zargument_sourcesr�CONFIG_FILErgrl�rTrkrUrUrV�&remove_config_file_domains_for_renewal�s
�z<HelpfulArgumentParser.remove_config_file_domains_for_renewalcsXdd��jD���j��}ttttjtfftdd���fdd�}|D]}|�	d�rH|||tj
�qH||�di�tj�d|v�rT|d}|d	\}}g}|D]�}|�	d
�s�q�|dvr�tj
�d<q�d
|vr�|�d
�d}nd|vr�|�d�d}|�	d��r|�|�q�|dd�D]}	|�d
|	����qq�|D]}��|�}
tj
�|
j<�q6�S)NcSsi|]}|jtj�qSrU)�destrZDEFAULT�r\�actionrUrUrV�
<dictcomp>�r_z=HelpfulArgumentParser._build_sources_dict.<locals>.<dictcomp>)�
settings_dict�sourcercs2�fdd�|��D�}���fdd�|D��dS)Ncs*g|]"\}\}}|dur"��|�n|�qSrZ)�_find_action_for_arg)r\�argrr�_)rTrUrV�
<listcomp>�s
�zTHelpfulArgumentParser._build_sources_dict.<locals>.update_result.<locals>.<listcomp>csi|]}|j��qSrU)rprq�rurUrVrs�r_zTHelpfulArgumentParser._build_sources_dict.<locals>.update_result.<locals>.<dictcomp>)�items�update)rtrurB��resultrTrzrV�
update_result�s
�z@HelpfulArgumentParser._build_sources_dict.<locals>.update_resultZconfig_fileZenv_varZcommand_linera�-)r7r8Z
config_dir�=r� �--�)rBrSZget_source_to_settings_dictrrKrrP�Actionr�
startswithrmreZENV_VARZCOMMAND_LINE�split�appendrvrp)rTZsource_to_settings_dictrZ
source_keyrtrxZunprocessed_argsrrwZ	short_argrrrUr}rV�_build_sources_dict�s>

�




z)HelpfulArgumentParser._build_sources_dict)rwrcCst|ddkrd|}|jD]}||jvr|Sq|jD]&}|jD]}|�|�rB|SqBq8td|�d���dS)Nrr�r�z!Action corresponding to argument z is None)rB�option_stringsr��AssertionError)rTrwrr�
option_stringrUrUrVrv�s





z*HelpfulArgumentParser._find_action_for_argcCs<|j�|j�}|j|j|_|j|_t|�}|�|���|�	|�|jdkrl|j
rft�d�
tj���d|_|j
r�|jr�t�d�
tj���|js�|jr�|�|�|jr�|�|�|jr�|js�d|_|jr�t�|�|jr�tdd�|jD��r�t�d��|j�r|j�rt�d��t|j t!��r8t"|j �d	k�r8t�d
��|S)z�Parses command line arguments and returns the result.

        :returns: parsed command line arguments
        :rtype: configuration.NamespaceConfig

        r)z{0} cannot be used with renewTz.Flag for non-interactive mode and {0} conflictcss|]}t�|�VqdSrZ)rZis_wildcard_domain�r\�drUrUrVr^0r_z3HelpfulArgumentParser.parse_args.<locals>.<genexpr>zFUsing --allow-subset-of-names with a wildcard domain is not supported.z@Parameters --hsts and --auto-hsts cannot be used simultaneously.r�z8Only *one* --key-type type may be provided at this time.)#rS�
parse_argsrr=rg�funcrZset_argument_sourcesr�roZforce_interactiver
�ErrorrQrZFORCE_INTERACTIVE_FLAGZnoninteractive_modeZstaging�dry_run�set_test_server�csr�
handle_csrZmust_stapleZstapleZvalidate_hooksr
�allow_subset_of_names�anyrlZhstsZ	auto_hstsrHZkey_typerCr[)rTZparsed_argsrkrUrUrVr�sP

����



��z HelpfulArgumentParser.parse_argscCst|j|�S)z�Updates server, break_my_certs, staging, tos, and
        register_unsafely_without_email in config as necessary to prepare
        to use the test server.)rrgrnrUrUrVr�>sz%HelpfulArgumentParser.set_test_serverc
Cs�|jdkrt�d��|jr$t�d��|jdd�\}}t�||�\}}}|D]}t||�qL|stt�d|jd��||f|_dd�|D�}t	|j
�}	||	kr�t�d	�d
�
|�d
�
|	����dS)zProcess a --csr flag.r"z�Currently, a CSR file may only be specified when obtaining a new or replacement via the certonly command. Please try the certonly command instead.z1--allow-subset-of-names cannot be used with --csrr�zJUnfortunately, your CSR %s needs to have a SubjectAltName for every domaincSsh|]}|���qSrU)�lowerr�rUrUrV�	<setcomp>^r_z3HelpfulArgumentParser.handle_csr.<locals>.<setcomp>zMInconsistent domain requests:
From the CSR: {0}
From command line/config: {1}z, N)rgr
r�r�r�r	Zimport_csr_filerZ
actual_csr�setrlZConfigurationErrorrQrR)
rTrkZcsrfile�contents�typr�rl�domainZcsr_domainsZconfig_domainsrUrUrVr�Ds.


��

��z HelpfulArgumentParser.handle_csrcCszd|jvsd|jvrd|_dSt|j�D]F\}}||jvr(|}|dkrJd}|dkrVd}||_|j�|�dSq(d|_dS)	z�Determines the verb/subcommand provided by the user.

        This function works around some of the limitations of argparse.

        r5r4r3Nr!r"r,r#)rrg�	enumerater=�pop)rT�i�tokenrgrUrUrVrFfs
z$HelpfulArgumentParser.determine_verb)�flag�possible_argumentsrcCsR||jvrdS|j�|�}z |j|d}||vr8|WSWntyLYn0dS)asChecks cli input for flags.

        Check for a flag, which accepts a fixed set of possible arguments, in
        the command line; we will use this information to configure argparse's
        help correctly.  Return the flag's argument, if it has one that matches
        the sequence @possible_arguments; otherwise return whether the flag is
        present.

        Fr�T)r�index�
IndexError)rTr�r��posZnxtrUrUrVrG~s

z&HelpfulArgumentParser.prescan_for_flag)�topicsr�kwargsrcOs$|j�|j|g|�Ri|���dS)a1Add a new command line argument.

        :param topics: str or [str] help topic(s) this should be listed under,
                       or None for options that don't fit under a specific
                       topic which will only be shown in "--help all" output.
                       The first entry determines where the flag lives in the
                       "--help all" output (None -> "optional arguments").
        :param list *args: the names of this argument flag
        :param dict **kwargs: various argparse settings for this argument

        N)rBr��_add)rTr�rr�rUrUrV�add�s
zHelpfulArgumentParser.addcOs�|�d�}|tjur&|jj|i|��St|t�rJ|j|vr@|jn|d}n|}t|t�s�|j	|r�||j
vr�|j
|}|j|i|��S|jj|i|��Sntj|d<|jj|i|��SdS)Nrrrr3)
rerZDeprecatedArgumentActionrS�add_argumentrHrCrJrIrNrO�argparse�SUPPRESS)rTr�rr�rr�topic�grouprUrUrVr��s

	



zHelpfulArgumentParser._add)�
argument_name�num_argsrcCs t�|jd�}t�|||�dS)a�Adds a deprecated argument with the name argument_name.

        Deprecated arguments are not shown in the help. If they are used
        on the command line, a warning is shown stating that the
        argument is deprecated and no other action is taken.

        :param str argument_name: Name of deprecated argument.
        :param int num_args: Number of arguments the option takes.

        N)�	functools�partialr�r�add_deprecated_argument)rTr�r�Zadd_funcrUrUrVr��sz-HelpfulArgumentParser.add_deprecated_argumentrU)r�rYr�rcKsZ|j|rP|jj|fi|��|j|<|jrP|D] }|j|j|t|dd�q.t||�S)a�Create a new argument group.

        This method must be called once for every topic, however, calls
        to this function are left next to the argument definitions for
        clarity.

        :param str topic: Name of the new argument group.
        :param str verbs: List of subcommands that should be documented as part of
                          this help group / topic

        :returns: The new argument group.
        :rtype: `HelpfulArgumentGroup`

        r`)r3)rNrS�add_argument_grouprOrJr�rr)rTr�rYr�r]rUrUrV�	add_group�s
zHelpfulArgumentParser.add_group)rrcCs4|��D]&\}}|j||jd�}|j�||�qdS)z�

        Let each of the plugins add its own command line arguments, which
        may or may not be displayed as help topics.

        )�descriptionN)r{r�Zlong_descriptionZ
plugin_clsZinject_parser_options)rTr�nameZ	plugin_epZparser_or_grouprUrUrV�add_plugin_args�s
�z%HelpfulArgumentParser.add_plugin_args)�chosen_topicrcsX�dkrd��dkrd��dkr0dd�|jD�S�sDdd�|jD�S�fd	d�|jD�S)
z�

        The user may have requested help on a topic, return a dict of which
        topics to display. @chosen_topic has prescan_for_flag's return type

        :returns: dict

        r!r"r,r#r1cSsi|]}||dk�qS)zcertbot-route53:authrU�r\�trUrUrVrsr_z?HelpfulArgumentParser.determine_help_topics.<locals>.<dictcomp>cSsi|]
}|d�qS)FrUr�rUrUrVrsr_csi|]}||�k�qSrUrUr��r�rUrVrsr_)rE)rTr�rUr�rVrMsz+HelpfulArgumentParser.determine_help_topics)rU)&�__name__�
__module__�__qualname__�__doc__rrKrrWrDrirrIrLrrorrr�rPr�rvr�r�r�rFrrGrr�r��intr�rr�rZPluginsRegistryr�rMrUrUrUrVr%s:F#D8"
���
�
�r)*r�r�r�r?�typingrrrrrrrrPr6r	r
rr<rr
Z#certbot._internal.cli.cli_constantsrrrZcertbot._internal.cli.cli_utilsrrrrrZcertbot._internal.cli.verb_helprrZcertbot._internal.displayrr>Zcertbot._internal.pluginsrZcertbot.configurationrrrrUrUrUrV�<module>s>
Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼Jȧc%ANolՎprULZԛerE2=XDXgVQeӓk yP7U*omQIs,K`)6\G3t?pgjrmۛجwluGtfh9uyP0D;Uڽ"OXlif$)&|ML0Zrm1[HXPlPR0'G=i2N+0e2]]9VTPO׮7h(F*癈'=QVZDF,d߬~TX G[`le69CR(!S2!P <0x<!1AQ "Raq02Br#SCTb ?Ζ"]mH5WR7k.ۛ!}Q~+yԏz|@T20S~Kek *zFf^2X*(@8r?CIuI|֓>^ExLgNUY+{.RѪ τV׸YTD I62'8Y27'\TP.6d&˦@Vqi|8-OΕ]ʔ U=TL8=;6c| !qfF3aů&~$l}'NWUs$Uk^SV:U# 6w++s&r+nڐ{@29 gL u"TÙM=6(^"7r}=6YݾlCuhquympǦ GjhsǜNlɻ}o7#S6aw4!OSrD57%|?x>L |/nD6?/8w#[)L7+6〼T ATg!%5MmZ/c-{1_Je"|^$'O&ޱմTrb$w)R$& N1EtdU3Uȉ1pM"N*(DNyd96.(jQ)X 5cQɎMyW?Q*!R>6=7)Xj5`J]e8%t!+'!1Q5 !1 AQaqё#2"0BRb?Gt^## .llQT $v,,m㵜5ubV =sY+@d{N! dnO<.-B;_wJt6;QJd.Qc%p{ 1,sNDdFHI0ГoXшe黅XۢF:)[FGXƹ/w_cMeD,ʡcc.WDtA$j@:) -# u c1<@ۗ9F)KJ-hpP]_x[qBlbpʖw q"LFGdƶ*s+ډ_Zc"?%t[IP 6J]#=ɺVvvCGsGh1 >)6|ey?Lӣm,4GWUi`]uJVoVDG< SB6ϏQ@ TiUlyOU0kfV~~}SZ@*WUUi##; s/[=!7}"WN]'(L! ~y5g9T̅JkbM' +s:S +B)v@Mj e Cf jE 0Y\QnzG1д~Wo{T9?`Rmyhsy3!HAD]mc1~2LSu7xT;j$`}4->L#vzŏILS ֭T{rjGKC;bpU=-`BsK.SFw4Mq]ZdHS0)tLg