python (3.11.7)
e d Z ddlZddlZddlZddlZddlZddlZ ddlZdZn
# e $ r dZY nw xY wddl
mZ ddlm
Z
g dZ ej ed d
Z G d de Z G d
de Z G d de Z G d de Z G d de Z G d de ZdZdZh dZg dZdddZdZ ej dg d Z ej d!g d" Z!d# Zd$ Z"dWd%Z#dWd&Z$dXd'Z%erd( Z& G d) d* Z'er# G d+ d,e' Z(e) d, ed-k r,ddl*Z* e*j+ d./ Z,e,- d0d1d2d34 e,- d5d6d7d84 e,- d9d:d;e.d<ed=ed>? e,- d@dAdBe.dC? e,- dDdEdFddGH e,/ Z0e0j1 Z1e0j se1d;k reZ1 e'e0j2 e1I Z3ne1d;k reZ1 e(e0j2 e1I Z3e34 Z5dJe5v re36 e37 e0j7 \ Z8Z9Z:Z;Z< e=dKe<dLe9dMe:dNe; dO Z> e? e.e; e0j@ z
dPz Z:e3A e:e; \ Z8ZBeBD ]\ ZCZD eeDdQ E dRdP d ZF eeDdS ZG e.eDd ZH e=dTI eC e>eFdU e>eGdV eH e3J dS dS )Ya 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.
NTF)
decode_header)_GLOBAL_DEFAULT_TIMEOUT)NNTP NNTPErrorNNTPReplyErrorNNTPTemporaryErrorNNTPPermanentErrorNNTPProtocolError
NNTPDataErrorr )
)removei c e Zd ZdZd ZdS )r z%Base class for all nntplib exceptionsc v t j | g|R |d | _ d S # t $ r d| _ Y d S w xY w)Nr zNo response given) Exception__init__response
IndexError)selfargss ;/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/nntplib.pyr zNNTPError.__init__e sW 4'$'''' 0 GDMMM 0 0 0/DMMMM 0s
# 88N)__name__
__module____qualname____doc__r r r r c s) //0 0 0 0 0r r c e Zd ZdZdS )r zUnexpected [123]xx replyNr r r r r r r r r l s ""Dr r c e Zd ZdZdS )r z
4xx errorsNr r r r r r p Dr r c e Zd ZdZdS )r z
5xx errorsNr r r r r r t r! r r c e Zd ZdZdS )r
z"Response does not begin with [1-5]Nr r r r r
r
x s ,,Dr r
c e Zd ZdZdS )r zError in response dataNr r r r r r | s Dr r w i3 > 100101211215220221222224225230231282)subjectfromdatez
message-id
references:bytes:linesr6 r7 )byteslines
GroupInfo)grouplastfirstflagArticleInfo)number
message_idr9 c g }t | D ]Z\ }}t |t r+| | |pd E| | [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
isinstancer8 appenddecodejoin)
header_strpartsvencs r r r s|
E&z22 3a LL#.112222LLOOOO
775>>r c g }| D ]}|d dk r'|dd d \ }}}d|z }n| d \ }}}| }t || }| | t
}t
| t
| k rt d |dt
| |k rt d |S )zParse 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) partitionlower_OVERVIEW_FMT_ALTERNATIVESgetrH _DEFAULT_OVERVIEW_FMTlenr )r9 fmtlinename_suffixdefaultss r _parse_overview_fmtr^ s
C 7c>>"122h0055OD!V:DD #nnS11OD!Vzz||)--dD99
4$H
3xx#h--BCCC
>CMM>h&&HIIIJr c ( t t }g }| D ]}i }| d ^}}t | }t | D ]\ } }
| t | k r|| }| d }| |k r`|s^|dz }
|
r<|
dt |
|
k rt d |
r|
t |
d nd}
|
||| <