JFIF$        dd7 

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

a

}|�g,�@s dZddlZddlZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
ddlmZddlmZdd
lmZddlmZddlmZddlmZer�ddlmZd;eeeeefd�dd�Zeed�dd�Zd<eee	ed�dd�ZGdd�d�ZGdd �d ej �Z!Gd!d"�d"ej"�Z#e
ej$ej%fe	eeed#�d$d%�Z&Gd&d'�d'e'�Z(eed(�d)d*�Z)Gd+d,�d,ej"�Z*eeeed-�d.d/�Z+Gd0d1�d1ej"�Z,Gd2d3�d3ej"�Z-Gd4d5�d5ej"�Z.ee/d(�d6d7�Z0eej%dd8�d9d:�Z1dS)=z"Certbot command line util function�N)�Any)�Iterable)�List)�Optional)�Sequence)�Tuple)�
TYPE_CHECKING)�Union)�
challenges)�
configuration)�errors)�util)�	constants)�os)�helpful�rb)�filename�mode�returnc
Cs~zHtj�|�}t||��}|��}Wd�n1s60Y||fWStyx}zt�|j��WYd}~n
d}~00dS)aReturns the given file's contents.

    :param str filename: path to file
    :param str mode: open mode (see `open`)

    :returns: absolute path of filename and its contents
    :rtype: tuple

    :raises argparse.ArgumentTypeError: File does not exist or is not readable.

    N)	r�path�abspath�open�read�OSError�argparse�ArgumentTypeError�strerror)rrZthe_file�contents�exc�r�C/usr/lib/python3.9/site-packages/certbot/_internal/cli/cli_utils.py�	read_files&
r!)�namercCst�tj|�S)zDefault value for CLI flag.)�copy�deepcopyrZCLI_DEFAULTS)r"rrr �flag_default/sr%F)r"�hiddenrcCs|r
tjSt�ttj|��S)zRExtract the help message for a `configuration.NamespaceConfig` property docstring.)r�SUPPRESS�inspectZgetdoc�getattrr�NamespaceConfig)r"r&rrr �config_help8sr+c@s4eZdZdZdedd�dd�Zeedd�dd	�ZdS)
�HelpfulArgumentGroupa+Emulates an argparse group for use with HelpfulArgumentParser.

    This class is used in the add_group method of HelpfulArgumentParser.
    Command line arguments can be added to the group, but help
    suppression and default detection is applied by
    HelpfulArgumentParser when necessary.

    zhelpful.HelpfulArgumentParserN)�helpful_arg_parser�topicrcCs||_||_dS�N)�_parser�_topic)�selfr-r.rrr �__init__HszHelpfulArgumentGroup.__init__)�args�kwargsrcOs |jj|jg|�Ri|��dS)z6Add a new command line argument to the argument group.N)r0�addr1)r2r4r5rrr �add_argumentLsz!HelpfulArgumentGroup.add_argument)�__name__�
__module__�__qualname__�__doc__�strr3rr7rrrr r,?sr,c@s&eZdZdZejeed�dd�ZdS)�CustomHelpFormatterz�This is a clone of ArgumentDefaultsHelpFormatter, with bugfixes.

    In particular we fix https://bugs.python.org/issue28742
    )�actionrcCsX|j}|jrTd|jvrTd|jvrT|jtjkrTtjtjg}|rT|jsL|j|vrT|d7}|S)Nz
%(default)z	(default:z (default: %(default)s))�help�defaultrr'�OPTIONAL�ZERO_OR_MORE�option_strings�nargs)r2r>Zhelpstr�defaulting_nargsrrr �_get_help_stringWsz$CustomHelpFormatter._get_help_stringN)	r8r9r:r;r�Actionrr<rFrrrr r=Qsr=c@s>eZdZdZdejejeee	e
dfeedd�dd�ZdS)�_DomainsActionz!Action class for parsing domains.N)�parser�	namespace�domain�
option_stringrcCst||durt|�nd�dS)z%Just wrap add_domains in argparseese.N)�add_domainsr<)r2rIrJrKrLrrr �__call__dsz_DomainsAction.__call__)N�
r8r9r:r;r�ArgumentParser�	Namespacer	r<rrrrNrrrr rHas�
�rH)�args_or_config�domainsrcCsNg}|s|S|�d�D]2}t�|���}|�|�||jvr|j�|�q|S)a�Registers new domains to be used during the current client run.

    Domains are not added to the list of requested domains if they have
    already been registered.

    :param args_or_config: parsed command line arguments
    :type args_or_config: argparse.Namespace or
        configuration.NamespaceConfig
    :param str domain: one or more comma separated domains

    :returns: domains after they have been normalized and validated
    :rtype: `list` of `str`

    �,)�splitr
Zenforce_domain_sanity�strip�appendrS)rRrSZvalidated_domainsrKrrr rMks

rMcs(eZdZdZeed��fdd�Z�ZS)�CaseInsensitiveListaA list that will ignore case when searching.

    This class is passed to the `choices` argument of `argparse.add_arguments`
    through the `helpful` wrapper. It is necessary due to special handling of
    command line arguments by `set_by_cli` in which the `type_func` is not applied.)�elementrcst|t�sdSt��|���S)NF)�
