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__/shorthand.cpython-310.pyc
o

@&�atD�@s�dZddlZddlZddlmZe�ZGdd�de�ZGdd�de�Z	Gdd	�d	e	�Z
Gd
d�de	�ZGdd
�d
e�ZGdd�de�Z
Gdd�de�ZGdd�de�ZdS)a�Module for parsing shorthand syntax.

This module parses any CLI options that use a "shorthand"
syntax::

    --foo A=b,C=d
         |------|
            |
            Shorthand syntax


This module provides two main classes to do this.
First, there's a ``ShorthandParser`` class.  This class works
on a purely syntactic level.  It looks only at the string value
provided to it in order to figure out how the string should be parsed.

However, because there was a pre-existing shorthand parser, we need
to remain backwards compatible with the previous parser.  One of the
things the previous parser did was use the associated JSON model to
control how the expression was parsed.

In order to accommodate this a post processing class is provided that
takes the parsed values from the ``ShorthandParser`` as well as the
corresponding JSON model for the CLI argument and makes any adjustments
necessary to maintain backwards compatibility.  This is done in the
``BackCompatVisitor`` class.

�N)�is_document_typec@seZdZdd�Zdd�ZdS)�_NamedRegexcCs||_t�|tj�|_dS�N)�name�re�compile�UNICODE�regex)�selfr�	regex_str�r�2/usr/lib/python3/dist-packages/awscli/shorthand.py�__init__3sz_NamedRegex.__init__cCs|j�|�Sr)r	�match�r
�valuerrr
r7sz_NamedRegex.matchN)�__name__�
__module__�__qualname__rrrrrr
r2src@seZdZdd�ZdS)�ShorthandParseErrorcCs�|jd|j}}}d|jd|j�vr&|jd|j��d�}|j|d}d|j|jd�vrL|j|j|jd��d�}|jd|�}|j|d�}d|d|d|fS)N��
�z%s
%s%s� �^)r�index�rindex)r
�consumed�	remaining�
num_spaces�last_newline�next_newlinerrr
�_error_location=sz#ShorthandParseError._error_locationN)rrrr"rrrr
r;src�$eZdZ�fdd�Zdd�Z�ZS)�ShorthandParseSyntaxErrorcs4||_||_||_||_|��}tt|��|�dSr)r�expected�actualr�_construct_msg�superr$r)r
rr%r&r�msg��	__class__rr
rUsz"ShorthandParseSyntaxError.__init__cCsd|j|j|��f}|S)Nz,Expected: '%s', received: '%s' for input:
%s)r%r&r"�r
r)rrr
r']s�z(ShorthandParseSyntaxError._construct_msg�rrrrr'�
__classcell__rrr*r
r$Tsr$cr#)�DuplicateKeyInObjectErrorcs.||_||_||_|��}tt|��|�dSr)�keyrrr'r(r/r)r
r0rrr)r*rr
rfs
z"DuplicateKeyInObjectError.__init__cCsd|j|��f}|S)NzxSecond instance of key "%s" encountered for input:
%s
This is often because there is a preceding "," instead of a space.)r0r"r,rrr
r'ms�z(DuplicateKeyInObjectError._construct_msgr-rrr*r
r/esr/c@seZdZdS)�DocumentTypesNotSupportedErrorN)rrrrrrr
r1vsr1c@seZdZdZedd�Zedd�ZdZdZdZ	d	Z
ed
dje
eed��Zed
dje
ee	d��Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd>d)d*�Zd+d,�Zd-d.�Zd?d0d1�Zd2d3�Zd4d5�Z d6d7�Z!d8d9�Z"d:d;�Z#d<d=�Z$d(S)@�ShorthandParserz�Parses shorthand syntax in the CLI.

    Note that this parser does not rely on any JSON models to control
    how to parse the shorthand syntax.

    zsingled quotedz\'(?:\\\\|\\\'|[^\'])*\'z
