AlkantarClanX12

Your IP : 18.216.53.7


Current Path : /proc/thread-self/root/opt/alt/python33/lib64/python3.3/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python33/lib64/python3.3/__pycache__/asynchat.cpython-33.pyo

�
��fD-c@s}dZddlZddlZddlmZGdd�dej�ZGdd�d�ZGdd	�d	�Zd
d�Z	dS(u�A class supporting chat-style (command/response) protocols.

This class adds support for 'chat' style protocols - where one side
sends a 'command', and the other sends a response (examples would be
the common internet protocols - smtp, nntp, ftp, etc..).

The handle_read() method looks at the input stream for the current
'terminator' (usually '\r\n' for single-line responses, '\r\n.\r\n'
for multi-line output), calling self.found_terminator() on its
receipt.

for example:
Say you build an async nntp client using this class.  At the start
of the connection, you'll have self.terminator set to '\r\n', in
order to process the single-line greeting.  Just before issuing a
'LIST' command you'll set it to '\r\n.\r\n'.  The output of the LIST
command will be accumulated (using your own 'collect_incoming_data'
method) up to the terminator, and then control will be returned to
you - by calling your self.found_terminator() method.
iN(udequecBs|EeZdZdZdZdZdZdZd'd'dd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'S((u
async_chatu�This is an abstract class.  You must derive from this class, and add
    the two methods collect_incoming_data() and found_terminator()iiulatin-1cCs8d|_g|_t�|_tjj|||�dS(Ns(uac_in_bufferuincomingudequeu
producer_fifouasyncoreu
dispatcheru__init__(uselfusockumap((u-/opt/alt/python33/lib64/python3.3/asynchat.pyu__init__Ds		uasync_chat.__init__cCstd��dS(Numust be implemented in subclass(uNotImplementedError(uselfudata((u-/opt/alt/python33/lib64/python3.3/asynchat.pyucollect_incoming_dataRsu async_chat.collect_incoming_datacCs|jj|�dS(N(uincominguappend(uselfudata((u-/opt/alt/python33/lib64/python3.3/asynchat.pyu_collect_incoming_dataUsu!async_chat._collect_incoming_datacCs&dj|j�}|jdd�=|S(Ns(ujoinuincoming(uselfud((u-/opt/alt/python33/lib64/python3.3/asynchat.pyu	_get_dataXsuasync_chat._get_datacCstd��dS(Numust be implemented in subclass(uNotImplementedError(uself((u-/opt/alt/python33/lib64/python3.3/asynchat.pyufound_terminator]suasync_chat.found_terminatorcCs:t|t�r-|jr-t||j�}n||_dS(uRSet the input delimiter.  Can be a fixed string of any length, an integer, or NoneN(u
isinstanceustruuse_encodingubytesuencodingu
terminator(uselfuterm((u-/opt/alt/python33/lib64/python3.3/asynchat.pyuset_terminator`suasync_chat.set_terminatorcCs|jS(N(u
terminator(uself((u-/opt/alt/python33/lib64/python3.3/asynchat.pyuget_terminatorfsuasync_chat.get_terminatorcCs`y|j|j�}Wn6tjk
rN}z|j�dSWYdd}~XnXt|t�r||jr|tt|j	�}n|j
||_
x�|j
r[t|j
�}|j�}|s�|j
|j
�d|_
q�t|t�rh|}||kr"|j
|j
�d|_
|j||_qX|j
|j
d|��|j
|d�|_
d|_|j�q�t|�}|j
j|�}|dkr�|dkr�|j
|j
d|��n|j
||d�|_
|j�q�t|j
|�}|r?||kr;|j
|j
d|��|j
|d�|_
nPq�|j
|j
�d|_
q�WdS(Nsiii����(urecvuac_in_buffer_sizeusocketuerroruhandle_erroru
isinstanceustruuse_encodingubytesuencodinguac_in_bufferulenuget_terminatorucollect_incoming_datauintu
terminatorufound_terminatorufindufind_prefix_at_end(uselfudatauwhyulbu
terminatorunuterminator_lenuindex((u-/opt/alt/python33/lib64/python3.3/asynchat.pyuhandle_readnsN
		
	
uasync_chat.handle_readcCs|j�dS(N(u
initiate_send(uself((u-/opt/alt/python33/lib64/python3.3/asynchat.pyuhandle_write�suasync_chat.handle_writecCs|j�dS(N(uclose(uself((u-/opt/alt/python33/lib64/python3.3/asynchat.pyuhandle_close�suasync_chat.handle_closecCs}|j}t|�|kr_xQtdt|�|�D]$}|jj||||��q4Wn|jj|�|j�dS(Ni(uac_out_buffer_sizeulenurangeu
producer_fifouappendu
initiate_send(uselfudatausabsui((u-/opt/alt/python33/lib64/python3.3/asynchat.pyupush�s	%uasync_chat.pushcCs|jj|�|j�dS(N(u
producer_fifouappendu
initiate_send(uselfuproducer((u-/opt/alt/python33/lib64/python3.3/asynchat.pyupush_with_producer�suasync_chat.push_with_producercCsdS(u4predicate for inclusion in the readable for select()i((uself((u-/opt/alt/python33/lib64/python3.3/asynchat.pyureadable�suasync_chat.readablecCs|jp|jS(u4predicate for inclusion in the writable for select()(u
producer_fifou	connected(uself((u-/opt/alt/python33/lib64/python3.3/asynchat.pyuwritable�suasync_chat.writablecCs|jjd�dS(uAautomatically close this channel once the outgoing queue is emptyN(u
producer_fifouappenduNone(uself((u-/opt/alt/python33/lib64/python3.3/asynchat.pyuclose_when_done�suasync_chat.close_when_donecCssxl|jrn|jrn|jd}|sO|jd=|dkrO|j�dSn|j}y|d|�}WnDtk
r�|j�}|r�|jj|�n
|jd=wYnXt|t	�r�|j
r�t||j�}ny|j
|�}Wn#tjk
r|j�dSYnX|rj|t|�ksC|t|�kr]||d�|jd<qj|jd=ndSWdS(Ni(u
producer_fifou	connecteduNoneuhandle_closeuac_out_buffer_sizeu	TypeErrorumoreu
appendleftu
isinstanceustruuse_encodingubytesuencodingusendusocketuerroruhandle_errorulen(uselfufirstuobsudataunum_sent((u-/opt/alt/python33/lib64/python3.3/asynchat.pyu
initiate_send�s8


	


	$
uasync_chat.initiate_sendcCs*d|_|jdd�=|jj�dS(Ns(uac_in_bufferuincomingu
producer_fifouclear(uself((u-/opt/alt/python33/lib64/python3.3/asynchat.pyudiscard_buffers�s	uasync_chat.discard_buffersN(u__name__u
__module__u__qualname__u__doc__uac_in_buffer_sizeuac_out_buffer_sizeuuse_encodinguencodinguNoneu__init__ucollect_incoming_datau_collect_incoming_datau	_get_dataufound_terminatoruset_terminatoruget_terminatoruhandle_readuhandle_writeuhandle_closeupushupush_with_producerureadableuwritableuclose_when_doneu
initiate_sendudiscard_buffers(u
__locals__((u-/opt/alt/python33/lib64/python3.3/asynchat.pyu
async_chat5s,D	*u
async_chatcBs/|EeZdZddd�Zdd�ZdS(usimple_producericCs||_||_dS(N(udataubuffer_size(uselfudataubuffer_size((u-/opt/alt/python33/lib64/python3.3/asynchat.pyu__init__s	usimple_producer.__init__cCset|j�|jkrK|jd|j�}|j|jd�|_|S|j}d|_|SdS(Ns(ulenudataubuffer_size(uselfuresult((u-/opt/alt/python33/lib64/python3.3/asynchat.pyumores		usimple_producer.moreN(u__name__u
__module__u__qualname__u__init__umore(u
__locals__((u-/opt/alt/python33/lib64/python3.3/asynchat.pyusimple_producersusimple_producercBs_|EeZdZd
dd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
S(ufifocCs(|st�|_nt|�|_dS(N(udequeulist(uselfulist((u-/opt/alt/python33/lib64/python3.3/asynchat.pyu__init__su
fifo.__init__cCs
t|j�S(N(ulenulist(uself((u-/opt/alt/python33/lib64/python3.3/asynchat.pyu__len__sufifo.__len__cCs|jS(N(ulist(uself((u-/opt/alt/python33/lib64/python3.3/asynchat.pyuis_emptysu
fifo.is_emptycCs|jdS(Ni(ulist(uself((u-/opt/alt/python33/lib64/python3.3/asynchat.pyufirst"su
fifo.firstcCs|jj|�dS(N(ulistuappend(uselfudata((u-/opt/alt/python33/lib64/python3.3/asynchat.pyupush%su	fifo.pushcCs$|jrd|jj�fSdSdS(Nii(iN(ulistupopleftuNone(uself((u-/opt/alt/python33/lib64/python3.3/asynchat.pyupop(s	ufifo.popN(
u__name__u
__module__u__qualname__uNoneu__init__u__len__uis_emptyufirstupushupop(u
__locals__((u-/opt/alt/python33/lib64/python3.3/asynchat.pyufifosufifocCsEt|�d}x.|r@|j|d|��r@|d8}qW|S(Ni(ulenuendswith(uhaystackuneedleul((u-/opt/alt/python33/lib64/python3.3/asynchat.pyufind_prefix_at_end=s#ufind_prefix_at_end(
u__doc__usocketuasyncoreucollectionsudequeu
dispatcheru
async_chatusimple_producerufifoufind_prefix_at_end(((u-/opt/alt/python33/lib64/python3.3/asynchat.pyu<module>/s�(