Your IP : 52.15.113.71


Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/cmd.cpython-35.opt-2.pyc



���]:�@sRddlZddlZdgZdZejejdZGdd�d�ZdS)�N�Cmdz(Cmd) �_c@s9eZdZeZeZdZdZdZ	dZ
dZdZdZ
dZdZd	ddd
d�Zddd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Z d,d-d.�Z!dS)/r�=�Nz(Documented commands (type help <topic>):zMiscellaneous help topics:zUndocumented commands:z*** No help on %s�ZtabcCs^|dk	r||_ntj|_|dk	r<||_ntj|_g|_||_dS)N)�stdin�sys�stdout�cmdqueue�completekey)�selfrrr	�r
�(/opt/alt/python35/lib64/python3.5/cmd.py�__init__Ls	zCmd.__init__cCs�|j�|jrt|jrtyCddl}|j�|_|j|j�|j|jd�Wnt	k
rsYnXz7|dk	r�||_
|j
r�|jjt
|j
�d�d}x�|s�|jr�|jjd�}n�|jryt|j�}Wqltk
rd}YqlXnS|jj|j�|jj�|jj�}t|�s]d}n|jd�}|j|�}|j|�}|j||�}q�W|j�Wd|jr�|jr�y ddl}|j|j�Wnt	k
r�YnXXdS)Nrz
: complete�
�EOFz
)�preloop�use_rawinputr�readlineZ
get_completerZ
old_completerZ
set_completer�complete�parse_and_bind�ImportError�intror	�write�strr
�pop�input�prompt�EOFError�flushr�len�rstrip�precmd�onecmd�postcmd�postloop)rrr�stop�liner
r
r�cmdloopbsN

					

	
zCmd.cmdloopcCs|S)Nr
)rr'r
r
rr"�sz
Cmd.precmdcCs|S)Nr
)rr&r'r
r
rr$�szCmd.postcmdcCsdS)Nr
)rr
r
rr�szCmd.preloopcCsdS)Nr
)rr
r
rr%�szCmd.postloopcCs|j�}|sdd|fS|ddkrFd|dd�}nC|ddkr�t|d�r|d|dd�}n
dd|fSdt|�}}x-||kr�|||jkr�|d}q�W|d|�||d�j�}}|||fS)Nr�?zhelp r�!Zdo_shellzshell )�strip�hasattrr �
identchars)rr'�i�n�cmd�argr
r
r�	parseline�s

"'z
Cmd.parselinecCs�|j|�\}}}|s(|j�S|dkrA|j|�S||_|dkr_d|_|dkrx|j|�Syt|d|�}Wntk
r�|j|�SYnX||�SdS)Nrr�do_)r2�	emptyline�default�lastcmd�getattr�AttributeError)rr'r0r1�funcr
r
rr#�s


		

z
Cmd.onecmdcCs|jr|j|j�SdS)N)r6r#)rr
r
rr4�s	z
Cmd.emptylinecCs|jjd|�dS)Nz*** Unknown syntax: %s
)r	r)rr'r
r
rr5�szCmd.defaultcGsgS)Nr
)r�ignoredr
r
r�completedefault�szCmd.completedefaultcs'd|��fdd�|j�D�S)Nr3cs/g|]%}|j��r|dd��qS)�N)�
startswith)�.0�a)�dotextr
r�
<listcomp>�s	z%Cmd.completenames.<locals>.<listcomp>)�	get_names)r�textr:r
)r@r�
completenames�s
zCmd.completenamesc
Cs'|dkr�ddl}|j�}|j�}t|�t|�}|j�|}|j�|}|dkr�|j|�\}	}
}|	dkr�|j}q�yt|d|	�}Wq�t	k
r�|j}Yq�Xn	|j
}|||||�|_y|j|SWntk
r"dSYnXdS)NrrZ	complete_)
rZget_line_buffer�lstripr Z
get_begidxZ
get_endidxr2r;r7r8rDZcompletion_matches�
IndexError)
rrC�staterZorigliner'�strippedZbegidxZendidxr0�argsZfooZcompfuncr
r
rr�s*
	
zCmd.completecCs
t|j�S)N)�dir�	__class__)rr
r
rrBsz
Cmd.get_namescsHt|j���}t�fdd�|j�D��}t||B�S)Nc3s6|],}|jd�d�r|dd�VqdS)�help_r�N)r=)r>r?)rIr
r�	<genexpr> sz$Cmd.complete_help.<locals>.<genexpr>)�setrDrB�list)rrI�commandsZtopicsr
)rIr�
complete_helps%zCmd.complete_helpcCs6|r�yt|d|�}Wn�tk
r�y>t|d|�j}|rj|jjdt|��dSWntk
rYnX|jjdt|j|f��dSYnX|�n{|j�}g}g}i}x8|D]0}|dd�dkr�d||dd�<q�W|j�d}	x�|D]�}|dd�dkr'||	krRq'|}	|dd�}
|
|kr�|j	|
�||
=q't||�jr�|j	|
�q'|j	|
�q'W|jjdt|j
��|j|j|dd	�|j|j
t|j��dd	�|j|j|dd	�dS)
NrLr3z%s
rMrrr<��P)r7r8�__doc__r	rr�nohelprB�sort�append�
doc_leader�print_topics�
doc_header�misc_headerrP�keys�undoc_header)rr1r9�doc�namesZcmds_docZ
cmds_undoc�help�nameZprevnamer0r
r
r�do_help$sN

$	





%zCmd.do_helpcCsx|rt|jjdt|��|jrP|jjdt|jt|���|j||d�|jjd�dS)Nz%s
rr)r	rr�rulerr �	columnize)r�headerZcmdsZcmdlenZmaxcolr
r
rrZRs	'zCmd.print_topicsrTcs��s|jjd�dS�fdd�tt���D�}|rgtddjtt|����t��}|dkr�|jjdt�d��dSx�tdt���D]�}||d|}g}d}x�t|�D]�}	d}
xNt|�D]@}|||	}||kr"P�|}
t|
t|
��}
qW|j	|
�||
d	7}||kr�Pq�W||kr�Pq�Wt��}d}dg}x�t|�D]�}g}xNt|�D]@}	|||	}||kr�d
}
n
�|}
|j	|
�q�Wx|r%|d
r%|d=q
Wx5tt|��D]!}	||	j
||	�||	<q9W|jjdtdj|���q�WdS)Nz<empty>
cs)g|]}t�|t�s|�qSr
)�
isinstancer)r>r.)rPr
rrAds	z!Cmd.columnize.<locals>.<listcomp>z list[i] not a string for i in %sz, rz%s
r�rz  ������rj)r	r�ranger �	TypeError�join�mapr�maxrX�ljust)rrPZdisplaywidthZ
nonstrings�sizeZnrowsZncolsZ	colwidthsZtotwidth�colZcolwidth�rowr.�xZtextsr
)rPrreZsZ%

		
z
Cmd.columnize)"�__name__�
__module__�__qualname__�PROMPTr�
IDENTCHARSr-rdr6rrYr[r\r^rVrrr(r"r$rr%r2r#r4r5r;rDrrBrRrcrZrer
r
r
rr4s:4
		.)�stringr�__all__rx�
ascii_letters�digitsryrr
r
r
r�<module>-s	

?>