AlkantarClanX12

Your IP : 18.217.208.220


Current Path : /opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/__pycache__/poplib.cpython-34.pyo

�
e f�7�
@s�dZddlZddlZddlZyddlZdZWnek
rZdZYnXddgZGdd�de�Z	dZ
d	Zd
ZdZ
ee
ZdZGd
d�d�Zer�Gdd�de�Zejd�nedkr�ddlZeejd�Zeej��ejejd�ejejd�ej�ej�\ZZxjeded�D]UZ ej!e �\Z"Z#Z$ede �xe#D]Z%ede%�q�Wed�qwWej&�ndS)z@A POP3 client class.

Based on the J. Myers POP3 draft, Jan. 96
�NTF�POP3�error_protoc@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�+/opt/alt/python34/lib64/python3.4/poplib.pyrs�ni�s
s
ic@s�eZdZdZdZeejdd�Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zejd0�Z d1d2�Z!d3d4�Z"dd5d6�Z#d7d8�Z$dd9d:�Z%dS);ra%This class supports both the minimal and optional command sets.
    Arguments can be strings or integers (where appropriate)
    (e.g.: retr(1) and retr('1') both work equally well.

    Minimal Command Set:
            USER name               user(name)
            PASS string             pass_(string)
            STAT                    stat()
            LIST [msg]              list(msg = None)
            RETR msg                retr(msg)
            DELE msg                dele(msg)
            NOOP                    noop()
            RSET                    rset()
            QUIT                    quit()

    Optional Commands (some servers support these):
            RPOP name               rpop(name)
            APOP name digest        apop(name, digest)
            TOP msg n               top(msg, n)
            UIDL [msg]              uidl(msg = None)
            CAPA                    capa()
            STLS                    stls()

    Raises one exception: 'error_proto'.

    Instantiate with:
            POP3(hostname, port=110)

    NB:     the POP protocol locks the mailbox from user
            authorization until QUIT, so be sure to get in, suck
            the messages, and quit, each time you access the
            mailbox.

            POP is a line-based protocol, which means large mail
            messages consume lots of python cycles reading them
            line-by-line.

            If it's available on your mail server, use IMAP4
            instead, it doesn't suffer from the two problems
            above.
    zUTF-8cCs^||_||_d|_|j|�|_|jjd�|_d|_|j�|_	dS)NF�rbr)
