Your IP : 3.145.61.142


Current Path : /opt/alt/python33/lib64/python3.3/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/__pycache__/nntplib.cpython-33.pyo

�
��f"�c@s(dZddlZddlZddlZddlZddlZyddlZWnek
rleZ	YnXe
Z	ddlmZ
ddlmZddddd	d
dgZdZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd	�d	e�ZGdd
�d
e�ZdZdZddddddddddd d!hZd"d#d$d%d&d'd(gZid'd)6d(d*6Zd+Zejd,d-d.d/d0g�Zejd1d2d3d*g�Z d4d�Zd5d6�Z!e"d7d8�Z#e"d9d:�Z$ed;d<�Z%e	r6d=d>�Z&nGd?d@�d@�Z'GdAd�de'�Z(e	r�GdBdC�dCe'�Z)ej*dC�ne+dDkr$ddl,Z,ddEl-m.Z.e,j/dFdG�Z0e0j1dHdIdJdKdLdM�e0j1dNdOdJdPdLdQ�e0j1dRdSdJdTdUe2dLdVeef�e0j1dWdXdJdYdUe2dLdZ�e0j1d[d\d]d^dJedLd_�e0j3�Z4e4j5Z5e4jr�e5dTkr�eZ5ne(d`e4j6dae5�Z7n.e5dTkr�eZ5ne)d`e4j6dae5�Z7e7j8�Z9dbe9kre7j:�ne7j;e4j;�\Z<Z=Z>Z?Z@eAdce@dde=dee>dfe?�dgdh�ZBeCe2e?�e4jDdT�Z>e7jEe>e?�\Z<ZFx�eFD]z\ZGZHeeHd#�jIdidT�dZJeeHd"�ZKe2eHd(�ZLeAdjjMeGeBeJdk�eBeKdl�eL��q�We7jN�ndS(mu�An NNTP client class based on:
- RFC 977: Network News Transfer Protocol
- RFC 2980: Common NNTP Extensions
- RFC 3977: Network News Transfer Protocol (version 2)

Example:

>>> from nntplib import NNTP
>>> s = NNTP('news')
>>> resp, count, first, last, name = s.group('comp.lang.python')
>>> print('Group', name, 'has', count, 'articles, range', first, 'to', last)
Group comp.lang.python has 51 articles, range 5770 to 5821
>>> resp, subs = s.xhdr('subject', '{0}-{1}'.format(first, last))
>>> resp = s.quit()
>>>

Here 'resp' is the server response line.
Error responses are turned into exceptions.

To post an article from a file:
>>> f = open(filename, 'rb') # file containing article, including header
>>> resp = s.post(f)
>>>

