Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/poplib.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@s�dZddlZddlZddgZdefd��YZdZdZdZd	Z	ee	Z
dfd
��YZyddlZWne
k
r�n$Xdefd��YZejd�ed
kr�ddlZeejd�Zej�GHejejd�ejejd�ej�ej�\ZZx[eded�D]FZeje�\ZZZ deGHxeD]Z!de!GHqxWdGHqJWej"�ndS(s@A POP3 client class.

Based on the J. Myers POP3 draft, Jan. 96
i�NtPOP3terror_protocBseZRS((t__name__t
__module__(((s/sys/lib/python2.7/poplib.pyRsini�s
s
cBs�eZdZeejd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zd
�Zd�Zd�Zd
�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zejd�Zd�Zd�Zdd�Z RS(s�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)

    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.
    cCs^||_||_tj||f|�|_|jjd�|_d|_|j�|_	dS(Ntrbi(
thosttporttsockettcreate_connectiontsocktmakefiletfilet
_debuggingt_getresptwelcome(tselfRRttimeout((s/sys/lib/python2.7/poplib.pyt__init__Os			cCs?|jdkr!dGt|�GHn|jjd|tf�dS(Nis*put*s%s%s(RtreprR	tsendalltCRLF(Rtline((s/sys/lib/python2.7/poplib.pyt_putlineYscCs,|jrdGt|�GHn|j|�dS(Ns*cmd*(RRR(RR((s/sys/lib/python2.7/poplib.pyt_putcmd`s	cCs�|jj�}|jdkr0dGt|�GHn|sEtd��nt|�}|dtkro|d |fS|dtkr�|dd!|fS|d |fS(Nis*get*s-ERR EOFi�ii�(RtreadlineRRRtlenRtCR(RRtoctets((s/sys/lib/python2.7/poplib.pyt_getlineiscCs\|j�\}}|jdkr3dGt|�GHn|d }|dkrXt|��n|S(Nis*resp*t+(RRRR(Rtresptotc((s/sys/lib/python2.7/poplib.pyR
{s
cCs�|j�}g}d}|j�\}}x`|dkr�|d dkr`|d}|d}n||}|j|�|j�\}}q-W|||fS(Nit.is..i(R
Rtappend(RRtlistRRR((s/sys/lib/python2.7/poplib.pyt_getlongresp�s



cCs|j|�|j�S(N(RR
(RR((s/sys/lib/python2.7/poplib.pyt	_shortcmd�s
cCs|j|�|j�S(N(RR$(RR((s/sys/lib/python2.7/poplib.pyt_longcmd�s
cCs|jS(N(R(R((s/sys/lib/python2.7/poplib.pyt
getwelcome�scCs
||_dS(N(R(Rtlevel((s/sys/lib/python2.7/poplib.pytset_debuglevel�scCs|jd|�S(sVSend user name, return response

        (should indicate password required).
        sUSER %s(R%(Rtuser((s/sys/lib/python2.7/poplib.pyR*�scCs|jd|�S(s�Send password, return response

        (response includes message count, mailbox size).

        NB: mailbox is locked by server from here to 'quit()'
        sPASS %s(R%(Rtpswd((s/sys/lib/python2.7/poplib.pytpass_�scCs`|jd�}|j�}|jr6dGt|�GHnt|d�}t|d�}||fS(s]Get mailbox status.

        Result is tuple of 2 ints (message count, mailbox size)
        tSTATs*stat*ii(R%tsplitRRtint(RtretvaltretstnumMessagestsizeMessages((s/sys/lib/python2.7/poplib.pytstat�s	cCs*|dk	r|jd|�S|jd�S(sRequest 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.
        sLIST %stLISTN(tNoneR%R&(Rtwhich((s/sys/lib/python2.7/poplib.pyR#�s	cCs|jd|�S(soRetrieve whole message number 'which'.

        Result is in form ['response', ['line', ...], octets].
        sRETR %s(R&(RR7((s/sys/lib/python2.7/poplib.pytretr�scCs|jd|�S(sFDelete message number 'which'.

        Result is 'response'.
        sDELE %s(R%(RR7((s/sys/lib/python2.7/poplib.pytdele�scCs
|jd�S(sXDoes nothing.

        One supposes the response indicates the server is alive.
        tNOOP(R%(R((s/sys/lib/python2.7/poplib.pytnoop�scCs
|jd�S(s(Unmark all messages marked for deletion.tRSET(R%(R((s/sys/lib/python2.7/poplib.pytrset�scCsYy|jd�}Wntk
r.}|}nX|jj�|jj�|`|`|S(sDSignoff: commit changes on server, unlock mailbox, close connection.tQUIT(R%RRtcloseR	(RRtval((s/sys/lib/python2.7/poplib.pytquit�s


cCs|jd|�S(sNot sure what this does.sRPOP %s(R%(RR*((s/sys/lib/python2.7/poplib.pytrpopss\+OK.*(<[^>]+>)cCs�|jj|j�}|s*td��nddl}|j|jd�|�j�}djt	d�|��}|j
d||f�S(s Authorisation

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

        Args:
                user    - mailbox user;
                secret  - secret shared between client and server.

        NB: mailbox is locked by server from here to 'quit()'
        s!-ERR APOP not supported by serveri�NitcSsdt|�S(Ns%02x(tord(tx((s/sys/lib/python2.7/poplib.pyt<lambda>ss
APOP %s %s(t	timestamptmatchRRthashlibtmd5tgrouptdigesttjointmapR%(RR*tsecrettmRIRL((s/sys/lib/python2.7/poplib.pytapops"cCs|jd||f�S(s�Retrieve message header of message number 'which'
        and first 'howmuch' lines of message body.

        Result is in form ['response', ['line', ...], octets].
        s	TOP %s %s(R&(RR7thowmuch((s/sys/lib/python2.7/poplib.pyttop#scCs*|dk	r|jd|�S|jd�S(s�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]
        sUIDL %stUIDLN(R6R%R&(RR7((s/sys/lib/python2.7/poplib.pytuidl,sN(!RRt__doc__t	POP3_PORTRt_GLOBAL_DEFAULT_TIMEOUTRRRRR
R$R%R&R'R)R*R,R4R6R#R8R9R;R=RARBtretcompileRGRQRSRU(((s/sys/lib/python2.7/poplib.pyR$s4(													
	
									tPOP3_SSLcBsDeZdZeddd�Zd�Zd�Zd�Zd�Z	RS(s�POP3 client class over SSL connection

        Instantiate with: POP3_SSL(hostname, port=995, keyfile=None, certfile=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

            See the methods of the parent class POP3 for more documentation.
        cCsR||_||_||_||_d|_d}d|_x�tj|j|jdtj	�D]�}|\}}}	}
}y,tj|||	�|_|jj
|�Wn;tjk
r�}|jr�|jj�nd|_q^nXPq^W|jstj|�n|jj
d�|_tj|j|j|j�|_d|_|j�|_dS(NRCs!getaddrinfo returns an empty listiR(RRtkeyfiletcertfiletbufferR6R	RtgetaddrinfotSOCK_STREAMtconnectterrorR?R
Rtssltwrap_sockettsslobjRR
R(RRRR\R]tmsgtrestaftsocktypetprotot	canonnametsa((s/sys/lib/python2.7/poplib.pyRJs0						(			!	cCsC|jj�}t|�dkr0td��n|j|7_dS(Nis-ERR EOF(RetreadRRR^(Rtlocalbuf((s/sys/lib/python2.7/poplib.pyt_fillBufferdscCs�d}tjd�}|j|j�}x&|sO|j�|j|j�}q*W|jd�}|jd|jd�|_|jdkr�dGt|�GHnt	|�}|dt
kr�|d |fS|dtkr�dd!|fS|d |fS(NRCs.*?\niis*get*i�i�(RYRZRHR^RoRKtsubRRRRR(RRt	renewlineRHR((s/sys/lib/python2.7/poplib.pyRjs 	
cCs�|jdkr!dGt|�GHn|t7}t|�}xF|dkr|jj|�}||krhPn||}||}q:WdS(Nis*put*i(RRRRRetwrite(RRtbytestsent((s/sys/lib/python2.7/poplib.pyR|s

cCsLy|jd�}Wntk
r.}|}nX|jj�|`|`|S(sDSignoff: commit changes on server, unlock mailbox, close connection.R>(R%RR	R?Re(RRR@((s/sys/lib/python2.7/poplib.pyRA�s

N(
RRRVt
POP3_SSL_PORTR6RRoRRRA(((s/sys/lib/python2.7/poplib.pyR[=s			t__main__iiisMessage %d:s   s-----------------------(#RVRYRt__all__t	ExceptionRRWRuRtLFRRRctImportErrorR[R"RtsystargvtaR'R*R,R#R4tnumMsgst	totalSizetrangetiR8theaderRfRRRA(((s/sys/lib/python2.7/poplib.pyt<module>s>
�
T

	

	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.