https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/awscli/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/awscli/__pycache__/argprocess.cpython-310.pyc
o

.&�aXS�@sDdZddlZddlZddlmZddlmZmZddlm	Z	m
Z
ddlmZddlm
Z
mZmZddlmZe�d	�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Z d/d#d$�Z!d%d&�Z"d'd(�Z#Gd)d*�d*e$�Z%Gd+d,�d,e%�Z&Gd-d.�d.e%�Z'dS)0zModule for processing CLI args.�N)�six)�OrderedDict�json)�SCALAR_TYPES�
COMPLEX_TYPES)�	shorthand)�%find_service_and_method_in_event_name�is_document_type�is_document_type_container)�is_json_value_headerzawscli.argprocessc�eZdZ�fdd�Z�ZS)�
ParamErrorcs,d||f}tt|��|�||_||_dS)aB

        :type cli_name: string
        :param cli_name: The complete cli argument name,
            e.g. "--foo-bar".  It should include the leading
            hyphens if that's how a user would specify the name.

        :type message: string
        :param message: The error message to display to the user.

        z Error parsing parameter '%s': %sN)�superr
�__init__�cli_name�message)�selfrr�full_message��	__class__��3/usr/lib/python3/dist-packages/awscli/argprocess.pyr s�
zParamError.__init__��__name__�
__module__�__qualname__r�
__classcell__rrrrr
�r
c@�eZdZdS)�ParamSyntaxErrorN�rrrrrrrr3�rcr)�ParamUnknownKeyErrorcs*d�|�}d||f}tt|��|�dS)N�, z'Unknown key '%s', valid choices are: %s)�joinrr"r)r�key�
valid_keysrrrrr8s
��zParamUnknownKeyError.__init__rrrrrr"7rr"c@r)�TooComplexErrorNr rrrrr'@r!r'cCs:t|dd�}|jd|||f||||d�}|dur|}|S)a
    Unpack an argument's value from the commandline. This is part one of a two
    step process in handling commandline arguments. Emits the load-cli-arg
    event with service, operation, and parameter names. Example::

        load-cli-arg.ec2.describe-instances.foo

    �name�	anonymouszload-cli-arg.%s.%s.%s)�param�value�service_name�operation_nameN)�getattr�emit_first_non_none_response)�sessionr,r-�cli_argumentr+�
param_name�value_overriderrr�unpack_argumentDs	��r4cCsg}t||�S�N��_detect_shape_structure)r*�stackrrr�detect_shape_structure\s
r9csH|j�vrdS��|j�z�|jtvrW���dS|jdkrg�fdd�|j��D�}t|�dkrAtdd�|D��rAW���d	St|�dkrWtd
d�|D��rWW���dSdd
�	t
t|���W���S|jdkrydt|j
��W���S|jdkr�|jjtvr�W���dSdt|j��W���SW���dS���w)N�	recursive�scalar�	structurecsg|]}t|���qSrr6��.0�p�r8rr�
<listcomp>js�z+_detect_shape_structure.<locals>.<listcomp>�cs��|]}|dkVqdS�r;Nrr=rrr�	<genexpr>p��z*_detect_shape_structure.<locals>.<genexpr>zstructure(scalar)csrCrDrr=rrrrErrFzstructure(scalars)z
structure(%s)r#�listzlist-%s�mapz
map-scalarzmap-%s)r(�append�	type_namer�pop�members�values�len�allr$�sorted�setr7�memberr+)r*r8�	sub_typesrr@rr7as<


�
�
��
	
�

��
�r7cCst|j||j�S)a1
    Parses and unpacks the encoded string command line parameter
    and returns native Python data structures that can be passed
    to the Operation.

    :type cli_argument: :class:`awscli.arguments.BaseCLIArgument`
    :param cli_argument: The CLI argument object.

    :param value: The value of the parameter.  This can be a number of
        different python types (str, list, etc).  This is the value as
        it's specified on the command line.

    :return: The "unpacked" argument than can be sent to the `Operation`
        object in python.
    )�_unpack_cli_arg�argument_modelr)r1r+rrr�unpack_cli_arg�s�rVcCs.|j�d�r|j�d�dkr|jdkrdSdS)N�	jsonvalue�location�header�stringTF)�
serialization�getrJ��modelrrr�
_special_type�s