�host�port�_tls_established�_create_socket�sock�makefile�file�
_debugging�_getresp�welcome)�selfrr�timeoutrrr�__init__`s				z
POP3.__init__cCstj|j|jf|�S)N)�socketZcreate_connectionrr)rrrrrrjszPOP3._create_socketcCs=|jdkr%tdt|��n|jj|t�dS)N�z*put*)r�print�reprrZsendall�CRLF)r�linerrr�_putlinemsz
POP3._putlinecCsB|jrtdt|��nt||j�}|j|�dS)Nz*cmd*)rrr�bytes�encodingr)rrrrr�_putcmdts	zPOP3._putcmdcCs�|jjtd�}t|�tkr7td��n|jdkr\tdt|��n|sqtd��nt|�}|dd�tkr�|dd�|fS|dd�t	kr�|dd�|fS|dd	�|fS)
Nrz
line too longz*get*z-ERR EOF����r#���r$)
r�readline�_MAXLINE�lenrrrrr�CR)rr�octetsrrr�_getline~sz
POP3._getlinecCsY|j�\}}|jdkr7tdt|��n|jd�sUt|��n|S)Nrz*resp*�+)r*rrr�
startswithr)r�resp�orrrr�sz
POP3._getrespcCs�|j�}g}d}|j�\}}xe|dkr�|jd�re|d}|dd�}n||}|j|�|j�\}}q-W|||fS)Nr�.s..r)rr*r,�append)rr-�listr)rr.rrr�_getlongresp�s


zPOP3._getlongrespcCs|j|�|j�S)N)r!r)rrrrr�	_shortcmd�s
zPOP3._shortcmdcCs|j|�|j�S)N)r!r2)rrrrr�_longcmd�s
z
POP3._longcmdcCs|jS)N)r)rrrr�
getwelcome�szPOP3.getwelcomecCs
||_dS)N)r)r�levelrrr�set_debuglevel�szPOP3.set_debuglevelcCs|jd|�S)zVSend user name, return response

        (should indicate password required).
        zUSER %s)r3)r�userrrrr8�sz	POP3.usercCs|jd|�S)z�Send password, return response

        (response includes message count, mailbox size).

        NB: mailbox is locked by server from here to 'quit()'
        zPASS %s)r3)rZpswdrrr�pass_�sz
POP3.pass_cCsd|jd�}|j�}|jr:tdt|��nt|d�}t|d�}||fS)z]Get mailbox status.

        Result is tuple of 2 ints (message count, mailbox size)
        ZSTATz*stat*rr")r3�splitrrr�int)rZretvalZretsZnumMessagesZsizeMessagesrrr�stat�s	z	POP3.statNcCs*|dk	r|jd|�S|jd�S)aRequest listing, return result.

        Result without a message number argument is in form
        ['response', ['mesg_num octets', ...], octets].

        Result when a message number argument is given is a
        single response: the "scan listing" for that message.
        NzLIST %sZLIST)r3r4)r�whichrrrr1�s	z	POP3.listcCs|jd|�S)zoRetrieve whole message number 'which'.

        Result is in form ['response', ['line', ...], octets].
        zRETR %s)r4)rr=rrr�retr�sz	POP3.retrcCs|jd|�S)zFDelete message number 'which'.

        Result is 'response'.
        zDELE %s)r3)rr=rrr�dele�sz	POP3.delecCs
|jd�S)zXDoes nothing.

        One supposes the response indicates the server is alive.
        ZNOOP)r3)rrrr�noopsz	POP3.noopcCs
|jd�S)z(Unmark all messages marked for deletion.ZRSET)r3)rrrr�rset
sz	POP3.rsetcCs|jd�}|j�|S)zDSignoff: commit changes on server, unlock mailbox, close connection.ZQUIT)r3�close)rr-rrr�quits
z	POP3.quitcCs�z/|j}d|_|dk	r.|j�nWd|j}d|_|dk	r�zXy|jtj�Wn=tk
r�}z|jtjkr��nWYdd}~XnXWd|j�XnXdS)z8Close the connection without assuming anything about it.N)	rrBrZshutdownrZ	SHUT_RDWR�OSError�errnoZENOTCONN)rrr�errrrBs				z
POP3.closecCs|jd|�S)zNot sure what this does.zRPOP %s)r3)rr8rrr�rpop.sz	POP3.rpops\+OK.[^<]*(<.*>)cCs�t||j�}|jj|j�}|s<td��nddl}|jd�|}|j|�j	�}|j
d||f�S)aAuthorisation

        - only possible if server has supplied a timestamp in initial greeting.

        Args:
                user     - mailbox user;
                password - mailbox password.

        NB: mailbox is locked by server from here to 'quit()'
        z!-ERR APOP not supported by serverrNrz
APOP %s %s)rr �	timestamp�matchrr�hashlib�groupZmd5Z	hexdigestr3)rr8ZpasswordZsecret�mrJZdigestrrr�apop5sz	POP3.apopcCs|jd||f�S)z�Retrieve message header of message number 'which'
        and first 'howmuch' lines of message body.

        Result is in form ['response', ['line', ...], octets].
        z	TOP %s %s)r4)rr=Zhowmuchrrr�topJszPOP3.topcCs*|dk	r|jd|�S|jd�S)z�Return message digest (unique id) list.

        If 'which', result contains unique id for that message
        in the form 'response mesgnum uid', otherwise result is
        the list ['response', ['mesgnum uid', ...], octets]
        NzUIDL %sZUIDL)r3r4)rr=rrr�uidlSsz	POP3.uidlc	Cs�dd�}i}yJ|jd�}|d}x*|D]"}||�\}}|||<q5WWn1tk
r�}ztd��WYdd}~XnX|S)aReturn server capabilities (RFC 2449) as a dictionary
        >>> c=poplib.POP3('localhost')
        >>> c.capa()
        {'IMPLEMENTATION': ['Cyrus', 'POP3', 'server', 'v2.2.12'],
         'TOP': [], 'LOGIN-DELAY': ['0'], 'AUTH-RESP-CODE': [],
         'EXPIRE': ['NEVER'], 'USER': [], 'STLS': [], 'PIPELINING': [],
         'UIDL': [], 'RESP-CODES': []}
        >>>

        Really, according to RFC 2449, the cyrus folks should avoid
        having the implementation split into multiple arguments...
        cSs-|jd�j�}|d|dd�fS)N�asciirr)�decoder:)rZlstrrr�	_parsecaplszPOP3.capa.<locals>._parsecapZCAPArz!-ERR CAPA not supported by serverN)r4r)	rrR�capsr-ZrawcapsZcaplineZcapnmZcapargsZ_errrrr�capa_s


z	POP3.capacCs�tstd��n|jr-td��n|j�}d|krTtd��n|dkrotj�}n|jd�}|j|jd|j	�|_|jj
d�|_d|_|S)	z{Start a TLS session on the active connection as specified in RFC 2595.

                context - a ssl.SSLContext
        z-ERR TLS support missingz$-ERR TLS session already establishedZSTLSz!-ERR STLS not supported by serverN�server_hostnamer
T)�HAVE_SSLrr
rT�ssl�_create_stdlib_contextr3�wrap_socketrrrr)r�contextrSr-rrr�stls|s		z	POP3.stls)&rrr�__doc__r �	POP3_PORTr�_GLOBAL_DEFAULT_TIMEOUTrrrr!r*rr2r3r4r5r7r8r9r<r1r>r?r@rArCrBrG�re�compilerHrMrNrOrTr[rrrrr2s>*	



	c@sUeZdZdZeddejddd�Zdd�Zddddd�Z	dS)	�POP3_SSLaPOP3 client class over SSL connection

        Instantiate with: POP3_SSL(hostname, port=995, keyfile=None, certfile=None,
                                   context=None)

               hostname - the hostname of the pop3 over ssl server
               port - port number
               keyfile - PEM formatted file that contains your private key
               certfile - PEM formatted certificate chain file
               context - a ssl.SSLContext

        See the methods of the parent class POP3 for more documentation.
        NcCs�|dk	r'|dk	r'td��n|dk	rN|dk	rNtd��n||_||_|dkr�tjd|d|�}n||_tj||||�dS)Nz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusive�certfile�keyfile)�
ValueErrorrcrbrWrXrZrr)rrrrcrbrrZrrrr�s			zPOP3_SSL.__init__cCs1tj||�}|jj|d|j�}|S)NrU)rrrZrYr)rrrrrrr�szPOP3_SSL._create_socketcCstd��dS)z�The method unconditionally raises an exception since the
            STLS command doesn't make any sense on an already established
            SSL/TLS session.
            z$-ERR TLS session already establishedN)r)rrcrbrZrrrr[�sz
POP3_SSL.stls)
rrrr\�
POP3_SSL_PORTrr^rrr[rrrrra�s

	ra�__main__rr"�zMessage %d:z   z-----------------------)'r\rEr_rrWrV�ImportError�__all__�	Exceptionrr]rer(ZLFrr&rrar0r�sys�argv�arr5r8r9r1r<ZnumMsgsZ	totalSize�range�ir>�header�msgr)rrCrrrr�<module>sH


�a,