isinstancer<�super�__contains__�lower)r2rY��	__class__rr r\�s
z CaseInsensitiveList.__contains__)r8r9r:r;�object�boolr\�
__classcell__rrr^r rX�srX)�valuercCsd|vsd|vrt�d��|S)N�(�)zmay not contain parentheses)rr)rcrrr �_user_agent_comment_type�s
rfc@s>eZdZdZdejejeee	e
dfeedd�dd�ZdS)�_EncodeReasonActionz+Action class for parsing revocation reason.N)rIrJ�reasonrLrcCs4|durtd��tjt|���}t||j|�dS)z.Encodes the reason for certificate revocation.NzUnexpected null reason.)�
ValueErrorrZREVOCATION_REASONSr<r]�setattr�dest)r2rIrJrhrL�coderrr rN�sz_EncodeReasonAction.__call__)NrOrrrr rg�s�
�rg)�pref_challsrcsVddd��dd�|D�}�fdd�|D�}d�dd	�|D��}|rRt�d
�|���|S)a Translate and validate preferred challenges.

    :param pref_challs: list of preferred challenge types
    :type pref_challs: `list` of `str`

    :returns: validated list of preferred challenge types
    :rtype: `list` of `str`

    :raises errors.Error: if pref_challs is invalid

    zdns-01zhttp-01)Zdns�httpcSsg|]}|���qSr)rV��.0�crrr �
<listcomp>��z.parse_preferred_challenges.<locals>.<listcomp>csg|]}��||��qSr)�getro��aliasesrr rr�rsz, css|]}|tjjvr|VqdSr/)r
Z	ChallengeZTYPES)rpr"rrr �	<genexpr>�s�z-parse_preferred_challenges.<locals>.<genexpr>zUnrecognized challenges: {0})�joinr�Error�format)rm�challsZunrecognizedrrur �parse_preferred_challenges�s
�r|c@s>eZdZdZdejejeee	e
dfeedd�dd�ZdS)�_PrefChallActionz.Action class for parsing preferred challenges.N)rIrJrmrLrc
Csn|durtd��ztt|��d��}Wn6tjy\}zt�|t|���WYd}~n
d}~00|j�	|�dS)NzUnexpected null pref_challs.rT)
rir|r<rUrryr�
ArgumentErrorrm�extend)r2rIrJrmrLr{�errorrrr rN�s&z_PrefChallAction.__call__)NrOrrrr r}�s�
�r}c@s>eZdZdZdejejeee	e
dfeedd�dd�ZdS)�_DeployHookActionz&Action class for parsing deploy hooks.N�rIrJ�valuesrLrcCs6|j|jk}|r&|j|kr&t�|d��||_|_dS)Nz!conflicts with --renew-hook value)�deploy_hook�
renew_hookrr~)r2rIrJr�rLZrenew_hook_setrrr rN�s�z_DeployHookAction.__call__)NrOrrrr r��s�
�r�c@s>eZdZdZdejejeee	e
dfeedd�dd�ZdS)�_RenewHookActionz%Action class for parsing renew hooks.Nr�cCs.|jdu}|r$|j|kr$t�|d��||_dS)Nz"conflicts with --deploy-hook value)r�rr~r�)r2rIrJr�rLZdeploy_hook_setrrr rN�s
�z_RenewHookAction.__call__)NrOrrrr r��s�
�r�cCs@zt|�}Wnty(t�d��Yn0|dkr<t�d��|S)a[Converts value to an int and checks that it is not negative.

    This function should used as the type parameter for argparse
    arguments.

    :param str value: value provided on the command line

    :returns: integer representation of value
    :rtype: int

    :raises argparse.ArgumentTypeError: if value isn't a non-negative integer

    zvalue must be an integerrzvalue must be non-negative)�intrirr)rcZ	int_valuerrr �nonnegative_int�s
r�)�verb�configrcCs�td�tjf}|jr(|j|vr(t�d��|jtd�krDtj|_d|_|jr�|dvr`t�d|��d|_	|_t
�
tj�
|jtjd��r�d|_d|_dS)a	Updates server, break_my_certs, staging, tos, and
    register_unsafely_without_email in config as necessary to prepare
    to use the test server.

    We have --staging/--dry-run; perform sanity check and set config.server

    :param str verb: subcommand called

    :param config: parsed command line arguments
    :type config: configuration.NamespaceConfig

    :raises errors.Error: if non-default server is used and --staging is set
    :raises errors.Error: if inapplicable verb is used and --dry-run is set
    �serverz'--server value conflicts with --stagingN)ZcertonlyZrenew�reconfigurezN--dry-run currently only works with the 'certonly' or 'renew' subcommands (%r)T�*)r%rZSTAGING_URIZstagingr�rryZaccount�dry_runZbreak_my_certs�globrrrxZ
config_dirZACCOUNTS_DIRZtosZregister_unsafely_without_email)r�r�Zdefault_serversrrr �set_test_server_options�s
�r�)r)F)2r;rr#r�r(�typingrrrrrrrr	Zacmer
Zcertbotrrr
Zcertbot._internalrZcertbot.compatrZcertbot._internal.clirr<r!r%rar+r,�
HelpFormatterr=rGrHrQr*rM�listrXrfrgr|r}r�r�r�r�r�rrrr �<module>sL	
�



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