r_cCsRt|�st|�rt|||�S|jtvrt|||�S|jtvr$t|||�St�	|�Sr5)
rr	�_unpack_json_cli_argrJr�unpack_scalar_cli_argr�_unpack_complex_cli_argr�	text_type)rUr+rrrrrT�s�
�
�
rTc
Cs<ztj|td�WSty}z	t|d||f��d}~ww)N)�object_pairs_hookz"Invalid JSON: %s
JSON received: %s)r�loadsr�
ValueErrorr
)rUr+r�errrr`�s����r`c
s|j}|dks|dkr |��ddkrt||��St�d|��|dkr~t|tj�r9|��ddkr8t||��Sn!t|t�rZt|�dkrZ|d�	�}|rZ|ddkrZt||d��Sz|j
���fd	d
�|D�WSttfy}}zt�|d��d}~wwdS)Nr<rHr�{zInvalid JSON:
%srG�[rBcsg|]}t�|���qSr)rT�r>�v�r�member_shape_modelrrrA�s�z+_unpack_complex_cli_arg.<locals>.<listcomp>)
rJ�lstripr`r
�
isinstancer�string_typesrGrN�striprRrf�	TypeError)rUr+rrJ�single_valuergrrlrrb�s0�����rb�cCs�|jdks
|jdkrt|�S|jdks|jdkrt|�S|jdkrE|j�d�rEtj�|�}tj�|�}tj�	|�s@d}t
||��t|d�S|jd	kr\t|t
j�rX|��d
krXdSt|�S|S)N�integer�long�float�double�blob�	streamingz%Blob values must be a path to a file.�rb�boolean�falseF)rJ�intrwr[r\�os�path�
expandvars�
expanduser�isfiler
�openrorrp�lower�bool)rUr+r�	file_path�msgrrrra�s$

�


racCst|�rdSt|�S)NF)r
�_is_complex_shaper]rrr�_supports_shorthand_syntax�s
r�cCs,|jdvrdS|jdkr|jjdvrdSdS)N)r<rGrHFrGT)rJrRr]rrrr��s

r�c@seZdZdd�ZdS)�ParamShorthandcCsNddgidgdgdgd�dgdgdgdgd	�d
�}|�|i��|g�}||vS)z�
        Determines whether a given operation for a service needs to use the
        deprecated shorthand parsing case for lists of structures that only have
        a single member.
        zput-record-batch�recordszreboot-workspace-requestszrebuild-workspace-requestszterminate-workspace-requests)zreboot-workspaceszrebuild-workspaceszterminate-workspaces�tags�	instances)zremove-tagszdescribe-instance-healthz'deregister-instances-from-load-balancerz%register-instances-with-load-balancer)�firehose�
workspaceszelastic-load-balancing)r\)r�
service_idr-�
argument_name�casesrrr�_uses_old_list_cases����z"ParamShorthand._uses_old_list_caseN)rrrr�rrrrr�sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ParamShorthandParsercCst��|_t��|_dSr5)r�ShorthandParser�_parser�BackCompatVisitor�_visitor�rrrrr"s
zParamShorthandParser.__init__cKs,|�||�sdSt|�\}}|�||||�S)a�Attempt to parse shorthand syntax for values.

        This is intended to be hooked up as an event handler (hence the
        **kwargs).  Given ``param`` object and its string ``value``,
        figure out if we can parse it.  If we can parse it, we return
        the parsed value (typically some sort of python dict).

        :type cli_argument: :class:`awscli.arguments.BaseCLIArgument`
        :param cli_argument: The CLI argument object.

        :type param: :class:`botocore.parameters.Parameter`
        :param param: The parameter object (includes various metadata
            about the parameter).

        :type value: str
        :param value: The value for the parameter type on the command
            line, e.g ``--foo this_value``, value would be ``"this_value"``.

        :returns: If we can parse the value we return the parsed value.
            If it looks like JSON, we return None (which tells the event
            emitter to use the default ``unpack_cli_arg`` provided that
            no other event handlers can parsed the value).  If we
            run into an error parsing the value, a ``ParamError`` will
            be raised.

        N)�_should_parse_as_shorthandr�_parse_as_shorthand)rr1r+�
event_name�kwargsr�r-rrr�__call__&s��zParamShorthandParser.__call__c
s�z@t�d|j���||||�}|dur|WSt|t�r0�fdd�|D�}�j�||j�W|S�j	�
|�}�j�||j�W|StjyU}zt
|jt|���d}~wt
tfyj}zt
|jt|���d}~ww)NzParsing param %s as shorthandcsg|]}�j�|��qSr)r��parserjr�rrrAYsz<ParamShorthandParser._parse_as_shorthand.<locals>.<listcomp>)�LOG�debugr�_handle_special_casesrorGr��visitrUr�r�r�ShorthandParseErrorr
�strr")rr1r+r�r-�
handled_value�parsedrgrr�rr�Js.��

�	����z(ParamShorthandParser._parse_as_shorthandcs�|j}|jdkr3|jjdkr3t|jj�dkr3|�|||j�r3t|jj���d��fdd�|D�}|S|jdkrTt|j�dkrVd|jvrX|jdjdkrZd	|vr\d|iSdSdSdSdSdS)
NrGr<rBrcsg|]}�|i�qSrrrj��key_namerrrA|sz>ParamShorthandParser._handle_special_cases.<locals>.<listcomp>�ValuerZ�=)	rUrJrRrNrLr�r(rG�keys)rr1r+r�r-r^�
new_valuesrr�rr�is(
�

�z*ParamShorthandParser._handle_special_casescCsV|rt|t�r|d}n|}t|tj�r$|���d�r$t�d|j�dS|j	}t
|�S)Nr)rirhz=Param %s looks like JSON, not considered for param shorthand.F)rorGrrprq�
startswithr�r��py_namerUr�)rr1r+�	check_valr^rrrr��s
��z/ParamShorthandParser._should_parse_as_shorthandN)rrrrr�r�r�r�rrrrr� s$#r�c@sZeZdZdZe�ZdZdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�ZdS)�ParamShorthandDocGenz3Documentation generator for param shorthand syntax.�cCs|durt|�SdS)z3Checks if a CLI argument supports shorthand syntax.NF)r�)rrUrrr�supports_shorthand�sz'ParamShorthandDocGen.supports_shorthandcCst|�|||�}||jurdS|r|Sg}z|jjdkr(|jj}|�||�dWS|�|j|�WSty9YdSw)a�Generate documentation for a CLI argument.

        :type cli_argument: awscli.arguments.BaseCLIArgument
        :param cli_argument: The CLI argument which to generate
            documentation for.

        :return: Returns either a string or ``None``.  If a string
            is returned, it is the generated shorthand example.
            If a value of ``None`` is returned then this indicates
            that no shorthand syntax is available for the provided
            ``argument_model``.

        NrGz ...rt)r��	_DONT_DOCrUrJrR�_shorthand_docsr')rr1r�r-�	docstringr8rUrrr�generate_shorthand_example�s �
�z/ParamShorthandDocGen.generate_shorthand_examplecCs�|j}|jdkrG|jjdkrGt|jj�dkrG|�|||j�rGt|jj�d}|j}|�	d�dkr>|�	d�dkr>d|j
|fSd|j
|||fS|jdkrct|j�dkrcd	|jvrc|jd	jd
krc|jSdS)NrGr<rBr�min�maxz%s %s1z%s %s1 %s2 %s3r�rZrt)rUrJrRrNrLr�r(rG�metadatar\rr�)rr1r�r-r^�member_namer�rrrr��s*
���

z*ParamShorthandDocGen._handle_special_casescCs\t|�|jkr
t��|jdkr|�||�S|jdkr |�||�S|jdkr+|�||�S|jS)Nr<rGrH)rN�
_MAX_STACKr'rJ�_structure_docs�
_list_docs�	_map_docs)rrUr8rrrr��s


z$ParamShorthandDocGen._shorthand_docscCsf|j}|�|j�z
|�|j|�}W|��n|��w|jtvs't|�dkr-d||fSd||fS)NrBz[%s,%s]z%s,%s)rRrIr(r�rKrJrrN)rrUr8�list_member�element_docsrrrr��szParamShorthandDocGen._list_docscCs^|j}|�|j|�}d||f}|jr'|s'|d7}|jD]}|d|7}q|S|r-d|}|S)NzKeyName1=%s,KeyName2=%sz

Where valid key names are:
z  %s
�{%s})r%r�r+�enum)rrUr8�k�
value_docs�startr�rrrr��s

�zParamShorthandDocGen._map_docscCsPg}|j��D]\}}t|�rq|�|�|||��qd�|�}|s$|Sd|S)N�,r�)rL�itemsr
rI�_member_docsr$)rrUr8�partsr(�member_shape�
inner_partrrrr�s
z$ParamShorthandDocGen._structure_docscCsP|�|j�dkr
dS|�|j�z|�||�}W|��n|��wd||fS)Nrz( ... recursive ... )z%s=%s)�countr(rIr�rK)rr(�shaper8�	value_docrrrr�sz!ParamShorthandDocGen._member_docsN)rrr�__doc__�objectr�r�r�r�r�r�r�r�r�r�rrrrr��s"r�)rt)(r�r�logging�
awscli.compatr�botocore.compatrr�awsclirrr�awscli.utilsrr	r
�botocore.utilsr�	getLoggerr��	Exceptionr
rr"r'r4r9r7rVr_rTr`rbrar�r�r�r�r�r�rrrr�<module>s8
	 		
	}

https://t.me/RX1948 - 2025