double quotedz"(?:\\\\|\\"|[^"])*"u\!\#-&\(-\+\--\<\>-Z\\-z|-￿u\s\!\#-&\(-\+\--\\\^-\|~-￿u\s\!\#-&\(-\+\--\<\>-￿z(\\,)�firstzC({escaped_comma}|[{start_word}])({escaped_comma}|[{follow_chars}])*)�
escaped_comma�
start_word�follow_chars�secondcCs
g|_dSr)�_tokens�r
rrr
r�s
zShorthandParser.__init__cCs||_d|_|��S)aSParse shorthand syntax.

        For example::

            parser = ShorthandParser()
            parser.parse('a=b')  # {'a': 'b'}
            parser.parse('a=b,c')  # {'a': ['b', 'c']}

        :type value: str
        :param value: Any value that needs to be parsed.

        :return: Parsed value, which will be a dictionary.
        r)�_input_value�_index�
_parameterrrrr
�parse�szShorthandParser.parsecCs�i}|��\}}|||<|j}|jt|j�kr@|jddd�|��\}}||vr1t||j|d��|||<|j}|jt|j�ks|S�N�,T��consume_whitespacer)�_keyvalr;�lenr:�_expectr/)r
�paramsr0�val�
last_indexrrr
r<�s��zShorthandParser._parametercCs&|��}|jddd�|��}||fS)N�=Tr@)�_keyrD�_values)r
r0�valuesrrr
rB�szShorthandParser._keyvalcCsRtjtjd}|j}|��s!|��|vrn|jd7_|��r|j||j�S)Nz-_.#/:r)�string�
ascii_letters�digitsr;�_at_eof�_currentr:)r
�valid_chars�startrrr
rI�s�zShorthandParser._keycCs<|��rdS|��dkr|��S|��dkr|��S|��S)Nr�[�{)rOrP�_explicit_list�
_hash_literal�
_csv_valuer9rrr
rJ�szShorthandParser._valuescCs�|��}|��|��s|j|jdkr|S|jddd�|g}	z!|��}|��|��r5|�|�Wn"|jddd�|�|�WntyU|��rN�|�	d�Ynwq!t
|�dkr_|S|Sr>)�_first_value�_consume_whitespacerOr:r;rD�
_second_value�appendr$�
_backtrack_torC)r
�first_value�csv_list�currentrrr
rW�s2
	
��zShorthandParser._csv_valuecCs>|j�|j|jd��}|dur|�|�}|�dd���SdS)N�\,r?r)�_FIRST_VALUErr:r;�_consume_matched_regex�replace�rstrip)r
�resultrrrr
�_value
s

zShorthandParser._valuecCsp|jddd�g}|��dkr1|��}|�|�|��|��dkr+|�d�|��|��dks|�d�|S)NrSTr@�]r?)rDrP�_explicit_valuesr[rY)r
rKrFrrr
rUs

�
zShorthandParser._explicit_listcC�0|��dkr
|��S|��dkr|��S|��S)NrSrT)rPrUrVrXr9rrr
rh"s
z ShorthandParser._explicit_valuescCs�|jddd�i}|��dkr;|��}|jddd�|��}|��|��dkr1|�d�|��|||<|��dks|�d�|S)NrTTr@�}rHr?)rDrPrIrhrY)r
�keyvalsr0�vrrr
rV+s
�
	zShorthandParser._hash_literalcCri)N�'�")rP�_single_quoted_value�_double_quoted_valuerfr9rrr
