ok

Mini Shell

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



���]�"�@s�ddlZddlZddlZddlmZdgZdZdZdZdZ	dZ
d	Zeeee	e
egZGd
d�d�Z
dd�ZdS)
�N)�quote�TemplateZffz-fzf-z--z.-z-.c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)rcCsd|_|j�dS)Nr)�	debugging�reset)�self�r�*/opt/alt/python35/lib64/python3.5/pipes.py�__init__Us	zTemplate.__init__cCsd|jfS)Nz<Template instance, steps=%r>)�steps)rrrr�__repr__ZszTemplate.__repr__cCs
g|_dS)N)r
)rrrrr^szTemplate.resetcCs/t�}|jdd�|_|j|_|S)N)rr
r)r�trrr�clonebs	zTemplate.clonecCs
||_dS)N)r)r�flagrrr�debugjszTemplate.debugcCs�t|�td�k	r$td��|tkrCtd|f��|tkr[td��|jr�|jd
dtkr�td��|ddkr�tjd	|�r�td
��|ddkr�tjd|�r�td��|jj	||f�dS)N�z%Template.append: cmd must be a stringzTemplate.append: bad kind %rz-Template.append: SOURCE can only be prepended�z'Template.append: already ends with SINKr�fz\$IN\bz#Template.append: missing $IN in cmdz\$OUT\bz$Template.append: missing $OUT in cmd���)
�type�	TypeError�	stepkinds�
ValueError�SOURCEr
�SINK�re�search�append)r�cmd�kindrrrrns ##zTemplate.appendcCst|�td�k	r$td��|tkrCtd|f��|tkr[td��|jr�|jddtkr�td��|ddkr�tjd	|�r�td
��|ddkr�tjd|�r�td��|jj	d||f�dS)
Nrz&Template.prepend: cmd must be a stringzTemplate.prepend: bad kind %rz+Template.prepend: SINK can only be appendedrrz,Template.prepend: already begins with SOURCErz\$IN\bz$Template.prepend: missing $IN in cmdz\$OUT\bz%Template.prepend: missing $OUT in cmd)
rrrrrr
rrr�insert)rrrrrr�prepend~s ##zTemplate.prependcCsI|dkr|j|�S|dkr2|j|�Std|f��dS)N�r�wz,Template.open: rw must be 'r' or 'w', not %r)�open_r�open_wr)r�file�rwrrr�open�s

z
Template.opencCs[|jst|d�S|jddtkr9td��|j|d�}tj|d�S)Nr!rz)Template.open_r: pipeline ends width SINKrr)r
r'rr�makepipeline�os�popen)rr%rrrrr#�s	
zTemplate.open_rcCs[|jst|d�S|jddtkr9td��|jd|�}tj|d�S)Nr"rrz,Template.open_w: pipeline begins with SOURCEr)r
r'rrr(r)r*)rr%rrrrr$�s	
zTemplate.open_wcCstj|j||��S)N)r)�systemr()r�infile�outfilerrr�copy�sz
Template.copycCs6t||j|�}|jr2t|�d|}|S)Nzset -x; )r(r
r�print)rr,r-rrrrr(�s
	

zTemplate.makepipelineN)�__name__�
__module__�__qualname__r	rrr
rrr r'r#r$r.r(rrrrrRs

cCstg}x-|D]%\}}|jd||dg�q
W|sU|jddddg�|ddd�\}}|ddkr�|r�|jdddddg�||dd<|ddd�\}}|ddkr�|r�|jddddg�||dd<g}x�tdt|��D]�}||dd}||d}	|ddksj|	ddkr$tj�\}
}tj|
�|j|�|||dd<||d<q$Wx�|D]�}|\}
}}}|ddkr�d	t|�d
|}|ddkr'dt|
�d
|}|ddkrQ|
rQ|d
t|
�}|ddkr{|r{|dt|�}||d<q�W|dd}xw|dd�D]e}|dd�\}}|ddkr�d|kr�d|d}|d|}q�|d|}q�W|rpd}x"|D]}|dt|�}q$Wdt|d�d}|d|d|}|S)Nr�catz--rr�r�zOUT=z; zIN=�-z <z >z{ z; }z |
�
zrm -f� ztrap z; exitz 1 2 3 13 14 15rrrr)	rr�range�len�tempfile�mkstempr)�closer)r,r
r-�listrrZgarbage�iZlkindZrkind�fdZtemp�item�infZoutfZcmdlistZrmcmdr%Ztrapcmdrrrr(�s` 

"

r()rr)r;Zshlexr�__all__ZFILEIN_FILEOUTZ
STDIN_FILEOUTZ
FILEIN_STDOUTZSTDIN_STDOUTrrrrr(rrrr�<module><s	c

Zerion Mini Shell 1.0