For descriptions of all methods, read the comments in the code below.
Note that all arguments and return values representing article numbers
are strings, not numbers, since they are rarely used for calculations.
iN(u
decode_header(u_GLOBAL_DEFAULT_TIMEOUTuNNTPuNNTPReplyErroruNNTPTemporaryErroruNNTPPermanentErroruNNTPProtocolErroru
NNTPDataErroru
decode_headericBs&|EeZdZdZdd�ZdS(u	NNTPErroru%Base class for all nntplib exceptionscGsCtj||�y|d|_Wntk
r>d|_YnXdS(NiuNo response given(u	Exceptionu__init__uresponseu
IndexError(uselfuargs((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu__init__bs

uNNTPError.__init__N(u__name__u
__module__u__qualname__u__doc__u__init__(u
__locals__((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu	NNTPError`su	NNTPErrorcBs|EeZdZdZdS(uNNTPReplyErroruUnexpected [123]xx replyN(u__name__u
__module__u__qualname__u__doc__(u
__locals__((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuNNTPReplyErroriscBs|EeZdZdZdS(uNNTPTemporaryErroru
4xx errorsN(u__name__u
__module__u__qualname__u__doc__(u
__locals__((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuNNTPTemporaryErrormscBs|EeZdZdZdS(uNNTPPermanentErroru
5xx errorsN(u__name__u
__module__u__qualname__u__doc__(u
__locals__((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuNNTPPermanentErrorqscBs|EeZdZdZdS(uNNTPProtocolErroru"Response does not begin with [1-5]N(u__name__u
__module__u__qualname__u__doc__(u
__locals__((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuNNTPProtocolErroruscBs|EeZdZdZdS(u
NNTPDataErroruError in response dataN(u__name__u
__module__u__qualname__u__doc__(u
__locals__((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu
NNTPDataErrorysiwi3u100u101u211u215u220u221u222u224u225u230u231u282usubjectufromudateu
message-idu
referencesu:bytesu:linesubytesuliness
u	GroupInfougroupulastufirstuflaguArticleInfounumberu
message_idcCskg}xUt|�D]G\}}t|t�rM|j|j|pCd��q|j|�qWdj|�S(uwTakes an unicode string representing a munged header value
    and decodes it as a (possibly non-ASCII) readable value.uasciiu(u_email_decode_headeru
isinstanceubytesuappendudecodeujoin(u
header_strupartsuvuenc((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu
decode_header�scCs�g}x�|D]�}|ddkrR|dd�jd�\}}}d|}n|jd�\}}}|j�}tj||�}|j|�q
Wt}t|�t|�kr�td��n|dt|��|kr�td��n|S(u�Parse a list of string representing the response to LIST OVERVIEW.FMT
    and return a list of header/metadata names.
    Raises NNTPDataError if the response is not compliant
    (cf. RFC 3977, section 8.4).iu:iNu$LIST OVERVIEW.FMT response too shortu*LIST OVERVIEW.FMT redefines default fields(u	partitionuloweru_OVERVIEW_FMT_ALTERNATIVESugetuappendu_DEFAULT_OVERVIEW_FMTulenu
NNTPDataError(ulinesufmtulineunameu_usuffixudefaults((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_parse_overview_fmt�s
"
u_parse_overview_fmtcCs6tt�}g}x|D]}i}|jd�^}}t|�}x�t|�D]�\}	}
|	t|�krwqSn||	}|jd�}|	|kr	|r	|d}
|
r�|
dt|
��j�|
kr�td��n|
r|
t|
�d�nd}
n|
|||	<qSW|j	||f�qW|S(uYParse the response to a OVER or XOVER command according to the
    overview format `fmt`.u	u:u: Nu?OVER/XOVER response doesn't include names of additional headers(
ulenu_DEFAULT_OVERVIEW_FMTusplituintu	enumerateu
startswithuloweru
NNTPDataErroruNoneuappend(ulinesufmtudata_process_funcu
n_defaultsuoverviewulineufieldsuarticle_numberutokensuiutokenu
field_nameuis_metadatauh((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_parse_overview�s&


(%u_parse_overviewcCs|dkr/|d	d�}|dd
�}nt|dd��}t|dd��}t|dd��}t|dd��}t|dd
��}t|dd��}|dkr�|d7}n|dkr�|d7}ntj||||||�S(u�Parse a pair of (date, time) strings, and return a datetime object.
    If only the date is given, it is assumed to be date and time
    concatenated together (e.g. response to the DATE command).
    iNiiiFi�idili����i����i����i����i����i����(uNoneuintudatetime(udate_strutime_struhoursuminutesusecondsuyearumonthuday((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_parse_datetime�s

u_parse_datetimecCstt|tj�sd}ndj|�}|j}|rX|d}dj||�}ndj||�}||fS(uPFormat a date or datetime object as a pair of (date, time) strings
    in the format required by the NEWNEWS and NEWGROUPS commands.  If a
    date object is passed, the time is assumed to be midnight (00h00).

    The returned representation depends on the legacy flag:
    * if legacy is False (the default):
      date has the YYYYMMDD format and time the HHMMSS format
    * if legacy is True:
      date has the YYMMDD format and time the HHMMSS format.
    RFC 3977 compliant servers should understand both formats; therefore,
    legacy is only needed when talking to old servers.
    u000000u({0.hour:02d}{0.minute:02d}{0.second:02d}idu{0:02d}{1.month:02d}{1.day:02d}u{0:04d}{1.month:02d}{1.day:02d}(u
isinstanceudatetimeuformatuyear(udtulegacyutime_struyudate_str((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_unparse_datetime�s
		
u_unparse_datetimecCs@|dkr3tjtj�}|jtjO_n|j|�S(u�Wrap a socket in SSL/TLS. Arguments:
        - sock: Socket to wrap
        - context: SSL context to use for the encrypted connection
        Returns:
        - sock: New, encrypted socket.
        N(uNoneusslu
SSLContextuPROTOCOL_SSLv23uoptionsuOP_NO_SSLv2uwrap_socket(usockucontext((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_encrypt_onsu_encrypt_oncBs�|EeZdZdZdZdfedd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�ZeZ
dd�Zdd�Zdgdd�Zdd�Zdfdd�Zdd�Zdfdd�Zdfdd�Zdd �Zd!d"�Zd#d$�Zd%dfd&d'�Zd%dfd(d)�Zd%dfdfd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Z d%dfd4d5�Z!d6d7�Z"d8d9�Z#dfd:d;�Z$d<d=�Z%d>d?�Z&dfd@dA�Z'd%dfdfdBdC�Z(d%dfdfdDdE�Z)d%dfdfdFdG�Z*dHdI�Z+d%dfdJdK�Z,d%dfdLdM�Z-d%dfdNdO�Z.d%dfdPdQ�Z/dRdS�Z0dTdU�Z1dVdW�Z2dXdY�Z3dZd[�Z4d\d]�Z5d^d_�Z6dfdfdgd`da�Z7dbdc�Z8e9r�dfddde�Z:ndfS(hu	_NNTPBaseuutf-8usurrogateescapecCs�||_||_d|_|j�|_d|_|j�d|_	|r�d|jkr�|j
�|j	s�d|_|j�q�nd|_d|_dS(uSInitialize an instance.  Arguments:
        - file: file-like object (open for read/write in binary mode)
        - host: hostname of the server
        - readermode: if true, send 'mode reader' command after
                      connecting.
        - timeout: timeout (in seconds) used for socket connections

        readermode is sometimes necessary if you are connecting to an
        NNTP server on the local machine and intend to call
        reader-specific commands, such as `group'.  If you get
        unexpected NNTPPermanentErrors, you might need to set
        readermode.
        iuREADERNF(
uhostufileu	debuggingu_getrespuwelcomeuNoneu_capsugetcapabilitiesuFalseureadermode_afterauthu_setreadermodeutls_onu
authenticated(uselfufileuhostu
readermodeutimeout((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu__init__:s				
		
			u_NNTPBase.__init__cCs|S(N((uself((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu	__enter__isu_NNTPBase.__enter__csl�fdd�}|�rhz0y�j�Wntjtfk
rIYnXWd|�rd�j�nXndS(Ncs
t�d�S(Nufile(uhasattr((uself(u,/opt/alt/python33/lib64/python3.3/nntplib.pyu<lambda>msu$_NNTPBase.__exit__.<locals>.<lambda>(uquitusocketuerroruEOFErroru_close(uselfuargsuis_connected((uselfu,/opt/alt/python33/lib64/python3.3/nntplib.pyu__exit__ls			u_NNTPBase.__exit__cCs)|jr"tdt|j��n|jS(u�Get the welcome message from the server
        (this is read and squirreled away by __init__()).
        If the response code is 200, posting is allowed;
        if it 201, posting is not allowed.u	*welcome*(u	debugginguprinturepruwelcome(uself((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu
getwelcomews	u_NNTPBase.getwelcomec
Cs�|jdkr�d|_d|_y|j�\}}Wn!ttfk
rZi|_Yq�X||_d|kr�ttt	|d��|_nd|kr�dj
|d�|_q�n|jS(u�Get the server capabilities, as read by __init__().
        If the CAPABILITIES command is not supported, an empty dict is
        returned.iuVERSIONuIMPLEMENTATIONu N(u_capsuNoneunntp_versionunntp_implementationucapabilitiesuNNTPPermanentErroruNNTPTemporaryErrorumaxumapuintujoin(uselfurespucaps((u,/opt/alt/python33/lib64/python3.3/nntplib.pyugetcapabilities�s			u_NNTPBase.getcapabilitiescCs
||_dS(u�Set the debugging level.  Argument 'level' means:
        0: no debugging output (default)
        1: print commands and responses but not body text etc.
        2: also print raw lines read and sent before stripping CR/LFN(u	debugging(uselfulevel((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuset_debuglevel�su_NNTPBase.set_debuglevelcCsP|t}|jdkr/tdt|��n|jj|�|jj�dS(ufInternal: send one line to the server, appending CRLF.
        The `line` must be a bytes-like object.iu*put*N(u_CRLFu	debugginguprintureprufileuwriteuflush(uselfuline((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_putline�s

u_NNTPBase._putlinecCsH|jrtdt|��n|j|j|j�}|j|�dS(ulInternal: send one command to the server (through _putline()).
        The `line` must be an unicode string.u*cmd*N(u	debugginguprinturepruencodeuencodinguerrorsu_putline(uselfuline((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_putcmd�s	u_NNTPBase._putcmdcCs�|jjtd�}t|�tkr7td��n|jdkr\tdt|��n|skt�n|r�|dd�t	kr�|dd�}q�|dd�t	kr�|dd	�}q�n|S(
u�Internal: return one line from the server, stripping _CRLF.
        Raise EOFError if the connection is closed.
        Returns a bytes object.iu
line too longu*get*iNi����i����i����i����(
ufileureadlineu_MAXLINEulenu
NNTPDataErroru	debugginguprinturepruEOFErroru_CRLF(uselfu
strip_crlfuline((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_getline�s	u_NNTPBase._getlinecCs�|j�}|jr+tdt|��n|j|j|j�}|dd�}|dkrnt|��n|dkr�t|��n|dkr�t	|��n|S(u�Internal: get a response from the server.
        Raise various errors if the response indicates an error.
        Returns an unicode string.u*resp*Niu4u5u123(
u_getlineu	debugginguprintureprudecodeuencodinguerrorsuNNTPTemporaryErroruNNTPPermanentErroruNNTPProtocolError(uselfurespuc((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_getresp�s	u_NNTPBase._getrespc
CsWd}z0t|ttf�r4t|d�}}n|j�}|dd�tkret|��ng}|dk	r�dtdf}x�|j	d�}||kr�Pn|jd�r�|dd�}n|j|�q�nWd}xN|j	�}||krPn|jd�r%|dd�}n|j
|�q�Wd|rL|j�nX||fS(	uQInternal: get a response plus following text from the server.
        Raise various errors if the response indicates an error.

        Returns a (response, lines) tuple where `response` is an unicode
        string and `lines` is a list of bytes objects.
        If `file` is a file-like object, it must be open in binary mode.
        uwbNis.s.
s..iF(uNoneu
isinstanceustrubytesuopenu_getrespu	_LONGRESPuNNTPReplyErroru_CRLFu_getlineuFalseu
startswithuwriteuappenduclose(uselfufileu
openedFileurespulinesuterminatorsulineu
terminator((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_getlongresp�s8	u_NNTPBase._getlongrespcCs|j|�|j�S(uWInternal: send a command and get the response.
        Same return value as _getresp().(u_putcmdu_getresp(uselfuline((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu	_shortcmd�s
u_NNTPBase._shortcmdcCs|j|�|j|�S(uoInternal: send a command and get the response plus following text.
        Same return value as _getlongresp().(u_putcmdu_getlongresp(uselfulineufile((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_longcmds
u_NNTPBase._longcmdcs?�j|��j|�\}}|�fdd�|D�fS(u�Internal: send a command and get the response plus following text.
        Same as _longcmd() and _getlongresp(), except that the returned `lines`
        are unicode strings rather than bytes objects.
        cs(g|]}|j�j�j��qS((udecodeuencodinguerrors(u.0uline(uself(u,/opt/alt/python33/lib64/python3.3/nntplib.pyu
<listcomp>s	u,_NNTPBase._longcmdstring.<locals>.<listcomp>(u_putcmdu_getlongresp(uselfulineufileurespulist((uselfu,/opt/alt/python33/lib64/python3.3/nntplib.pyu_longcmdstring	s
u_NNTPBase._longcmdstringcCswy|jSWntk
rYnXy|jd�\}}Wn"tk
r]tdd�}Yn
Xt|�}||_|S(uqInternal: get the overview format. Queries the server if not
        already done, else returns the cached value.uLIST OVERVIEW.FMTN(u_cachedoverviewfmtuAttributeErroru_longcmdstringuNNTPPermanentErroru_DEFAULT_OVERVIEW_FMTu_parse_overview_fmt(uselfurespulinesufmt((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_getoverviewfmts

	u_NNTPBase._getoverviewfmtcCsdd�|D�S(NcSs"g|]}t|j���qS((u	GroupInfousplit(u.0uline((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu
<listcomp>&s	u(_NNTPBase._grouplist.<locals>.<listcomp>((uselfulines((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu
_grouplist$su_NNTPBase._grouplistcCsRi}|jd�\}}x*|D]"}|j�^}}|||<q"W||fS(u!Process a CAPABILITIES command.  Not supported by all servers.
        Return:
        - resp: server response if successful
        - caps: a dictionary mapping capability names to lists of tokens
        (for example {'VERSION': ['2'], 'OVER': [], LIST: ['ACTIVE', 'HEADERS'] })
        uCAPABILITIES(u_longcmdstringusplit(uselfucapsurespulinesulineunameutokens((u,/opt/alt/python33/lib64/python3.3/nntplib.pyucapabilities(s
u_NNTPBase.capabilitiesufilecCs�t|tjtjf�s9tdj|jj���nt||jdk�\}}dj||�}|j	||�\}}||j
|�fS(u�Process a NEWGROUPS command.  Arguments:
        - date: a date or datetime object
        Return:
        - resp: server response if successful
        - list: list of newsgroup names
        uAthe date parameter must be a date or datetime object, not '{:40}'iuNEWGROUPS {0} {1}(u
isinstanceudatetimeudateu	TypeErroruformatu	__class__u__name__u_unparse_datetimeunntp_versionu_longcmdstringu
_grouplist(uselfudateufileudate_strutime_strucmdurespulines((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu	newgroups6su_NNTPBase.newgroupscCs|t|tjtjf�s9tdj|jj���nt||jdk�\}}dj|||�}|j	||�S(u�Process a NEWNEWS command.  Arguments:
        - group: group name or '*'
        - date: a date or datetime object
        Return:
        - resp: server response if successful
        - list: list of message ids
        uAthe date parameter must be a date or datetime object, not '{:40}'iuNEWNEWS {0} {1} {2}(
u
isinstanceudatetimeudateu	TypeErroruformatu	__class__u__name__u_unparse_datetimeunntp_versionu_longcmdstring(uselfugroupudateufileudate_strutime_strucmd((u,/opt/alt/python33/lib64/python3.3/nntplib.pyunewnewsFsu_NNTPBase.newnewscCsJ|dk	rd|}nd}|j||�\}}||j|�fS(u@Process a LIST or LIST ACTIVE command. Arguments:
        - group_pattern: a pattern indicating which groups to query
        - file: Filename string or file object to store the result in
        Returns:
        - resp: server response if successful
        - list: list of (group, last, first, flag) (strings)
        uLIST ACTIVE uLISTN(uNoneu_longcmdstringu
_grouplist(uselfu
group_patternufileucommandurespulines((u,/opt/alt/python33/lib64/python3.3/nntplib.pyulistVs

u_NNTPBase.listcCs�tjd�}|jd|�\}}|jd�sS|jd|�\}}ni}xX|D]P}|j|j��}|r`|jdd�\}	}
|s�|
S|
||	<q`q`W|r�||fSdSdS(Nu^(?P<group>[^ 	]+)[ 	]+(.*)$uLIST NEWSGROUPS u215uXGTITLE iiu(ureucompileu_longcmdstringu
startswithusearchustripugroup(uselfu
group_patternu
return_alluline_paturespulinesugroupsuraw_lineumatchunameudesc((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_getdescriptionses

u_NNTPBase._getdescriptionscCs|j|d�S(u�Get a description for a single group.  If more than one
        group matches ('group' is a pattern), return the first.  If no
        group matches, return an empty string.

        This elides the response code from the server, since it can
        only be '215' or '285' (for xgtitle) anyway.  If the response
        code is needed, use the 'descriptions' method.

        NOTE: This neither checks for a wildcard in 'group' nor does
        it check whether the group actually exists.F(u_getdescriptionsuFalse(uselfugroup((u,/opt/alt/python33/lib64/python3.3/nntplib.pyudescription|su_NNTPBase.descriptioncCs|j|d�S(u'Get descriptions for a range of groups.T(u_getdescriptionsuTrue(uselfu
group_pattern((u,/opt/alt/python33/lib64/python3.3/nntplib.pyudescriptions�su_NNTPBase.descriptionscCs�|jd|�}|jd�s1t|��n|j�}d}}}t|�}|dkr�|d}|dkr�|d}|dkr�|d}|dkr�|dj�}q�q�q�n|t|�t|�t|�|fS(uProcess a GROUP command.  Argument:
        - group: the group name
        Returns:
        - resp: server response if successful
        - count: number of articles
        - first: first article number
        - last: last article number
        - name: the group name
        uGROUP u211iiiii(u	_shortcmdu
startswithuNNTPReplyErrorusplitulenuloweruint(uselfunameurespuwordsucountufirstulastun((u,/opt/alt/python33/lib64/python3.3/nntplib.pyugroup�s



u_NNTPBase.groupcCs|jd|�S(uProcess a HELP command. Argument:
        - file: Filename string or file object to store the result in
        Returns:
        - resp: server response if successful
        - list: list of strings returned by the server in response to the
                HELP command
        uHELP(u_longcmdstring(uselfufile((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuhelp�su_NNTPBase.helpcCsQ|jd�st|��n|j�}t|d�}|d}|||fS(u_Internal: parse the response line of a STAT, NEXT, LAST,
        ARTICLE, HEAD or BODY command.u22ii(u
startswithuNNTPReplyErrorusplituint(uselfurespuwordsuart_numu
message_id((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu
_statparse�s
u_NNTPBase._statparsecCs|j|�}|j|�S(u/Internal: process a STAT, NEXT or LAST command.(u	_shortcmdu
_statparse(uselfulineuresp((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_statcmd�su_NNTPBase._statcmdcCs-|r|jdj|��S|jd�SdS(u(Process a STAT command.  Argument:
        - message_spec: article number or message id (if not specified,
          the current article is selected)
        Returns:
        - resp: server response if successful
        - art_num: the article number
        - message_id: the message id
        uSTAT {0}uSTATN(u_statcmduformat(uselfumessage_spec((u,/opt/alt/python33/lib64/python3.3/nntplib.pyustat�s	u_NNTPBase.statcCs
|jd�S(u;Process a NEXT command.  No arguments.  Return as for STAT.uNEXT(u_statcmd(uself((u,/opt/alt/python33/lib64/python3.3/nntplib.pyunext�su_NNTPBase.nextcCs
|jd�S(u;Process a LAST command.  No arguments.  Return as for STAT.uLAST(u_statcmd(uself((u,/opt/alt/python33/lib64/python3.3/nntplib.pyulast�su_NNTPBase.lastcCsF|j||�\}}|j|�\}}}|t|||�fS(u2Internal: process a HEAD, BODY or ARTICLE command.(u_longcmdu
_statparseuArticleInfo(uselfulineufileurespulinesuart_numu
message_id((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_artcmd�su_NNTPBase._artcmdcCs4|dk	rdj|�}nd}|j||�S(u0Process a HEAD command.  Argument:
        - message_spec: article number or message id
        - file: filename string or file object to store the headers in
        Returns:
        - resp: server response if successful
        - ArticleInfo: (article number, message id, list of header lines)
        uHEAD {0}uHEADN(uNoneuformatu_artcmd(uselfumessage_specufileucmd((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuhead�su_NNTPBase.headcCs4|dk	rdj|�}nd}|j||�S(u+Process a BODY command.  Argument:
        - message_spec: article number or message id
        - file: filename string or file object to store the body in
        Returns:
        - resp: server response if successful
        - ArticleInfo: (article number, message id, list of body lines)
        uBODY {0}uBODYN(uNoneuformatu_artcmd(uselfumessage_specufileucmd((u,/opt/alt/python33/lib64/python3.3/nntplib.pyubody�su_NNTPBase.bodycCs4|dk	rdj|�}nd}|j||�S(u5Process an ARTICLE command.  Argument:
        - message_spec: article number or message id
        - file: filename string or file object to store the article in
        Returns:
        - resp: server response if successful
        - ArticleInfo: (article number, message id, list of article lines)
        uARTICLE {0}uARTICLEN(uNoneuformatu_artcmd(uselfumessage_specufileucmd((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuarticle�su_NNTPBase.articlecCs
|jd�S(uYProcess a SLAVE command.  Returns:
        - resp: server response if successful
        uSLAVE(u	_shortcmd(uself((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuslavesu_NNTPBase.slavecsbtjd��|jdj||�|�\}}�fdd��|�fdd�|D�fS(uiProcess an XHDR command (optional server extension).  Arguments:
        - hdr: the header type (e.g. 'subject')
        - str: an article nr, a message id, or a range nr1-nr2
        - file: Filename string or file object to store the result in
        Returns:
        - resp: server response if successful
        - list: list of (nr, value) strings
        u^([0-9]+) ?(.*)
?uXHDR {0} {1}cs)�j|�}|r%|jdd�S|S(Nii(umatchugroup(ulineum(upat(u,/opt/alt/python33/lib64/python3.3/nntplib.pyu
remove_numbersu%_NNTPBase.xhdr.<locals>.remove_numbercsg|]}�|��qS(((u.0uline(u
remove_number(u,/opt/alt/python33/lib64/python3.3/nntplib.pyu
<listcomp>s	u"_NNTPBase.xhdr.<locals>.<listcomp>(ureucompileu_longcmdstringuformat(uselfuhdrustrufileurespulines((upatu
remove_numberu,/opt/alt/python33/lib64/python3.3/nntplib.pyuxhdrs	$u_NNTPBase.xhdrcCsC|jdj||�|�\}}|j�}|t||�fS(uFProcess an XOVER command (optional server extension) Arguments:
        - start: start of range
        - end: end of range
        - file: Filename string or file object to store the result in
        Returns:
        - resp: server response if successful
        - list: list of dicts containing the response fields
        u
XOVER {0}-{1}(u_longcmdstringuformatu_getoverviewfmtu_parse_overview(uselfustartuendufileurespulinesufmt((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuxovers	u_NNTPBase.xoverc	Cs�d|jkrdnd}t|ttf�r[|\}}|dj||pQd�7}n|dk	rx|d|}n|j||�\}}|j�}|t||�fS(u�Process an OVER command.  If the command isn't supported, fall
        back to XOVER. Arguments:
        - message_spec:
            - either a message id, indicating the article to fetch
              information about
            - or a (start, end) tuple, indicating a range of article numbers;
              if end is None, information up to the newest message will be
              retrieved
            - or None, indicating the current article number must be used
        - file: Filename string or file object to store the result in
        Returns:
        - resp: server response if successful
        - list: list of dicts containing the response fields

        NOTE: the "message id" form isn't supported by XOVER
        uOVERuXOVERu {0}-{1}uu N(	u_capsu
isinstanceutupleulistuformatuNoneu_longcmdstringu_getoverviewfmtu_parse_overview(	uselfumessage_specufileucmdustartuendurespulinesufmt((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuover*su_NNTPBase.overc	Cs�tjdtd�tjd�}|jd||�\}}g}xE|D]=}|j|j��}|rK|j|j	dd��qKqKW||fS(u�Process an XGTITLE command (optional server extension) Arguments:
        - group: group name wildcard (i.e. news.*)
        Returns:
        - resp: server response if successful
        - list: list of (name,title) stringsuFThe XGTITLE extension is not actively used, use descriptions() insteadiu^([^ 	]+)[ 	]+(.*)$uXGTITLE i(
uwarningsuwarnuDeprecationWarningureucompileu_longcmdstringusearchustripuappendugroup(	uselfugroupufileuline_paturespu	raw_linesulinesuraw_lineumatch((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuxgtitleEs	

 u_NNTPBase.xgtitlecCs�tjdtd�|jdj|��}|jd�sIt|��ny|j�\}}Wntk
rt|��YnX||fSdS(u�Process an XPATH command (optional server extension) Arguments:
        - id: Message id of article
        Returns:
        resp: server response if successful
        path: directory path to article
        u(The XPATH extension is not actively usediu	XPATH {0}u223N(	uwarningsuwarnuDeprecationWarningu	_shortcmduformatu
startswithuNNTPReplyErrorusplitu
ValueError(uselfuidurespuresp_numupath((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuxpathWs	

u_NNTPBase.xpathcCs�|jd�}|jd�s-t|��n|j�}t|�dkrZt|��n|d}t|�dkr�t|��n|t|d�fS(u�Process the DATE command.
        Returns:
        - resp: server response if successful
        - date: datetime object
        uDATEu111iiiN(u	_shortcmdu
startswithuNNTPReplyErrorusplitulenu
NNTPDataErroru_parse_datetimeuNone(uselfurespuelemudate((u,/opt/alt/python33/lib64/python3.3/nntplib.pyudateks
u_NNTPBase.datecCs�|j|�}|jd�s-t|��nt|ttf�rQ|j�}nx_|D]W}|jt�s�|j	d�t}n|jd�r�d|}n|j
j|�qXW|j
jd�|j
j�|j
�S(Nu3s
s.s.
(u	_shortcmdu
startswithuNNTPReplyErroru
isinstanceubytesu	bytearrayu
splitlinesuendswithu_CRLFurstripufileuwriteuflushu_getresp(uselfucommandufurespuline((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_post|s


u_NNTPBase._postcCs|jd|�S(u�Process a POST command.  Arguments:
        - data: bytes object, iterable or file containing the article
        Returns:
        - resp: server response if successfuluPOST(u_post(uselfudata((u,/opt/alt/python33/lib64/python3.3/nntplib.pyupost�su_NNTPBase.postcCs|jdj|�|�S(uProcess an IHAVE command.  Arguments:
        - message_id: message-id of the article
        - data: file containing the article
        Returns:
        - resp: server response if successful
        Note that if the server refuses the article an exception is raised.u	IHAVE {0}(u_postuformat(uselfu
message_idudata((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuihave�su_NNTPBase.ihavecCs|jj�|`dS(N(ufileuclose(uself((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_close�s
u_NNTPBase._closec
Cs%z|jd�}Wd|j�X|S(udProcess a QUIT command and close the socket.  Returns:
        - resp: server response if successfuluQUITN(u	_shortcmdu_close(uselfuresp((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuquit�su_NNTPBase.quitcCsi|jrtd��n|r5|r5td��ny[|r�|r�ddl}|j�}|j|j�}|r�|d}|d}q�nWntk
r�YnX|s�dS|jd|�}|jd�r|s�t|��q|jd|�}|jd�st	|��qnd|_|j�|j
red	|jkre|j�d|_|j�ndS(
NuAlready logged in.u7At least one of `user` and `usenetrc` must be specifiediiuauthinfo user u381uauthinfo pass u281uREADER(u
authenticatedu
ValueErrorunetrcuauthenticatorsuhostuIOErroru	_shortcmdu
startswithuNNTPReplyErroruNNTPPermanentErroruNoneu_capsugetcapabilitiesureadermode_afterauthu_setreadermode(uselfuuserupassworduusenetrcunetrcucredentialsuauthuresp((u,/opt/alt/python33/lib64/python3.3/nntplib.pyulogin�s<	


	

	u_NNTPBase.logincCsty|jd�|_WnWtk
r*YnFtk
ro}z&|jjd�rZd|_n�WYdd}~XnXdS(Numode readeru480T(u	_shortcmduwelcomeuNNTPPermanentErroruNNTPTemporaryErroruresponseu
startswithuTrueureadermode_afterauth(uselfue((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_setreadermode�s
u_NNTPBase._setreadermodecCs�|jrtd��n|jr0td��n|jd�}|jd�r�|jj�t|j|�|_|jj	d�|_d|_d|_|j
�ntd��dS(	uzProcess a STARTTLS command. Arguments:
            - context: SSL context to use for the encrypted connection
            uTLS is already enabled.u+TLS cannot be started after authentication.uSTARTTLSu382urwbuTLS failed to start.NT(utls_onu
ValueErroru
authenticatedu	_shortcmdu
startswithufileucloseu_encrypt_onusockumakefileuTrueuNoneu_capsugetcapabilitiesu	NNTPError(uselfucontexturesp((u,/opt/alt/python33/lib64/python3.3/nntplib.pyustarttls�s		
		
u_NNTPBase.starttlsNT(;u__name__u
__module__u__qualname__uencodinguerrorsuNoneu_GLOBAL_DEFAULT_TIMEOUTu__init__u	__enter__u__exit__u
getwelcomeugetcapabilitiesuset_debugleveludebugu_putlineu_putcmduTrueu_getlineu_getrespu_getlongrespu	_shortcmdu_longcmdu_longcmdstringu_getoverviewfmtu
_grouplistucapabilitiesu	newgroupsunewnewsulistu_getdescriptionsudescriptionudescriptionsugroupuhelpu
_statparseu_statcmdustatunextulastu_artcmduheadubodyuarticleuslaveuxhdruxoveruoveruxgtitleuxpathudateu_postupostuihaveu_closeuquituloginu_setreadermodeu	_have_sslustarttls(u
__locals__((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu	_NNTPBase*sj
.	.



		)
u	_NNTPBasecBs>|EeZdZeddddedd�Zdd�ZdS(uNNTPc	Cs~||_||_tj||f|�|_|jjd�}tj|||||�|sd|rz|j|||�ndS(u,Initialize an instance.  Arguments:
        - host: hostname to connect to
        - port: port to connect to (default the standard NNTP port)
        - user: username to authenticate with
        - password: password to use with username
        - readermode: if true, send 'mode reader' command after
                      connecting.
        - usenetrc: allow loading username and password from ~/.netrc file
                    if not specified explicitly
        - timeout: timeout (in seconds) used for socket connections

        readermode is sometimes necessary if you are connecting to an
        NNTP server on the local machine and intend to call
        reader-specific commands, such as `group'.  If you get
        unexpected NNTPPermanentErrors, you might need to set
        readermode.
        urwbN(	uhostuportusocketucreate_connectionusockumakefileu	_NNTPBaseu__init__ulogin(	uselfuhostuportuuserupasswordu
readermodeuusenetrcutimeoutufile((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu__init__�s		
u
NNTP.__init__c
Cs&ztj|�Wd|jj�XdS(N(u	_NNTPBaseu_closeusockuclose(uself((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_closesuNNTP._closeNF(	u__name__u
__module__u__qualname__u	NNTP_PORTuNoneuFalseu_GLOBAL_DEFAULT_TIMEOUTu__init__u_close(u
__locals__((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuNNTP�s	c	BsA|EeZdZedddddedd�Zdd�ZdS(uNNTP_SSLc	
Cs�tj||f|�|_t|j|�|_|jjd�}	tj||	|d|d|�|sm|r�|j|||�ndS(u�This works identically to NNTP.__init__, except for the change
            in default port and the `ssl_context` argument for SSL connections.
            urwbu
readermodeutimeoutN(usocketucreate_connectionusocku_encrypt_onumakefileu	_NNTPBaseu__init__ulogin(
uselfuhostuportuuserupasswordussl_contextu
readermodeuusenetrcutimeoutufile((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu__init__&s
uNNTP_SSL.__init__c
Cs&ztj|�Wd|jj�XdS(N(u	_NNTPBaseu_closeusockuclose(uself((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu_close5suNNTP_SSL._closeNF(	u__name__u
__module__u__qualname__u
NNTP_SSL_PORTuNoneuFalseu_GLOBAL_DEFAULT_TIMEOUTu__init__u_close(u
__locals__((u,/opt/alt/python33/lib64/python3.3/nntplib.pyuNNTP_SSL$s
	uNNTP_SSLu__main__(u	parsedateudescriptionuJ        nntplib built-in demo - display the latest articles in a newsgroupu-gu--groupudefaultugmane.comp.python.generaluhelpu3group to fetch messages from (default: %(default)s)u-su--serverunews.gmane.orgu+NNTP server hostname (default: %(default)s)u-pu--portiutypeu#NNTP port number (default: %s / %s)u-nu
--nb-articlesi
u2number of articles to fetch (default: %(default)s)u-Su--ssluactionu
store_trueuuse NNTP over SSLuhostuportuSTARTTLSuGroupuhasuarticles, rangeutocCs1t|�|kr-|d|d�d}n|S(Niu...(ulen(usulim((u,/opt/alt/python33/lib64/python3.3/nntplib.pyucutasucutu<u{:7} {:20} {:42} ({})ii*(Ou__doc__ureusocketucollectionsudatetimeuwarningsussluImportErroruFalseu	_have_ssluTrueuemail.headeru
decode_headeru_email_decode_headeru_GLOBAL_DEFAULT_TIMEOUTu__all__u_MAXLINEu	Exceptionu	NNTPErroruNNTPReplyErroruNNTPTemporaryErroruNNTPPermanentErroruNNTPProtocolErroru
NNTPDataErroru	NNTP_PORTu
NNTP_SSL_PORTu	_LONGRESPu_DEFAULT_OVERVIEW_FMTu_OVERVIEW_FMT_ALTERNATIVESu_CRLFu
namedtupleu	GroupInfouArticleInfou_parse_overview_fmtuNoneu_parse_overviewu_parse_datetimeu_unparse_datetimeu_encrypt_onu	_NNTPBaseuNNTPuNNTP_SSLuappendu__name__uargparseuemail.utilsu	parsedateuArgumentParseruparseruadd_argumentuintu
parse_argsuargsuportuserverusugetcapabilitiesucapsustarttlsugroupurespucountufirstulastunameuprintucutustrunb_articlesuxoveru	overviewsuartnumuoverusplituauthorusubjectulinesuformatuquit(((u,/opt/alt/python33/lib64/python3.3/nntplib.pyu<module>s�&
				
		���&			

	
	
! 	)

?>