HEX
Server: Apache
System: Linux aura.ambarhosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User: chicagos (1295)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python2.7/site-packages/awscli/shorthand.pyc
�
R$�_c@s�dZddlZddlZe�Zdefd��YZdefd��YZdefd��YZd	efd
��YZ	defd��YZ
d
efd��YZdefd��YZdS(s�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.

i����Nt_NamedRegexcBseZd�Zd�ZRS(cCs%||_tj|tj�|_dS(N(tnametretcompiletUNICODEtregex(tselfRt	regex_str((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyt__init__1s	cCs|jj|�S(N(Rtmatch(Rtvalue((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR	5s(t__name__t
__module__RR	(((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR0s	tShorthandParseErrorcBseZd�ZRS(cCs�|jd|j}}}d|j|j kr]|j|j jd�}|j|d}nd|j|jkr�|j|j|jjd�}|j| }|j|}nd|d|d|fS(Nts
is%s
%s%st t^(R
tindextrindex(Rtconsumedt	remainingt
num_spacestlast_newlinetnext_newline((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyt_error_location;s 
(RRR(((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR
9stShorthandParseSyntaxErrorcBseZd�Zd�ZRS(cCsJ||_||_||_||_|j�}tt|�j|�dS(N(R
texpectedtactualRt_construct_msgtsuperRR(RR
RRRtmsg((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRSs				cCs#d|j|j|j�f}|S(Ns,Expected: '%s', received: '%s' for input:
%s(RRR(RR((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR[s(RRRR(((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRRs	tDuplicateKeyInObjectErrorcBseZd�Zd�ZRS(cCsA||_||_||_|j�}tt|�j|�dS(N(tkeyR
RRRRR(RR R
RR((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRds
			cCsd|j|j�f}|S(NsySecond instance of key "%s" encountered for input:
%s
This is often because there is a preceeding "," instead of a space.(R R(RR((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRks(RRRR(((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRcs	tShorthandParserc	BsgeZdZedd�Zedd�ZdZdZdZdZ	ed	d
j
de	ded
e��Zedd
j
de	ded
e��Zd�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd&d�Zd�Zd�Zed�Zd �Z d!�Z!d"�Z"d#�Z#d$�Z$d%�Z%RS('s�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.

    ssingled quoteds\'(?:\\\\|\\\'|[^\'])*\'s
double quoteds"(?:\\\\|\\"|[^"])*"u\!\#-&\(-\+\--\<\>-Z\\-z|-￿u\s\!\#-&\(-\+\--\\\^-\|~-￿u\s\!\#-&\(-\+\--\<\>-￿s(\\,)tfirstuC({escaped_comma}|[{start_word}])({escaped_comma}|[{follow_chars}])*t
escaped_commat
start_wordtfollow_charstsecondcCs
g|_dS(N(t_tokens(R((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR�scCs||_d|_|j�S(sSParse shorthand syntax.

        For example::

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

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

        :return: Parsed value, which will be a dictionary.
        i(t_input_valuet_indext
_parameter(RR
((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pytparse�s		cCs�i}|j�\}}|||<|j}x||jt|j�kr�|jddt�|j�\}}||kr�t||j|d��n|||<|j}q.W|S(Nt,tconsume_whitespacei(t_keyvalR)tlenR(t_expecttTrueR(RtparamsR tvalt
last_index((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR*�s
	

cCs5|j�}|jddt�|j�}||fS(Nt=R-(t_keyR0R1t_values(RR tvalues((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR.�scCsftjtjd}|j}x5|j�sT|j�|krBPn|jd7_q W|j||j!S(Ns-_.#/:i(tstringt
ascii_letterstdigitsR)t_at_eoft_currentR((Rtvalid_charststart((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR6�s	cCsV|j�rdS|j�dkr,|j�S|j�dkrH|j�S|j�SdS(NRt[t{(R<R=t_explicit_listt
_hash_literalt
_csv_value(R((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR7�s

cCs
|j�}|j�|j�s8|j|jdkr<|S|jddt�|g}x�tr�yW|j�}|j�|j�r�|j|�Pn|jddt�|j|�Wq[t	k
r�|j�r��n|j
d�Pq[Xq[Wt|�dkr|S|S(NR,R-i(t_first_valuet_consume_whitespaceR<R(R)R0R1t
_second_valuetappendRt
_backtrack_toR/(Rtfirst_valuetcsv_listtcurrent((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRD�s.
"		


	
	cCsQ|jj|j|j�}|dk	rM|j|�}|jdd�j�SdS(Ns\,R,R(t_FIRST_VALUER	R(R)tNonet_consume_matched_regextreplacetrstrip(RtresultR((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyt_values
cCs�|jddt�g}xe|j�dkr�|j�}|j|�|j�|j�dkr|jd�|j�qqW|jd�|S(NR@R-t]R,(R0R1R=t_explicit_valuesRHRF(RR8R3((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRBs



cCsF|j�dkr|j�S|j�dkr8|j�S|j�SdS(NR@RA(R=RBRCRE(R((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRUs


cCs�|jddt�i}x�|j�dkr�|j�}|jddt�|j�}|j�|j�dkr�|jd�|j�n|||<qW|jd�|S(NRAR-t}R5R,(R0R1R=R6RURF(RtkeyvalsR tv((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRC%s



cCsB|j�dkr|j�S|j�dkr8|j�S|j�S(Nt't"(R=t_single_quoted_valuet_double_quoted_valueRS(R((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRE4s


cCs|j|jdd�S(Ntescaped_charRY(t_consume_quotedt_SINGLE_QUOTED(R((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR[<scCsQ|j|�dd!}|dk	rM|jd||�}|jdd�}n|S(Nii����s\%ss\\s\(t_must_consume_regexRNRP(RRR]R
((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR^Bs
cCs|j|jdd�S(NR]RZ(R^t_DOUBLE_QUOTED(R((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR\IscCsd|j�dkr|j�S|j�dkr8|j�S|j|j�}|jdd�j�SdS(NRYRZs\,R,(R=R[R\R`t
_SECOND_VALUERPRQ(RR((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRGLs

cCs�|r|j�n|jt|j�krIt|j|d|j��n|j|j}||kr�t|j|||j��n|jd7_|r�|j�ndS(NtEOFi(RFR)R/R(R(RtcharR-R((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR0Us
cCsX|j|j|j�}|dk	r2|j|�St|jd|jd|j��dS(Ns<%s>s<none>(R	R(R)RNRORR(RRRR((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR`cs

cCsG|j�\}}|j|j||j|!}|j||7_|S(N(tspanR(R)(RRRR?tendRX((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyROjscCs*|jt|j�kr&|j|jStS(N(R)R/R(t_EOF(R((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR=pscCs|jt|j�kS(N(R)R/R((R((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR<wscCs?x8|jdkr:|j|j|kr:|jd8_qWdS(Nii(R)R((RRd((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRIzs(cCsAx:|j�tkr<|j�tjkr<|jd7_qWdS(Ni(R=RgR9t
whitespaceR)(R((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRF~s*N(&RRt__doc__RR_Rat_START_WORDt_FIRST_FOLLOW_CHARSt_SECOND_FOLLOW_CHARSt_ESCAPED_COMMAtformatRMRbRR+R*R.R6R7RDRSRBRURCRER[RNR^R\RGtFalseR0R`ROR=R<RIRF(((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR!tsT							
		0															tModelVisitorcBs>eZd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs|ji|d|�dS(NR(t_visit(RR2tmodel((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pytvisit�scCs3t|d|j|j�}|||||�dS(Ns	_visit_%s(tgetattrt	type_namet
_visit_scalar(RtparenttshapeRR
tmethod((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRq�scCsVt|t�sdSx<|jj�D]+\}}|j||||j|��q#WdS(N(t
isinstancetdicttmemberstitemsRqtget(RRwRxRR
tmember_nametmember_shape((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyt_visit_structure�s
cCsMt|t�sdSx3t|�D]%\}}|j||j||�q WdS(N(Rztlistt	enumerateRqtmember(RRwRxRR
titelement((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyt_visit_list�scCsSt|t�sdS|j}x0|j�D]"\}}|j||||�q)WdS(N(RzR{R
R}Rq(RRwRxRR
tvalue_shapetkRX((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyt
_visit_map�s
	cCsdS(N((RRwRxRR
((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRv�s(RRRsRqR�R�R�Rv(((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRp�s					tBackCompatVisitorcBseZd�Zd�ZRS(cCsQt|t�s.|dk	rM|g||<qMntt|�j||||�SdS(N(RzR�RNRR�R�(RRwRxRR
((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR��s
cCs�|dkrdS|j}|dkr8t|�||<nl|d	krWt|�||<nM|dkr�|j�dkr�t||<q�|j�dkr�t||<q�ndS(
Ntintegertlongtdoubletfloattbooleanttruetfalse(sintegerslong(sdoublesfloat(RNRutintR�tlowerR1Ro(RRwRxRR
Ru((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyRv�s	
(RRR�Rv(((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyR��s	
(
RiRR9tobjectRgRt	ExceptionR
RRR!RpR�(((s4/usr/lib/python2.7/site-packages/awscli/shorthand.pyt<module>(s		�!