Movatterモバイル変換
[0]ホーム
18.12.1 NNTP Objects
NNTP instances have the following methods. Theresponse that isreturned as the first item in the return tuple of almost all methodsis the server's response: a string beginning with a three-digit code.If the server's response indicates an error, the method raises one ofthe above exceptions.
- Return the welcome message sent by the server in reply to the initialconnection. (This message sometimes contains disclaimers or helpinformation that may be relevant to the user.)
- Set the instance's debugging level. This controls the amount ofdebugging output printed. The default,
0, produces no debuggingoutput. A value of1 produces a moderate amount of debuggingoutput, generally a single line per request or response. A value of2 or higher produces the maximum amount of debugging output,logging each line sent and received on the connection (includingmessage text).
| newgroups( | date, time,[file]) |
- Send a "NEWGROUPS" command. Thedate argument should be astring of the form
'yymmdd' indicating thedate, andtime should be a string of the form'hhmmss' indicating the time. Return a pair(response,groups) wheregroups is a list ofgroup names that are new since the given date and time.If thefile parameter is supplied, then the output of the "NEWGROUPS" command is stored in a file. Iffile is a string, then the method will open a file object with that name, write to it then close it. Iffile is a file object, then it will startcallingwrite() on it to store the lines of the command output.Iffile is supplied, then the returnedlist is an empty list.
| newnews( | group, date, time,[file]) |
- Send a "NEWNEWS" command. Here,group is a group name or
'*', anddate andtime have the same meaning as fornewgroups(). Return a pair(response,articles) wherearticles is a list of message ids.If thefile parameter is supplied, then the output of the "NEWNEWS" command is stored in a file. Iffile is a string, then the method will open a file object with that name, write to it then close it. Iffile is a file object, then it will startcallingwrite() on it to store the lines of the command output.Iffile is supplied, then the returnedlist is an empty list.
- Send a "LIST" command. Return a pair
(response,list) wherelist is a list of tuples. Each tuple has theform(group,last,first,flag), wheregroup is a group name,last andfirst are the lastand first article numbers (as strings), andflag is'y' if posting is allowed,'n' if not, and'm' ifthe newsgroup is moderated. (Note the ordering:last,first.)If thefile parameter is supplied, then the output of the "LIST" command is stored in a file. Iffile is a string, then the method will open a file object with that name, write to it then close it. Iffile is a file object, then it will startcallingwrite() on it to store the lines of the command output.Iffile is supplied, then the returnedlist is an empty list.
| descriptions( | grouppattern) |
- Send a "LIST NEWSGROUPS" command, wheregrouppattern is a wildmatstring as specified in RFC2980 (it's essentially the same as DOS or UNIXshell wildcard strings). Return a pair
(response,list), wherelist is a list of tuples containing(name,title).New in version 2.4.
- Get a description for a single groupgroup. If more than one groupmatches (if 'group' is a real wildmat string), return the first match. If no group matches, return an empty string.
This elides the response code from the server. If the response code isneeded, usedescriptions().
New in version 2.4.
- Send a "GROUP" command, wherename is the group name.Return a tuple
(response,count,first,last,name) wherecount is the (estimated) numberof articles in the group,first is the first article number inthe group,last is the last article number in the group, andname is the group name. The numbers are returned as strings.
- Send a "HELP" command. Return a pair
(response,list) wherelist is a list of help strings.If thefile parameter is supplied, then the output of the "HELP" command is stored in a file. Iffile is a string, then the method will open a file object with that name, write to it then close it. Iffile is a file object, then it will startcallingwrite() on it to store the lines of the command output.Iffile is supplied, then the returnedlist is an empty list.
- Send a "STAT" command, whereid is the message id (enclosedin "<" and ">") or an article number (as a string).Return a triple
(response,number,id) wherenumber is the article number (as a string) andid is themessage id (enclosed in "<" and ">").
- Send a "NEXT" command. Return as forstat().
- Send a "LAST" command. Return as forstat().
- Send a "HEAD" command, whereid has the same meaning as forstat(). Return a tuple
(response,number,id,list)where the first three are the same as forstat(),andlist is a list of the article's headers (an uninterpretedlist of lines, without trailing newlines).
- Send a "BODY" command, whereid has the same meaning as forstat(). If thefile parameter is supplied, thenthe body is stored in a file. Iffile is a string, thenthe method will open a file object with that name, write to it then close it.Iffile is a file object, then it will start callingwrite() on it to store the lines of the body.Return as forhead(). Iffile is supplied, thenthe returnedlist is an empty list.
- Send an "ARTICLE" command, whereid has the same meaning asforstat(). Return as forhead().
- Send a "SLAVE" command. Return the server'sresponse.
| xhdr( | header, string,[file]) |
- Send an "XHDR" command. This command is not defined in the RFCbut is a common extension. Theheader argument is a headerkeyword, e.g.
'subject'. Thestring argument should havethe form'first-last' wherefirst andlast are the first and last article numbers to search. Return apair(response,list), wherelist is a list ofpairs(id,text), whereid is an article number(as a string) andtext is the text of the requested header forthat article.If thefile parameter is supplied, then the output of the "XHDR" command is stored in a file. Iffile is a string, then the method will open a file object with that name, write to it then close it. Iffile is a file object, then it will startcallingwrite() on it to store the lines of the command output.Iffile is supplied, then the returnedlist is an empty list.
- Post an article using the "POST" command. Thefileargument is an open file object which is read until EOF using itsreadline() method. It should be a well-formed news article,including the required headers. Thepost() methodautomatically escapes lines beginning with ".".
- Send an "IHAVE" command.id is a message id (enclosed in "<" and ">").If the response is not an error, treatfile exactly as for thepost() method.
- Return a triple
(response,date,time),containing the current date and time in a form suitable for thenewnews() andnewgroups() methods.This is an optional NNTP extension, and may not be supported by allservers.
- Process an "XGTITLE" command, returning a pair
(response,list), wherelist is a list of tuples containing(name,title).If thefile parameter is supplied, then the output of the "XGTITLE" command is stored in a file. Iffile is a string, then the method will open a file object with that name, write to it then close it. Iffile is a file object, then it will startcallingwrite() on it to store the lines of the command output.Iffile is supplied, then the returnedlist is an empty list.This is an optional NNTP extension, and may not be supported by allservers.RFC2980 says ``It is suggested that this extension be deprecated''. Usedescriptions() ordescription() instead.
- Return a pair
(resp,list).list is a listof tuples, one for each article in the range delimited by thestartandend article numbers. Each tuple is of the form(article number,subject,poster,date,id,references,size,lines).If thefile parameter is supplied, then the output of the "XOVER" command is stored in a file. Iffile is a string, then the method will open a file object with that name, write to it then close it. Iffile is a file object, then it will startcallingwrite() on it to store the lines of the command output.Iffile is supplied, then the returnedlist is an empty list.This is an optional NNTP extension, and may not be supported by allservers.
- Return a pair
(resp,path), wherepath is thedirectory path to the article with message IDid. This is anoptional NNTP extension, and may not be supported by all servers.
- Send a "QUIT" command and close the connection. Once this methodhas been called, no other methods of the NNTP object should be called.
Release 2.5.2, documentation updated on 21st February, 2008. SeeAbout this document... for information on suggesting changes.
[8]ページ先頭