选择文件�文件大�最�修改时间�作
[📄] 36r5hq6kq6.74 KB2026-10-03 04:04:28
[📄] assets_ee72a41.php3.45 KB2026-09-30 15:33:41
[📄] dpack.php7.91 KB2026-10-03 05:40:27
[📄] filemanager_rcttbwr.php43.54 KB2026-10-02 09:50:09
[📄] image_3ff7dc4.php5.57 KB2026-09-30 15:27:22
a ´i? ã @s>dZddlZddlZddlZddlZddlZz ddlZWneyNdZYn0dZddl m Z ddlm Z gd¢Z dZGd d „d eƒZGd d „d eƒZGd d„deƒZGdd„deƒZGdd„deƒZGdd„deƒZdZdZhd£Zgd¢ZdddœZdZe dgd¢¡Ze dgd ¢¡Zd!d"„Z d#d$„ZdZd%d&„Z d[d'd(„Z!d\d)d*„Z"e�rZd+d,„Z#Gd-d.„d.ƒZ$e�rˆGd/d0„d0e$ƒZ%e  &d0¡e'd1k�r:ddl(Z(e(j)d2d3�Z*e*j+d4d5d6d7d8�e*j+d9d:d;dd?e,d@eefdA�e*j+dBdCdDe,dEdA�e*j+dFdGdHddIdJ�e* -¡Z.e.j/Z/e.j�sBe/d?k�r2eZ/e$e.j0e/dK�Z1ne/d?k�rPeZ/e%e.j0e/dK�Z1e1 2¡Z3dLe3v�rxe1 4¡e1 5e.j5¡\Z6Z7Z8Z9Z:e;dMe:dNe7dOe8dPe9ƒdQdR„ZdSƒZ8e1 ?e8e9¡\Z6Z@e@D]Z\ZAZBe eBdTƒ CdUdS¡dZDe eBdVƒZEe,eBdƒZFe;dW GeAe>> 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. éNFT)Ú decode_header)Ú_GLOBAL_DEFAULT_TIMEOUT)ÚNNTPÚ NNTPErrorÚNNTPReplyErrorÚNNTPTemporaryErrorÚNNTPPermanentErrorÚNNTPProtocolErrorÚ NNTPDataErrorric@seZdZdZdd„ZdS)rz%Base class for all nntplib exceptionscGs>tj|g|¢RŽz|d|_Wnty8d|_Yn0dS)NrzNo response given)Ú ExceptionÚ__init__ÚresponseÚ IndexError)ÚselfÚargs©rú/usr/lib64/python3.9/nntplib.pyr bs  zNNTPError.__init__N)Ú__name__Ú __module__Ú __qualname__Ú__doc__r rrrrr`src@seZdZdZdS)rzUnexpected [123]xx replyN©rrrrrrrrrisrc@seZdZdZdS)rz 4xx errorsNrrrrrrmsrc@seZdZdZdS)rz 5xx errorsNrrrrrrqsrc@seZdZdZdS)r z"Response does not begin with [1-5]Nrrrrrr usr c@seZdZdZdS)r zError in response dataNrrrrrr ysr éwi3> Z220Z231Z100Ú211Z101Z221Ú215Z224Z282Z225Z230Z222)ÚsubjectÚfromÚdatez message-idZ referencesú:bytesú:linesrr)ÚbytesÚlinesó Ú GroupInfo)ÚgroupÚlastÚfirstÚflagÚ ArticleInfo)ÚnumberÚ message_idr!cCsJg}t|ƒD]2\}}t|tƒr4| | |p,d¡¡q | |¡q d |¡S)zvTakes a unicode string representing a munged header value and decodes it as a (possibly non-ASCII) readable value.ÚasciiÚ)Ú_email_decode_headerÚ isinstancer ÚappendÚdecodeÚjoin)Z header_strÚpartsÚvÚencrrrr§s   rcCs¦g}|D]`}|ddkr:|dd… d¡\}}}d|}n| d¡\}}}| ¡}t ||¡}| |¡qt}t|ƒt|ƒkr†tdƒ‚|dt|ƒ…|kr¢tdƒ‚|S)zÐ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).rú:éNz$LIST OVERVIEW.FMT response too shortz*LIST OVERVIEW.FMT redefines default fields)Ú partitionÚlowerÚ_OVERVIEW_FMT_ALTERNATIVESÚgetr/Ú_DEFAULT_OVERVIEW_FMTÚlenr )r!ÚfmtÚlineÚnameÚ_ÚsuffixÚdefaultsrrrÚ_parse_overview_fmt²s    rCcCsÐttƒ}g}|D]º}i}| d¡^}}t|ƒ}t|ƒD]„\} } | t|ƒkrLq6|| } |  d¡} | |kr®| s®| d} | r–| dt| ƒ… ¡| kr–tdƒ‚| rª| t| ƒd…nd} | ||| <q6| ||f¡q|S)zZParse the response to an OVER or XOVER command according to the overview format `fmt`.ú r5z: Nz?OVER/XOVER response doesn't include names of additional headers) r<r;ÚsplitÚintÚ enumerateÚ startswithr8r r/)r!r=Zdata_process_funcZ n_defaultsZoverviewr>ÚfieldsZarticle_numberÚtokensÚiÚtokenÚ field_nameZ is_metadataÚhrrrÚ_parse_overviewËs&   rOcCs¶|dur |dd…}|dd…}t|dd…ƒ}t|dd…ƒ}t|dd…ƒ}t|dd…ƒ}t|dd…ƒ}t|dd…ƒ}|dkr’|d7}n|d kr¢|d 7}t ||||||¡S) zÈ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). NiúÿÿÿéééüÿÿÿéþÿÿÿéFiÐédil)rFÚdatetime)Údate_strÚtime_strZhoursZminutesZsecondsÚyearZmonthZdayrrrÚ_parse_datetimeès   rZcCsPt|tjƒsd}n d |¡}|j}|r<|d}d ||¡}n d ||¡}||fS)aPFormat 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. Z000000z({0.hour:02d}{0.minute:02d}{0.second:02d}rUz{0:02d}{1.month:02d}{1.day:02d}z{0:04d}{1.month:02d}{1.day:02d})r.rVÚformatrY)ZdtÚlegacyrXÚyrWrrrÚ_unparse_datetimeþs   r^cCs|durt ¡}|j||d�S)zÇ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)Zserver_hostname)ÚsslZ_create_stdlib_contextZ wrap_socket)ÚsockÚcontextÚhostnamerrrÚ _encrypt_onsrcc@seZdZdZdZeddddefdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dd„ZeZdd„Zdd„Zdidd„Zdd„Zdjdd„Zd d!„Zdkd"d#„Zdld$d%„Zd&d'„Zd(d)„Zd*d+„Zdd,œd-d.„Zdd,œd/d0„Zdmdd,œd1d2„Zd3d4„Zd5d6„Zd7d8„Z d9d:„Z!dd,œd;d<„Z"d=d>„Z#d?d@„Z$dndAdB„Z%dCdD„Z&dEdF„Z'dodGdH„Z(dpdd,œdIdJ„Z)dqdd,œdKdL„Z*drdd,œdMdN„Z+dOdP„Z,dd,œdQdR„Z-dd,œdSdT„Z.dd,œdUdV„Z/dWdX„Z0dYdZ„Z1d[d\„Z2d]d^„Z3d_d`„Z4dadb„Z5dsdcdd„Z6dedf„Z7e8�rdtdgdh„Z9dS)urzutf-8ÚsurrogateescapeNFcCs~||_||_| |¡|_d|_z2|j d¡|_| |¡|s@|rN| |||¡Wn(|jrh|j ¡|j ¡‚Yn0dS)a,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. NÚrwb) ÚhostÚportÚ_create_socketr`ÚfileÚmakefileÚ _base_initÚloginÚclose)rrfrgÚuserÚpasswordÚ readermodeÚusenetrcÚtimeoutrrrr 8s    z NNTP.__init__cCs^d|_| ¡|_d|_| ¡d|_|rNd|jvrN| ¡|jsNd|_| ¡d|_d|_dS)z~Partial initialization for the NNTP protocol. This instance method is extracted for supporting the test code. rNFÚREADER) Ú debuggingÚ_getrespÚwelcomeÚ_capsÚgetcapabilitiesÚreadermode_afterauthÚ_setreadermodeÚtls_onÚ authenticated)rrprrrrk[s  zNNTP._base_initcCs|S©Nr©rrrrÚ __enter__}szNNTP.__enter__c s^‡fdd„}|ƒrZz6z ˆ ¡Wnttfy6Yn0W|ƒrZˆ ¡n|ƒrXˆ ¡0dS)Ncs tˆdƒS)Nri)Úhasattrrr~rrÚ�ózNNTP.__exit__..)ÚquitÚOSErrorÚEOFErrorÚ_close)rrZ is_connectedrr~rÚ__exit__€s   ÿz NNTP.__exit__cCs<|dur|stdƒ‚t d||j|j¡t |j|jf|¡S)Nz0Non-blocking socket (timeout=0) is not supportedznntplib.connect)Ú ValueErrorÚsysÚauditrfrgÚsocketÚcreate_connection)rrrrrrrh‹s zNNTP._create_socketcCs|jrtdt|jƒƒ|jS)zÅ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.z *welcome*)rtÚprintÚreprrvr~rrrÚ getwelcome‘szNNTP.getwelcomec Cs„|jdur~d|_d|_z| ¡\}}WnttfyBi|_Yn<0||_d|vrfttt|dƒƒ|_d|vr~d  |d¡|_|jS)zŒGet the server capabilities, as read by __init__(). If the CAPABILITIES command is not supported, an empty dict is returned.Nr6ÚVERSIONZIMPLEMENTATIONú ) rwÚ nntp_versionZnntp_implementationÚ capabilitiesrrÚmaxÚmaprFr1)rÚrespÚcapsrrrrxšs  zNNTP.getcapabilitiescCs ||_dS)zÞ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)rt)rÚlevelrrrÚset_debuglevel°szNNTP.set_debuglevelcCsHt d||¡|t}|jdkr.tdt|ƒƒ|j |¡|j ¡dS)zfInternal: send one line to the server, appending CRLF. The `line` must be a bytes-like object.znntplib.putliner6z*put*N) r‰rŠÚ_CRLFrtr�rŽriÚwriteÚflush©rr>rrrÚ_putline¹s  z NNTP._putlinecCs2|jrtdt|ƒƒ| |j|j¡}| |¡dS)zkInternal: send one command to the server (through _putline()). The `line` must be a unicode string.z*cmd*N)rtr�rŽÚencodeÚencodingÚerrorsržr�rrrÚ_putcmdÂsz NNTP._putcmdTcCs†|j td¡}t|ƒtkr$tdƒ‚|jdkrrrrÚ_getlineÉs   z NNTP._getlinecCsl| ¡}|jrtdt|ƒƒ| |j|j¡}|dd…}|dkrHt|ƒ‚|dkrXt|ƒ‚|dvrht |ƒ‚|S)zŒInternal: get a response from the server. Raise various errors if the response indicates an error. Returns a unicode string.z*resp*Nr6Ú4Ú5Z123) r¦rtr�rŽr0r r¡rrr )rr–ÚcrrrruÚs z NNTP._getrespcCsðd}zÔt|ttfƒr"t|dƒ}}| ¡}|dd…tvrBt|ƒ‚g}|dur’dtdf}| d¡}||vrnqÊ|  d¡r„|dd…}|  |¡qZn8d}| ¡}||kr¨qÊ|  d¡r¾|dd…}|  |¡q–W|rè|  ¡n|ræ|  ¡0||fS) aPInternal: 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 a unicode string and `lines` is a list of bytes objects. If `file` is a file-like object, it must be open in binary mode. NÚwbéó.s. Fs..r6) r.Ústrr ÚopenruÚ _LONGRESPrršr¦rHr›r/rm)rriZ openedFiler–r!Z terminatorsr>Ú terminatorrrrÚ _getlongrespês8        ÿ zNNTP._getlongrespcCs| |¡| ¡S)zWInternal: send a command and get the response. Same return value as _getresp().)r¢rur�rrrÚ _shortcmds zNNTP._shortcmdcCs| |¡| |¡S)zoInternal: send a command and get the response plus following text. Same return value as _getlongresp().©r¢r±)rr>rirrrÚ_longcmds z NNTP._longcmdcs.ˆ |¡ˆ |¡\}}|‡fdd„|DƒfS)zÒ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. csg|]}| ˆjˆj¡‘qSr)r0r r¡©Ú.0r>r~rrÚ +sÿz'NNTP._longcmdstring..r³)rr>rir–Úlistrr~rÚ_longcmdstring$s   ÿzNNTP._longcmdstringcCs`z|jWStyYn0z| d¡\}}WntyLtdd…}Yn 0t|ƒ}||_|S)zqInternal: get the overview format. Queries the server if not already done, else returns the cached value.zLIST OVERVIEW.FMTN)Z_cachedoverviewfmtÚAttributeErrorr¹rr;rC)rr–r!r=rrrÚ_getoverviewfmt.s  zNNTP._getoverviewfmtcCsdd„|DƒS)NcSsg|]}t| ¡Ž‘qSr)r#rErµrrrr·Ar‚z#NNTP._grouplist..r)rr!rrrÚ _grouplist?szNNTP._grouplistcCs8i}| d¡\}}|D]}| ¡^}}|||<q||fS)a!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'] }) Z CAPABILITIES)r¹rE)rr—r–r!r>r?rJrrrr“Cs   zNNTP.capabilities)ricCsbt|tjtjfƒs$td |jj¡ƒ‚t||jdkƒ\}}d ||¡}|  ||¡\}}||  |¡fS)zÁProcess a NEWGROUPS command. Arguments: - date: a date or datetime object Return: - resp: server response if successful - list: list of newsgroup names úAthe date parameter must be a date or datetime object, not '{:40}'rPzNEWGROUPS {0} {1}) r.rVrÚ TypeErrorr[Ú __class__rr^r’r¹r¼)rrrirWrXÚcmdr–r!rrrÚ newgroupsQsÿÿ zNNTP.newgroupscCsRt|tjtjfƒs$td |jj¡ƒ‚t||jdkƒ\}}d |||¡}|  ||¡S)zÞ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 r½rPzNEWNEWS {0} {1} {2}) r.rVrr¾r[r¿rr^r’r¹)rr$rrirWrXrÀrrrÚnewnewsasÿÿz NNTP.newnewscCs4|durd|}nd}| ||¡\}}|| |¡fS)a@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) Nz LIST ACTIVE ÚLIST)r¹r¼)rÚ group_patternriÚcommandr–r!rrrr¸qs  z NNTP.listc Cs�t d¡}| d|¡\}}| d¡s8| d|¡\}}i}|D]:}| | ¡¡}|r@| dd¡\} } |sr| S| || <q@|rˆ||fSdSdS)Nz^(?P[^ ]+)[ ]+(.*)$zLIST NEWSGROUPS rzXGTITLE r6rPr,)ÚreÚcompiler¹rHÚsearchÚstripr$) rrÄZ return_allZline_patr–r!ÚgroupsZraw_lineÚmatchr?ZdescrrrÚ_getdescriptions€s   zNNTP._getdescriptionscCs | |d¡S)aé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©rÌ)rr$rrrÚ description—s zNNTP.descriptioncCs | |d¡S)z'Get descriptions for a range of groups.TrÍ)rrÄrrrÚ descriptions¤szNNTP.descriptionscCsš| d|¡}| d¡s t|ƒ‚| ¡}d}}}t|ƒ}|dkr€|d}|dkr€|d}|dkr€|d}|dkr€|d ¡}|t|ƒt|ƒt|ƒ|fS)aProcess 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 zGROUP rrr6rPr«rQ)r²rHrrEr<r8rF)rr?r–ÚwordsÚcountr&r%Únrrrr$¨s    z NNTP.groupcCs | d|¡S)aProcess 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 ZHELP)r¹)rrirrrÚhelpÂsz NNTP.helpcCs8| d¡st|ƒ‚| ¡}t|dƒ}|d}|||fS)z_Internal: parse the response line of a STAT, NEXT, LAST, ARTICLE, HEAD or BODY command.Z22r6rP)rHrrErF)rr–rÐÚart_numr*rrrÚ _statparseÌs   zNNTP._statparsecCs| |¡}| |¡S)z/Internal: process a STAT, NEXT or LAST command.)r²rÕ)rr>r–rrrÚ_statcmdÖs z NNTP._statcmdcCs"|r| d |¡¡S| d¡SdS)a(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 zSTAT {0}ZSTATN)rÖr[)rÚ message_specrrrÚstatÛs z NNTP.statcCs | d¡S)z;Process a NEXT command. No arguments. Return as for STAT.ZNEXT©rÖr~rrrÚnextész NNTP.nextcCs | d¡S)z;Process a LAST command. No arguments. Return as for STAT.ZLASTrÙr~rrrr%ísz NNTP.lastcCs0| ||¡\}}| |¡\}}}|t|||ƒfS)z2Internal: process a HEAD, BODY or ARTICLE command.)r´rÕr()rr>rir–r!rÔr*rrrÚ_artcmdñsz NNTP._artcmdcCs$|durd |¡}nd}| ||¡S)a0Process 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) NzHEAD {0}ZHEAD©r[rÛ©rr×rirÀrrrÚhead÷s z NNTP.headcCs$|durd |¡}nd}| ||¡S)a+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) NzBODY {0}ZBODYrÜrÝrrrÚbodys z NNTP.bodycCs$|durd |¡}nd}| ||¡S)a5Process 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) Nz ARTICLE {0}ZARTICLErÜrÝrrrÚarticles z NNTP.articlecCs | d¡S)zYProcess a SLAVE command. Returns: - resp: server response if successful ZSLAVE)r²r~rrrÚslave!sz NNTP.slavecsDt d¡‰| d ||¡|¡\}}‡fdd„‰|‡fdd„|DƒfS)aiProcess 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 z^([0-9]+) ?(.*) ?z XHDR {0} {1}csˆ |¡}|r| dd¡S|S)Nr6rP)rËr$)r>Úm)ÚpatrrÚ remove_number2s z NNTP.xhdr..remove_numbercsg|] }ˆ|ƒ‘qSrrrµ)rärrr·5r‚zNNTP.xhdr..)rÆrÇr¹r[)rZhdrr­rir–r!r)rãrärÚxhdr's  z NNTP.xhdrcCs.| d ||¡|¡\}}| ¡}|t||ƒfS)aFProcess 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 z XOVER {0}-{1})r¹r[r»rO)rÚstartÚendrir–r!r=rrrÚxover7s ÿz NNTP.xoverc Csxd|jvrdnd}t|ttfƒr>|\}}|d ||p6d¡7}n|durR|d|}| ||¡\}}| ¡}|t||ƒfS)aß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 ZOVERZXOVERz {0}-{1}r,Nr‘)rwr.Útupler¸r[r¹r»rO) rr×rirÀrærçr–r!r=rrrÚoverEs z NNTP.overcCsb| d¡}| d¡st|ƒ‚| ¡}t|ƒdkr8t|ƒ‚|d}t|ƒdkrTt|ƒ‚|t|dƒfS)z�Process the DATE command. Returns: - resp: server response if successful - date: datetime object ZDATEZ111rPr6éN)r²rHrrEr<r rZ)rr–Úelemrrrrr`s    z NNTP.datecCs�| |¡}| d¡st|ƒ‚t|ttfƒr2| ¡}|D]:}| t¡sR|  d¡t}| d¡rdd|}|j   |¡q6|j   d¡|j   ¡|  ¡S)NÚ3r"r¬s. )r²rHrr.r Ú bytearrayÚ splitlinesÚendswithršÚrstriprir›rœru)rrÅÚfr–r>rrrÚ_postqs      z NNTP._postcCs | d|¡S)z¨Process a POST command. Arguments: - data: bytes object, iterable or file containing the article Returns: - resp: server response if successfulZPOST)ró)rÚdatarrrÚpost†sz NNTP.postcCs| d |¡|¡S)a 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.z IHAVE {0})rór[)rr*rôrrrÚihave�sz NNTP.ihavecCs4z"|jr|j ¡|`W|j ¡n |j ¡0dSr})rirmr`r~rrrr†–s  z NNTP._closecCs&z| d¡}W| ¡n | ¡0|S)zdProcess a QUIT command and close the socket. Returns: - resp: server response if successfulZQUIT)r²r†)rr–rrrrƒžs z NNTP.quitcCsô|jrtdƒ‚|s|stdƒ‚z<|rX|sXddl}| ¡}| |j¡}|rX|d}|d}WntylYn0|svdS| d|¡}| d¡r¼|sœt|ƒ‚n | d|¡}| d¡s¼t |ƒ‚d|_ |  ¡|j rðd |j vrð|  ¡d|_ |  ¡dS) NzAlready logged in.z7At least one of `user` and `usenetrc` must be specifiedrrPzauthinfo user Z381zauthinfo pass Z281rs)r|rˆÚnetrcZauthenticatorsrfr„r²rHrrrwrxryrz)rrnrorqr÷Z credentialsZauthr–rrrrl§s>ÿ      z NNTP.loginc Cs`z| d¡|_WnJty"Yn:tyZ}z"|j d¡rDd|_n‚WYd}~n d}~00dS)Nz mode readerZ480T)r²rvrrr rHry)rÚerrrrzÐs  zNNTP._setreadermodecCs||jrtdƒ‚|jrtdƒ‚| d¡}| d¡rp|j ¡t|j||j ƒ|_|j  d¡|_d|_d|_ |  ¡nt dƒ‚dS) zzProcess a STARTTLS command. Arguments: - context: SSL context to use for the encrypted connection zTLS is already enabled.z+TLS cannot be started after authentication.ÚSTARTTLSZ382reTNzTLS failed to start.)r{rˆr|r²rHrirmrcr`rfrjrwrxr)rrar–rrrÚstarttlsÞs    z NNTP.starttls)T)N)N)N)N)N)N)N)N)N)NNT)N):rrrr r¡Ú NNTP_PORTrr rkrr‡rhr�rxr™Údebugržr¢r¦rur±r²r´r¹r»r¼r“rÁrÂr¸rÌrÎrÏr$rÓrÕrÖrØrÚr%rÛrÞrßràrárårèrêrrórõrör†rƒrlrzÚ _have_sslrúrrrrr(sp þ #"     .         ) rcs8eZdZedddddef‡fdd„ Z‡fdd„Z‡ZS)ÚNNTP_SSLNFc s"||_tƒ |||||||¡dS)z›This works identically to NNTP.__init__, except for the change in default port and the `ssl_context` argument for SSL connections. N)Ú ssl_contextÚsuperr ) rrfrgrnrorÿrprqrr©r¿rrr ùsÿzNNTP_SSL.__init__cs@tƒ |¡}zt||j|jƒ}Wn| ¡‚Yn0|SdSr})rrhrcrÿrfrm)rrrr`rrrrhs zNNTP_SSL._create_socket)rrrÚ NNTP_SSL_PORTrr rhÚ __classcell__rrrrrþ÷s ý rþÚ__main__zJ nntplib built-in demo - display the latest articles in a newsgroup)rÎz-gz--groupzgmane.comp.python.generalz3group to fetch messages from (default: %(default)s))ÚdefaultrÓz-sz--serverz news.gmane.ioz+NNTP server hostname (default: %(default)s)z-pz--portr£z#NNTP port number (default: %s / %s))rÚtyperÓz-nz --nb-articlesé z2number of articles to fetch (default: %(default)s)z-Sz--sslÚ store_truezuse NNTP over SSL)ÚactionrrÓ)rfrgrùZGroupZhaszarticles, rangeÚtocCs$t|ƒ|kr |d|d…d}|S)NrQz...)r<)ÚsZlimrrrÚcut3s r r6rúsºA       þÿÿ    S    ÿ ÿ  ÿ ÿ ÿ      ÿ