a �DOg�4�@s�ddlZddlZddlZddlmZddlmZgd�ZGdd�d�Zdd d �Z d d �Z e� d ej �j Zdd�Zdd�Zedkr�eej�dkr�ee��n@ejdZee��Zeeee��Wd�n1s�0YdS)�N)�deque)�StringIO)�shlex�split�quote�joinc@sneZdZddd�Zedd��Zdd�Zdd d �Zd d �Zd d�Z dd�Z dd�Z ddd�Z dd�Z dd�ZdS)rNFcCst|t�rt|�}|dur(||_||_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 ur�d}||_|�rt�|_|j d7_ |j �t�|��}|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)�selfrrr�punctuation_chars�t�r-�/usr/lib64/python3.9/shlex.py�__init__sJ zshlex.__init__cCs|jS�N)r$�r*r-r-r.r+Dszshlex.punctuation_charscCs*|jdkrtdt|��|j�|�dS)Nr zshlex: pushing token )r �print�reprr� appendleft)r*�tokr-r-r.� push_tokenHs zshlex.push_tokencCspt|t�rt|�}|j�|j|j|jf�||_||_d|_|jrl|dur\t d|jf�nt d|jf�dS)Nr zshlex: pushing to file %szshlex: pushing to stream %s) rrrr"r4rrrr r2)r*� newstream�newfiler-r-r.� push_sourceNs zshlex.push_sourcecCsD|j��|j��\|_|_|_|jr:td|j|jf�d|_dS)Nzshlex: popping to %s, line %dr ) r�closer"�popleftrrr r2rr1r-r-r.� pop_source\s  �zshlex.pop_sourcecCs�|jr.|j��}|jdkr*tdt|��|S|��}|jdurz||jkrz|�|���}|rp|\}}|�||�|� �}q@||j kr�|j s�|j S|� �|� �}qz|jdkr�||j kr�tdt|��ntd�|S)Nr zshlex: popping token z shlex: token=zshlex: token=EOF) rr;r r2r3� read_tokenr#� sourcehookr9� get_tokenrr"r<)r*r5�raw�specr8r7r-r-r.r?es.          zshlex.get_tokencCs�d}d}|jr |jr |j��}n |j�d�}|dkrB|jd7_|jdkr^td|j|f�|jdurtd|_ �q�q|jdk�r�|s�d|_�q��q�||j vr�|jdkr�td �|j s�|j r|r�q�nqn�||j vr�|j� �|jd7_n�|j �r ||jv�r d }||_n�||jv�r&||_ d |_nr||jv�r@||_ d |_nX||jv�rb|j �sZ||_ ||_n6|j�rx||_ d |_n ||_ |j �s�|j r|r�q�nqq|j|jv�rDd }|�s�|jdk�r�td �td��||jk�r|j �s�|j |7_ d|_�q�nd |_n>|j �r4||jv�r4|j|jv�r4|j}||_n|j |7_ q|j|jv�r�|�st|jdk�rltd�td��||jv�r�||jk�r�||k�r�|j |j7_ |j |7_ ||_q|jdvr|�s�d|_�q�q||j v�r|jdk�r�td�d|_|j �s�|j r|r�q�nqq||j v�rh|j� �|jd7_|j �r�d|_|j �s�|j r|r�q�nqq|jd k�r�||jv�r�|j |7_ n"||j v�r�|j�|�d|_�q�q|j �r�||jv�r�||_q|j �r�||jv�r�d }||_q||jv�s||jv�s|j�r,||jv�r,|j |7_ q|j�rB|j�|�n |j�|�|jdk�rbtd�d|_|j �s�|j r|r�q�qqq|j }d|_ |j �r�|�s�|dk�r�d}|jdk�r�|�r�tdt|��ntd�|S)NFr r � �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 character)rErFz%shlex: I see whitespace in word statez&shlex: I see punctuation in word statezshlex: raw token=zshlex: raw token=EOF)r+r%�popr�readrr r2rr!rrr�readlinerrrr� ValueErrorr�appendrr4r3)r*ZquotedZ escapedstateZnextchar�resultr-r-r.r=�s     �           �  ��         ��   zshlex.read_tokencCsV|ddkr|dd�}t|jt�rHtj�|�sHtj�tj�|j�|�}|t|d�fS)Nrr r ������r) rrr�os�path�isabsr�dirname�open)r*r8r-r-r.r>s   zshlex.sourcehookcCs(|dur|j}|dur|j}d||fS)Nz"%s", line %d: )rr)r*rrr-r-r.� error_leader s zshlex.error_leadercCs|Sr0r-r1r-r-r.�__iter__(szshlex.__iter__cCs|��}||jkrt�|Sr0)r?r� StopIteration)r*r!r-r-r.�__next__+s zshlex.__next__)NNFF)N)NN)�__name__� __module__� __qualname__r/�propertyr+r6r9r<r?r=r>rTrUrWr-r-r-r.rs� /     rFTcCsD|dur ddl}|jdtdd�t||d�}d|_|s@�zjoin..)r)Z split_commandr-r-r.r>srz[^\w@%+=:,./-]cCs,|sdSt|�dur|Sd|�dd�dS)Nz''�'z'"'"')� _find_unsafe�replace)rar-r-r.rEs  rcCs$|��}|sq tdt|��qdS)NzToken: )r?r2r3)Zlexer�ttr-r-r.� _print_tokensQsrj�__main__r )FT)rO�rer� collectionsr�ior�__all__rrr�compile�ASCII�searchrgrrjrX�len�argv�fnrS�fr-r-r-r.� s&