| |
- NNTP
- NNTPError(exceptions.Exception)
-
- NNTPDataError
- NNTPPermanentError
- NNTPProtocolError
- NNTPReplyError
- NNTPTemporaryError
class NNTP |
|
# The class itself |
|
Methods defined here:
- __init__(self, host, port=119, user=None, password=None, readermode=None, usenetrc=True)
- 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.
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.
- artcmd(self, line, file=None)
- Internal: process a HEAD, BODY or ARTICLE command.
- article(self, id)
- Process an ARTICLE command. Argument:
- id: article number or message id
Returns:
- resp: server response if successful
- nr: article number
- id: message id
- list: the lines of the article
- body(self, id, file=None)
- Process a BODY command. Argument:
- id: article number or message id
- file: Filename string or file object to store the article in
Returns:
- resp: server response if successful
- nr: article number
- id: message id
- list: the lines of the article's body or an empty list
if file was used
- date(self)
- Process the DATE command. Arguments:
None
Returns:
resp: server response if successful
date: Date suitable for newnews/newgroups commands etc.
time: Time suitable for newnews/newgroups commands etc.
- debug = set_debuglevel(self, level)
- description(self, group)
- 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.
- descriptions(self, group_pattern)
- Get descriptions for a range of groups.
- getline(self)
- Internal: return one line from the server, stripping CRLF.
Raise EOFError if the connection is closed.
- getlongresp(self, file=None)
- Internal: get a response plus following text from the server.
Raise various errors if the response indicates an error.
- getresp(self)
- Internal: get a response from the server.
Raise various errors if the response indicates an error.
- getwelcome(self)
- 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.
- group(self, name)
- Process a GROUP command. Argument:
- group: the group name
Returns:
- resp: server response if successful
- count: number of articles (string)
- first: first article number (string)
- last: last article number (string)
- name: the group name
- head(self, id)
- Process a HEAD command. Argument:
- id: article number or message id
Returns:
- resp: server response if successful
- nr: article number
- id: message id
- list: the lines of the article's header
- help(self, file=None)
- Process a HELP command. Returns:
- resp: server response if successful
- list: list of strings
- ihave(self, id, f)
- Process an IHAVE command. Arguments:
- id: message-id of the article
- f: file containing the article
Returns:
- resp: server response if successful
Note that if the server refuses the article an exception is raised.
- last(self)
- Process a LAST command. No arguments. Return as for STAT.
- list(self, file=None)
- Process a LIST command. Return:
- resp: server response if successful
- list: list of (group, last, first, flag) (strings)
- longcmd(self, line, file=None)
- Internal: send a command and get the response plus following text.
- newgroups(self, date, time, file=None)
- Process a NEWGROUPS command. Arguments:
- date: string 'yymmdd' indicating the date
- time: string 'hhmmss' indicating the time
Return:
- resp: server response if successful
- list: list of newsgroup names
- newnews(self, group, date, time, file=None)
- Process a NEWNEWS command. Arguments:
- group: group name or '*'
- date: string 'yymmdd' indicating the date
- time: string 'hhmmss' indicating the time
Return:
- resp: server response if successful
- list: list of message ids
- next(self)
- Process a NEXT command. No arguments. Return as for STAT.
- post(self, f)
- Process a POST command. Arguments:
- f: file containing the article
Returns:
- resp: server response if successful
- putcmd(self, line)
- Internal: send one command to the server (through putline()).
- putline(self, line)
- Internal: send one line to the server, appending CRLF.
- quit(self)
- Process a QUIT command and close the socket. Returns:
- resp: server response if successful
- set_debuglevel(self, level)
- 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/LF
- shortcmd(self, line)
- Internal: send a command and get the response.
- slave(self)
- Process a SLAVE command. Returns:
- resp: server response if successful
- stat(self, id)
- Process a STAT command. Argument:
- id: article number or message id
Returns:
- resp: server response if successful
- nr: the article number
- id: the message id
- statcmd(self, line)
- Internal: process a STAT, NEXT or LAST command.
- statparse(self, resp)
- Internal: parse the response of a STAT, NEXT or LAST command.
- xgtitle(self, group, file=None)
- 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) strings
- xhdr(self, hdr, str, file=None)
- Process 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
Returns:
- resp: server response if successful
- list: list of (nr, value) strings
- xover(self, start, end, file=None)
- Process an XOVER command (optional server extension) Arguments:
- start: start of range
- end: end of range
Returns:
- resp: server response if successful
- list: list of (art-nr, subject, poster, date,
id, references, size, lines)
- xpath(self, id)
- Process an XPATH command (optional server extension) Arguments:
- id: Message id of article
Returns:
resp: server response if successful
path: directory path to article
|
|