Your IP : 3.139.239.25


Current Path : /opt/alt/python36/lib64/python3.6/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/__pycache__/shlex.cpython-36.pyc

3

� f�2�@s�dZddlZddlZddlZddlmZddlmZdddgZGdd�d�Z	ddd�Z
ejdej�j
Zd
d�Zdd�Zedkr�eej�dkr�ee	��n,ejdZee��Zee	ee��WdQRXdS)z8A lexical analyzer class for simple shell-like syntaxes.�N)�deque)�StringIO�shlex�split�quotec@sfeZdZdZddd�Zdd�Zddd	�Zd
d�Zdd
�Zdd�Z	dd�Z
ddd�Zdd�Zdd�Z
dS)rz8A lexical analyzer class for simple shell-like syntaxes.NFcCst|t�rt|�}|dk	r(||_||_ntj|_d|_||_|rHd|_nd|_d|_	d|_
|jrn|j
d7_
d|_d|_d|_
d|_d	|_d
|_t�|_d|_d|_d|_t�|_d|_|s�d}n|d
kr�d}||_|�rt�|_|j
d7_
|j
jtj|��}|j
j|�|_
dS)N��#Z?abcdfeghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_u|ßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞz 	
Fz'"�\�"� �rTz();<>|&z~-./*?=)�
isinstance�strr�instream�infile�sys�stdin�posix�eof�
commenters�	wordchars�
whitespace�whitespace_split�quotes�escape�
escapedquotes�stater�pushback�lineno�debug�token�	filestack�source�punctuation_chars�_pushback_chars�	maketrans�dict�fromkeys�	translate)�selfrrrr#�t�r+�*/opt/alt/python36/lib64/python3.6/shlex.py�__init__sJ
zshlex.__init__cCs*|jdkrtdt|��|jj|�dS)z:Push a token onto the stack popped by the get_token methodrzshlex: pushing token N)r�print�reprr�
appendleft)r)�tokr+r+r,�
push_tokenDs
zshlex.push_tokencCspt|t�rt|�}|jj|j|j|jf�||_||_d|_|jrl|dk	r\t	d|jf�nt	d|jf�dS)z9Push an input source onto the lexer's input source stack.rNzshlex: pushing to file %szshlex: pushing to stream %s)
r
rrr!r0rrrrr.)r)�	newstream�newfiler+r+r,�push_sourceJs
zshlex.push_sourcecCsD|jj�|jj�\|_|_|_|jr:td|j|jf�d|_dS)zPop the input source stack.zshlex: popping to %s, line %drN)	r�closer!�popleftrrrr.r)r)r+r+r,�
pop_sourceXs
zshlex.pop_sourcecCs�|jr.|jj�}|jdkr*tdt|��|S|j�}|jdk	r~x<||jkr||j|j��}|rr|\}}|j||�|j	�}qBWx*||j
kr�|js�|j
S|j�|j	�}q�W|jdkr�||j
kr�tdt|��ntd�|S)zBGet a token from the input stream (or from stack if it's nonempty)rzshlex: popping token Nz
shlex: token=zshlex: token=EOF)
rr7rr.r/�
read_tokenr"�
sourcehookr5�	get_tokenrr!r8)r)r1�raw�specr4r3r+r+r,r;as.




zshlex.get_tokencCs�d}d}�x\|jr$|jr$|jj�}n|jjd�}|dkrF|jd7_|jdkrbtd|j|f�|jdkrvd|_	Pq|jdk�r�|s�d|_P�qd||j
kr�|jdkr�td	�|j	s�|jr|rPnqn�||jkr�|jj
�|jd7_n�|jo�||jk�rd
}||_n�||jk�r"||_	d
|_np||jk�r<||_	d|_nV||jk�r^|j�sV||_	||_n4|j�rt||_	d
|_n||_	|j	�s�|jr|rPnqq|j|jk�r<d}|�s�|jdk�r�td
�td��||jk�r�|j�s�|j	|7_	d|_Pnd
|_n>|j�r,||jk�r,|j|jk�r,|j}||_n|j	|7_	q|j|jk�r�|�sl|jdk�rdtd�td��||jk�r�||jk�r�||k�r�|j	|j7_	|j	|7_	||_q|jdkr|�s�d|_Pq||j
k�r|jdk�r�td�d|_|j	�s|jr|rPnqq||jk�rZ|jj
�|jd7_|j�rdd|_|j	�sR|jr|rPnqq|jdk�r�||jk�r�|j	|7_	n ||j
k�r�|jj|�d|_Pq|j�r�||jk�r�||_q|j�r�||jk�r�d
}||_q||jk�s||jk�s|j�r|j	|7_	q|j�r&|jj|�n|jj|�|jdk�rFtd�d|_|j	�s^|jr|rPqqqW|j	}d|_	|j�r�|�r�|dk�r�d}|jdk�r�|�r�tdt|��ntd�|S)NFrr�
�z&shlex: in state %r I see character: %rr�z+shlex: I see whitespace in whitespace state�a�cTz shlex: I see EOF in quotes statezNo closing quotationz shlex: I see EOF in escape statezNo escaped characterz%shlex: I see whitespace in word statez&shlex: I see punctuation in word statezshlex: raw token=zshlex: raw token=EOF)rArB)r#r$�popr�readrrr.rr rrr�readlinerrrr�
ValueErrorr�appendrr0r/)r)ZquotedZescapedstateZnextchar�resultr+r+r,r9�s�









zshlex.read_tokencCsX|ddkr|dd�}t|jt�rJtjj|�rJtjjtjj|j�|�}|t|d�fS)z(Hook called on a filename to be sourced.rr
r�r���)	r
rr�os�path�isabs�join�dirname�open)r)r4r+r+r,r:s
zshlex.sourcehookcCs(|dkr|j}|dkr|j}d||fS)z<Emit a C-compiler-like, Emacs-friendly error-message leader.Nz"%s", line %d: )rr)r)rrr+r+r,�error_leaders
zshlex.error_leadercCs|S)Nr+)r)r+r+r,�__iter__#szshlex.__iter__cCs|j�}||jkrt�|S)N)r;r�
StopIteration)r)r r+r+r,�__next__&s
zshlex.__next__)NNFF)N)NN)�__name__�
__module__�__qualname__�__doc__r-r2r5r8r;r9r:rQrRrTr+r+r+r,rs
.
	 	
FTcCs$t||d�}d|_|sd|_t|�S)N)rTr)rrr�list)�sZcommentsrZlexr+r+r,r,s
z[^\w@%+=:,./-]cCs,|sdSt|�dkr|Sd|jdd�dS)z1Return a shell-escaped version of the string *s*.z''N�'z'"'"')�_find_unsafe�replace)rZr+r+r,r6s
cCs(x"|j�}|sPtdt|��qWdS)NzToken: )r;r.r/)ZlexerZttr+r+r,�
_print_tokensBs
r^�__main__r)FT)rXrK�rer�collectionsr�ior�__all__rr�compile�ASCII�searchr\rr^rU�len�argv�fnrP�fr+r+r+r,�<module>s&	





?>