rX:s
zShorthandParser._first_valuecC�|j|jdd�S)Nrm��escaped_char)�_consume_quoted�_SINGLE_QUOTEDr9rrr
roBsz$ShorthandParser._single_quoted_valueNcCs:|�|�dd�}|dur|�d||�}|�dd�}|S)Nr���z\%sz\\�\)�_must_consume_regexrc)r
r	rsrrrr
rtHs
zShorthandParser._consume_quotedcCrq)Nrnrr)rt�_DOUBLE_QUOTEDr9rrr
rpO�z$ShorthandParser._double_quoted_valuecCsD|��dkr
|��S|��dkr|��S|�|j�}|�dd���S)Nrmrnr`r?)rProrprx�
_SECOND_VALUErcrd)r
rrrr
rZRszShorthandParser._second_valueFcCsv|r|��|jt|j�krt|j|d|j��|j|j}||kr*t|j|||j��|jd7_|r9|��dSdS)N�EOFr)rYr;rCr:r$)r
�charrAr&rrr
rD[s���zShorthandParser._expectcCs@|�|j|jd��}|dur|�|�St|jd|jd|j��)Nz<%s>z<none>)rr:r;rbr$r)r
r	rerrr
rxis
�z#ShorthandParser._must_consume_regexcCs<|��\}}|j|j||j|�}|j||7_|Sr)�spanr:r;)r
rerR�endrlrrr
rbpsz&ShorthandParser._consume_matched_regexcCs |jt|j�kr|j|jStSr)r;rCr:�_EOFr9rrr
rPvszShorthandParser._currentcCs|jt|j�kSr)r;rCr:r9rrr
rO}rzzShorthandParser._at_eofcCsR|jdkr#|j|j|kr'|jd8_|jdkr%|j|j|ks
dSdSdSdS)Nrr)r;r:)r
r}rrr
r\��*�zShorthandParser._backtrack_tocCsR|��tkr#|��tjvr'|jd7_|��tkr%|��tjvs
dSdSdSdS)Nr)rPr�rL�
whitespacer;r9rrr
rY�r�z#ShorthandParser._consume_whitespacer)F)%rrr�__doc__rrury�_START_WORD�_FIRST_FOLLOW_CHARS�_SECOND_FOLLOW_CHARS�_ESCAPED_COMMA�formatrar{rr=r<rBrIrJrWrfrUrhrVrXrortrprZrDrxrbrPrOr\rYrrrr
r2zsb

����	
0	

	r2c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ModelVisitorcCs|�i|d|�dS)Nr)�_visit)r
rE�modelrrr
�visit�szModelVisitor.visitcCs&t|d|j|j�}|||||�dS)Nz	_visit_%s)�getattr�	type_name�
_visit_scalar)r
�parent�shaperr�methodrrr
r��s�zModelVisitor._visitc	Cs<t|t�sdS|j��D]\}}|�||||�|��qdSr)�
isinstance�dict�members�itemsr��get�r
r�r�rr�member_name�member_shaperrr
�_visit_structure�s

��zModelVisitor._visit_structurecCs6t|t�sdSt|�D]
\}}|�||j||�qdSr)r��list�	enumerater��member)r
r�r�rr�i�elementrrr
�_visit_list�s

�zModelVisitor._visit_listcCs:t|t�sdS|j}|��D]\}}|�||||�qdSr)r�r�rr�r�)r
r�r�rr�value_shape�krlrrr
�
_visit_map�s
�zModelVisitor._visit_mapcCsdSrr�r
r�r�rrrrr
r��szModelVisitor._visit_scalarN)	rrrr�r�r�r�r�r�rrrr
r��sr�cs4eZdZdd�Z�fdd�Zdd�Zdd�Z�ZS)	�BackCompatVisitorc	Csf|�||�t|t�s
dS|j��D]\}}z
|�||||�|��Wqty0td|��wdS)NzwShorthand syntax does not support document types. Use JSON input for top-level argument to specify nested parameter: %s)	�_raise_if_document_type_foundr�r�r�r�r�r�r1rr�rrr
r��s 

�����z"BackCompatVisitor._visit_structurecs:t|t�s|dur|g||<dSdStt|��||||�Sr)r�r�r(r�r�r�r*rr
r��s
�
�zBackCompatVisitor._visit_listcCs�|durdS|j}|dvrt|�||<dS|dvr!t|�||<dS|dkr=|��dkr1d||<dS|��dkr?d||<dSdSdS)N)�integer�long)�double�float�boolean�trueT�falseF)r��intr��lower)r
r�r�rrr�rrr
r��s�zBackCompatVisitor._visit_scalarcCs|durt|�r
t��dSdSr)rr1)r
rr�rrr
r��s�z/BackCompatVisitor._raise_if_document_type_found)rrrr�r�r�r�r.rrr*r
r��s

r�)r�rrL�awscli.utilsr�objectr�r�	Exceptionrr$r/r1r2r�r�rrrr
�<module>s	!

https://t.me/RX1948 - 2025