Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
nntplib.NNTP Class Reference
Inheritance diagram for nntplib.NNTP:
Inheritance graph
[legend]
Collaboration diagram for nntplib.NNTP:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def getwelcome
def getcapabilities
def set_debuglevel
def capabilities
def newgroups
def newnews
def list
def description
def descriptions
def group
def help
def stat
def next
def last
def head
def body
def article
def slave
def xhdr
def xover
def over
def xgtitle
def xpath
def date
def post
def ihave
def quit
def login
def starttls

Public Attributes

 host
 port
 sock
 file
 debugging
 welcome
 readermode_afterauth
 tls_on
 authenticated
 nntp_version
 nntp_implementation

Static Public Attributes

string encoding = 'utf-8'
string errors = 'surrogateescape'
 debug = set_debuglevel

Private Member Functions

def _close

Detailed Description

Definition at line 986 of file nntplib.py.


Constructor & Destructor Documentation

def nntplib.NNTP.__init__ (   self,
  host,
  port = NNTP_PORT,
  user = None,
  password = None,
  readermode = None,
  usenetrc = False,
  timeout = _GLOBAL_DEFAULT_TIMEOUT 
)
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.

Definition at line 990 of file nntplib.py.

00990 
00991                  timeout=_GLOBAL_DEFAULT_TIMEOUT):
00992         """Initialize an instance.  Arguments:
00993         - host: hostname to connect to
00994         - port: port to connect to (default the standard NNTP port)
00995         - user: username to authenticate with
00996         - password: password to use with username
00997         - readermode: if true, send 'mode reader' command after
00998                       connecting.
00999         - usenetrc: allow loading username and password from ~/.netrc file
01000                     if not specified explicitly
01001         - timeout: timeout (in seconds) used for socket connections
01002 
01003         readermode is sometimes necessary if you are connecting to an
01004         NNTP server on the local machine and intend to call
01005         reader-specific commands, such as `group'.  If you get
01006         unexpected NNTPPermanentErrors, you might need to set
01007         readermode.
01008         """
01009         self.host = host
01010         self.port = port
01011         self.sock = socket.create_connection((host, port), timeout)
01012         file = self.sock.makefile("rwb")
01013         _NNTPBase.__init__(self, file, host,
01014                            readermode, timeout)
01015         if user or usenetrc:
01016             self.login(user, password, usenetrc)

Here is the caller graph for this function:


Member Function Documentation

def nntplib.NNTP._close (   self) [private]

Reimplemented from nntplib._NNTPBase.

Definition at line 1017 of file nntplib.py.

01017 
01018     def _close(self):
01019         try:
01020             _NNTPBase._close(self)
01021         finally:
01022             self.sock.close()
01023 

def nntplib._NNTPBase.article (   self,
  message_spec = None,
  file = None 
) [inherited]
Process 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)

Definition at line 732 of file nntplib.py.

00732 
00733     def article(self, message_spec=None, *, file=None):
00734         """Process an ARTICLE command.  Argument:
00735         - message_spec: article number or message id
00736         - file: filename string or file object to store the article in
00737         Returns:
00738         - resp: server response if successful
00739         - ArticleInfo: (article number, message id, list of article lines)
00740         """
00741         if message_spec is not None:
00742             cmd = 'ARTICLE {0}'.format(message_spec)
00743         else:
00744             cmd = 'ARTICLE'
00745         return self._artcmd(cmd, file)

Here is the call graph for this function:

def nntplib._NNTPBase.body (   self,
  message_spec = None,
  file = None 
) [inherited]
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)

Definition at line 718 of file nntplib.py.

00718 
00719     def body(self, message_spec=None, *, file=None):
00720         """Process a BODY command.  Argument:
00721         - message_spec: article number or message id
00722         - file: filename string or file object to store the body in
00723         Returns:
00724         - resp: server response if successful
00725         - ArticleInfo: (article number, message id, list of body lines)
00726         """
00727         if message_spec is not None:
00728             cmd = 'BODY {0}'.format(message_spec)
00729         else:
00730             cmd = 'BODY'
00731         return self._artcmd(cmd, file)

Here is the call graph for this function:

def nntplib._NNTPBase.capabilities (   self) [inherited]
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'] })

Definition at line 524 of file nntplib.py.

00524 
00525     def capabilities(self):
00526         """Process a CAPABILITIES command.  Not supported by all servers.
00527         Return:
00528         - resp: server response if successful
00529         - caps: a dictionary mapping capability names to lists of tokens
00530         (for example {'VERSION': ['2'], 'OVER': [], LIST: ['ACTIVE', 'HEADERS'] })
00531         """
00532         caps = {}
00533         resp, lines = self._longcmdstring("CAPABILITIES")
00534         for line in lines:
00535             name, *tokens = line.split()
00536             caps[name] = tokens
00537         return resp, caps

Here is the call graph for this function:

def nntplib._NNTPBase.date (   self) [inherited]
Process the DATE command.
Returns:
- resp: server response if successful
- date: datetime object

Definition at line 847 of file nntplib.py.

00847 
00848     def date(self):
00849         """Process the DATE command.
00850         Returns:
00851         - resp: server response if successful
00852         - date: datetime object
00853         """
00854         resp = self._shortcmd("DATE")
00855         if not resp.startswith('111'):
00856             raise NNTPReplyError(resp)
00857         elem = resp.split()
00858         if len(elem) != 2:
00859             raise NNTPDataError(resp)
00860         date = elem[1]
00861         if len(date) != 14:
00862             raise NNTPDataError(resp)
00863         return resp, _parse_datetime(date, None)

Here is the call graph for this function:

def nntplib._NNTPBase.description (   self,
  group 
) [inherited]
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.

Definition at line 608 of file nntplib.py.

00608 
00609     def description(self, group):
00610         """Get a description for a single group.  If more than one
00611         group matches ('group' is a pattern), return the first.  If no
00612         group matches, return an empty string.
00613 
00614         This elides the response code from the server, since it can
00615         only be '215' or '285' (for xgtitle) anyway.  If the response
00616         code is needed, use the 'descriptions' method.
00617 
00618         NOTE: This neither checks for a wildcard in 'group' nor does
00619         it check whether the group actually exists."""
00620         return self._getdescriptions(group, False)

Here is the call graph for this function:

def nntplib._NNTPBase.descriptions (   self,
  group_pattern 
) [inherited]
Get descriptions for a range of groups.

Definition at line 621 of file nntplib.py.

00621 
00622     def descriptions(self, group_pattern):
00623         """Get descriptions for a range of groups."""
00624         return self._getdescriptions(group_pattern, True)

Here is the call graph for this function:

def nntplib._NNTPBase.getcapabilities (   self) [inherited]
Get the server capabilities, as read by __init__().
If the CAPABILITIES command is not supported, an empty dict is
returned.

Definition at line 358 of file nntplib.py.

00358 
00359     def getcapabilities(self):
00360         """Get the server capabilities, as read by __init__().
00361         If the CAPABILITIES command is not supported, an empty dict is
00362         returned."""
00363         if self._caps is None:
00364             self.nntp_version = 1
00365             self.nntp_implementation = None
00366             try:
00367                 resp, caps = self.capabilities()
00368             except NNTPPermanentError:
00369                 # Server doesn't support capabilities
00370                 self._caps = {}
00371             else:
00372                 self._caps = caps
00373                 if 'VERSION' in caps:
00374                     # The server can advertise several supported versions,
00375                     # choose the highest.
00376                     self.nntp_version = max(map(int, caps['VERSION']))
00377                 if 'IMPLEMENTATION' in caps:
00378                     self.nntp_implementation = ' '.join(caps['IMPLEMENTATION'])
00379         return self._caps

def nntplib._NNTPBase.getwelcome (   self) [inherited]
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.

Definition at line 349 of file nntplib.py.

00349 
00350     def getwelcome(self):
00351         """Get the welcome message from the server
00352         (this is read and squirreled away by __init__()).
00353         If the response code is 200, posting is allowed;
00354         if it 201, posting is not allowed."""
00355 
00356         if self.debugging: print('*welcome*', repr(self.welcome))
00357         return self.welcome

def nntplib._NNTPBase.group (   self,
  name 
) [inherited]
Process 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

Definition at line 625 of file nntplib.py.

00625 
00626     def group(self, name):
00627         """Process a GROUP command.  Argument:
00628         - group: the group name
00629         Returns:
00630         - resp: server response if successful
00631         - count: number of articles
00632         - first: first article number
00633         - last: last article number
00634         - name: the group name
00635         """
00636         resp = self._shortcmd('GROUP ' + name)
00637         if not resp.startswith('211'):
00638             raise NNTPReplyError(resp)
00639         words = resp.split()
00640         count = first = last = 0
00641         n = len(words)
00642         if n > 1:
00643             count = words[1]
00644             if n > 2:
00645                 first = words[2]
00646                 if n > 3:
00647                     last = words[3]
00648                     if n > 4:
00649                         name = words[4].lower()
00650         return resp, int(count), int(first), int(last), name

Here is the call graph for this function:

def nntplib._NNTPBase.head (   self,
  message_spec = None,
  file = None 
) [inherited]
Process 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)

Definition at line 704 of file nntplib.py.

00704 
00705     def head(self, message_spec=None, *, file=None):
00706         """Process a HEAD command.  Argument:
00707         - message_spec: article number or message id
00708         - file: filename string or file object to store the headers in
00709         Returns:
00710         - resp: server response if successful
00711         - ArticleInfo: (article number, message id, list of header lines)
00712         """
00713         if message_spec is not None:
00714             cmd = 'HEAD {0}'.format(message_spec)
00715         else:
00716             cmd = 'HEAD'
00717         return self._artcmd(cmd, file)

Here is the call graph for this function:

def nntplib._NNTPBase.help (   self,
  file = None 
) [inherited]
Process 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

Definition at line 651 of file nntplib.py.

00651 
00652     def help(self, *, file=None):
00653         """Process a HELP command. Argument:
00654         - file: Filename string or file object to store the result in
00655         Returns:
00656         - resp: server response if successful
00657         - list: list of strings returned by the server in response to the
00658                 HELP command
00659         """
00660         return self._longcmdstring('HELP', file)

Here is the call graph for this function:

Here is the caller graph for this function:

def nntplib._NNTPBase.ihave (   self,
  message_id,
  data 
) [inherited]
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.

Definition at line 892 of file nntplib.py.

00892 
00893     def ihave(self, message_id, data):
00894         """Process an IHAVE command.  Arguments:
00895         - message_id: message-id of the article
00896         - data: file containing the article
00897         Returns:
00898         - resp: server response if successful
00899         Note that if the server refuses the article an exception is raised."""
00900         return self._post('IHAVE {0}'.format(message_id), data)

Here is the call graph for this function:

def nntplib._NNTPBase.last (   self) [inherited]
Process a LAST command.  No arguments.  Return as for STAT.

Definition at line 694 of file nntplib.py.

00694 
00695     def last(self):
00696         """Process a LAST command.  No arguments.  Return as for STAT."""
00697         return self._statcmd('LAST')

Here is the call graph for this function:

def nntplib._NNTPBase.list (   self,
  group_pattern = None,
  file = None 
) [inherited]
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)

Definition at line 570 of file nntplib.py.

00570 
00571     def list(self, group_pattern=None, *, file=None):
00572         """Process a LIST or LIST ACTIVE command. Arguments:
00573         - group_pattern: a pattern indicating which groups to query
00574         - file: Filename string or file object to store the result in
00575         Returns:
00576         - resp: server response if successful
00577         - list: list of (group, last, first, flag) (strings)
00578         """
00579         if group_pattern is not None:
00580             command = 'LIST ACTIVE ' + group_pattern
00581         else:
00582             command = 'LIST'
00583         resp, lines = self._longcmdstring(command, file)
00584         return resp, self._grouplist(lines)

Here is the call graph for this function:

Here is the caller graph for this function:

def nntplib._NNTPBase.login (   self,
  user = None,
  password = None,
  usenetrc = True 
) [inherited]

Definition at line 914 of file nntplib.py.

00914 
00915     def login(self, user=None, password=None, usenetrc=True):
00916         if self.authenticated:
00917             raise ValueError("Already logged in.")
00918         if not user and not usenetrc:
00919             raise ValueError(
00920                 "At least one of `user` and `usenetrc` must be specified")
00921         # If no login/password was specified but netrc was requested,
00922         # try to get them from ~/.netrc
00923         # Presume that if .netrc has an entry, NNRP authentication is required.
00924         try:
00925             if usenetrc and not user:
00926                 import netrc
00927                 credentials = netrc.netrc()
00928                 auth = credentials.authenticators(self.host)
00929                 if auth:
00930                     user = auth[0]
00931                     password = auth[2]
00932         except IOError:
00933             pass
00934         # Perform NNTP authentication if needed.
00935         if not user:
00936             return
00937         resp = self._shortcmd('authinfo user ' + user)
00938         if resp.startswith('381'):
00939             if not password:
00940                 raise NNTPReplyError(resp)
00941             else:
00942                 resp = self._shortcmd('authinfo pass ' + password)
00943                 if not resp.startswith('281'):
00944                     raise NNTPPermanentError(resp)
00945         # Attempt to send mode reader if it was requested after login.
00946         if self.readermode_afterauth:
00947             self._setreadermode()

Here is the call graph for this function:

def nntplib._NNTPBase.newgroups (   self,
  date,
  file = None 
) [inherited]
Process a NEWGROUPS command.  Arguments:
- date: a date or datetime object
Return:
- resp: server response if successful
- list: list of newsgroup names

Definition at line 538 of file nntplib.py.

00538 
00539     def newgroups(self, date, *, file=None):
00540         """Process a NEWGROUPS command.  Arguments:
00541         - date: a date or datetime object
00542         Return:
00543         - resp: server response if successful
00544         - list: list of newsgroup names
00545         """
00546         if not isinstance(date, (datetime.date, datetime.date)):
00547             raise TypeError(
00548                 "the date parameter must be a date or datetime object, "
00549                 "not '{:40}'".format(date.__class__.__name__))
00550         date_str, time_str = _unparse_datetime(date, self.nntp_version < 2)
00551         cmd = 'NEWGROUPS {0} {1}'.format(date_str, time_str)
00552         resp, lines = self._longcmdstring(cmd, file)
00553         return resp, self._grouplist(lines)

Here is the call graph for this function:

def nntplib._NNTPBase.newnews (   self,
  group,
  date,
  file = None 
) [inherited]
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

Definition at line 554 of file nntplib.py.

00554 
00555     def newnews(self, group, date, *, file=None):
00556         """Process a NEWNEWS command.  Arguments:
00557         - group: group name or '*'
00558         - date: a date or datetime object
00559         Return:
00560         - resp: server response if successful
00561         - list: list of message ids
00562         """
00563         if not isinstance(date, (datetime.date, datetime.date)):
00564             raise TypeError(
00565                 "the date parameter must be a date or datetime object, "
00566                 "not '{:40}'".format(date.__class__.__name__))
00567         date_str, time_str = _unparse_datetime(date, self.nntp_version < 2)
00568         cmd = 'NEWNEWS {0} {1} {2}'.format(group, date_str, time_str)
00569         return self._longcmdstring(cmd, file)

Here is the call graph for this function:

def nntplib._NNTPBase.next (   self) [inherited]
Process a NEXT command.  No arguments.  Return as for STAT.

Definition at line 690 of file nntplib.py.

00690 
00691     def next(self):
00692         """Process a NEXT command.  No arguments.  Return as for STAT."""
00693         return self._statcmd('NEXT')

Here is the call graph for this function:

Here is the caller graph for this function:

def nntplib._NNTPBase.over (   self,
  message_spec,
  file = None 
) [inherited]
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

Definition at line 782 of file nntplib.py.

00782 
00783     def over(self, message_spec, *, file=None):
00784         """Process an OVER command.  If the command isn't supported, fall
00785         back to XOVER. Arguments:
00786         - message_spec:
00787             - either a message id, indicating the article to fetch
00788               information about
00789             - or a (start, end) tuple, indicating a range of article numbers;
00790               if end is None, information up to the newest message will be
00791               retrieved
00792             - or None, indicating the current article number must be used
00793         - file: Filename string or file object to store the result in
00794         Returns:
00795         - resp: server response if successful
00796         - list: list of dicts containing the response fields
00797 
00798         NOTE: the "message id" form isn't supported by XOVER
00799         """
00800         cmd = 'OVER' if 'OVER' in self._caps else 'XOVER'
00801         if isinstance(message_spec, (tuple, list)):
00802             start, end = message_spec
00803             cmd += ' {0}-{1}'.format(start, end or '')
00804         elif message_spec is not None:
00805             cmd = cmd + ' ' + message_spec
00806         resp, lines = self._longcmdstring(cmd, file)
00807         fmt = self._getoverviewfmt()
00808         return resp, _parse_overview(lines, fmt)

Here is the call graph for this function:

def nntplib._NNTPBase.post (   self,
  data 
) [inherited]
Process a POST command.  Arguments:
- data: bytes object, iterable or file containing the article
Returns:
- resp: server response if successful

Definition at line 885 of file nntplib.py.

00885 
00886     def post(self, data):
00887         """Process a POST command.  Arguments:
00888         - data: bytes object, iterable or file containing the article
00889         Returns:
00890         - resp: server response if successful"""
00891         return self._post('POST', data)

Here is the call graph for this function:

def nntplib._NNTPBase.quit (   self) [inherited]
Process a QUIT command and close the socket.  Returns:
- resp: server response if successful

Definition at line 905 of file nntplib.py.

00905 
00906     def quit(self):
00907         """Process a QUIT command and close the socket.  Returns:
00908         - resp: server response if successful"""
00909         try:
00910             resp = self._shortcmd('QUIT')
00911         finally:
00912             self._close()
00913         return resp

Here is the call graph for this function:

Here is the caller graph for this function:

def nntplib._NNTPBase.set_debuglevel (   self,
  level 
) [inherited]
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

Definition at line 380 of file nntplib.py.

00380 
00381     def set_debuglevel(self, level):
00382         """Set the debugging level.  Argument 'level' means:
00383         0: no debugging output (default)
00384         1: print commands and responses but not body text etc.
00385         2: also print raw lines read and sent before stripping CR/LF"""
00386 
        self.debugging = level
def nntplib._NNTPBase.slave (   self) [inherited]
Process a SLAVE command.  Returns:
- resp: server response if successful

Definition at line 746 of file nntplib.py.

00746 
00747     def slave(self):
00748         """Process a SLAVE command.  Returns:
00749         - resp: server response if successful
00750         """
00751         return self._shortcmd('SLAVE')

Here is the call graph for this function:

def nntplib._NNTPBase.starttls (   self,
  context = None 
) [inherited]
Process a STARTTLS command. Arguments:
- context: SSL context to use for the encrypted connection

Definition at line 962 of file nntplib.py.

00962 
00963         def starttls(self, context=None):
00964             """Process a STARTTLS command. Arguments:
00965             - context: SSL context to use for the encrypted connection
00966             """
00967             # Per RFC 4642, STARTTLS MUST NOT be sent after authentication or if
00968             # a TLS session already exists.
00969             if self.tls_on:
00970                 raise ValueError("TLS is already enabled.")
00971             if self.authenticated:
00972                 raise ValueError("TLS cannot be started after authentication.")
00973             resp = self._shortcmd('STARTTLS')
00974             if resp.startswith('382'):
00975                 self.file.close()
00976                 self.sock = _encrypt_on(self.sock, context)
00977                 self.file = self.sock.makefile("rwb")
00978                 self.tls_on = True
00979                 # Capabilities may change after TLS starts up, so ask for them
00980                 # again.
00981                 self._caps = None
00982                 self.getcapabilities()
00983             else:
00984                 raise NNTPError("TLS failed to start.")
00985 

Here is the call graph for this function:

def nntplib._NNTPBase.stat (   self,
  message_spec = None 
) [inherited]
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

Definition at line 676 of file nntplib.py.

00676 
00677     def stat(self, message_spec=None):
00678         """Process a STAT command.  Argument:
00679         - message_spec: article number or message id (if not specified,
00680           the current article is selected)
00681         Returns:
00682         - resp: server response if successful
00683         - art_num: the article number
00684         - message_id: the message id
00685         """
00686         if message_spec:
00687             return self._statcmd('STAT {0}'.format(message_spec))
00688         else:
00689             return self._statcmd('STAT')

Here is the call graph for this function:

def nntplib._NNTPBase.xgtitle (   self,
  group,
  file = None 
) [inherited]
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

Definition at line 809 of file nntplib.py.

00809 
00810     def xgtitle(self, group, *, file=None):
00811         """Process an XGTITLE command (optional server extension) Arguments:
00812         - group: group name wildcard (i.e. news.*)
00813         Returns:
00814         - resp: server response if successful
00815         - list: list of (name,title) strings"""
00816         warnings.warn("The XGTITLE extension is not actively used, "
00817                       "use descriptions() instead",
00818                       PendingDeprecationWarning, 2)
00819         line_pat = re.compile('^([^ \t]+)[ \t]+(.*)$')
00820         resp, raw_lines = self._longcmdstring('XGTITLE ' + group, file)
00821         lines = []
00822         for raw_line in raw_lines:
00823             match = line_pat.search(raw_line.strip())
00824             if match:
00825                 lines.append(match.group(1, 2))
00826         return resp, lines

Here is the call graph for this function:

def nntplib._NNTPBase.xhdr (   self,
  hdr,
  str,
  file = None 
) [inherited]
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
- file: Filename string or file object to store the result in
Returns:
- resp: server response if successful
- list: list of (nr, value) strings

Definition at line 752 of file nntplib.py.

00752 
00753     def xhdr(self, hdr, str, *, file=None):
00754         """Process an XHDR command (optional server extension).  Arguments:
00755         - hdr: the header type (e.g. 'subject')
00756         - str: an article nr, a message id, or a range nr1-nr2
00757         - file: Filename string or file object to store the result in
00758         Returns:
00759         - resp: server response if successful
00760         - list: list of (nr, value) strings
00761         """
00762         pat = re.compile('^([0-9]+) ?(.*)\n?')
00763         resp, lines = self._longcmdstring('XHDR {0} {1}'.format(hdr, str), file)
00764         def remove_number(line):
00765             m = pat.match(line)
00766             return m.group(1, 2) if m else line
00767         return resp, [remove_number(line) for line in lines]

Here is the call graph for this function:

def nntplib._NNTPBase.xover (   self,
  start,
  end,
  file = None 
) [inherited]
Process 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

Definition at line 768 of file nntplib.py.

00768 
00769     def xover(self, start, end, *, file=None):
00770         """Process an XOVER command (optional server extension) Arguments:
00771         - start: start of range
00772         - end: end of range
00773         - file: Filename string or file object to store the result in
00774         Returns:
00775         - resp: server response if successful
00776         - list: list of dicts containing the response fields
00777         """
00778         resp, lines = self._longcmdstring('XOVER {0}-{1}'.format(start, end),
00779                                           file)
00780         fmt = self._getoverviewfmt()
00781         return resp, _parse_overview(lines, fmt)

Here is the call graph for this function:

def nntplib._NNTPBase.xpath (   self,
  id 
) [inherited]
Process an XPATH command (optional server extension) Arguments:
- id: Message id of article
Returns:
resp: server response if successful
path: directory path to article

Definition at line 827 of file nntplib.py.

00827 
00828     def xpath(self, id):
00829         """Process an XPATH command (optional server extension) Arguments:
00830         - id: Message id of article
00831         Returns:
00832         resp: server response if successful
00833         path: directory path to article
00834         """
00835         warnings.warn("The XPATH extension is not actively used",
00836                       PendingDeprecationWarning, 2)
00837 
00838         resp = self._shortcmd('XPATH {0}'.format(id))
00839         if not resp.startswith('223'):
00840             raise NNTPReplyError(resp)
00841         try:
00842             [resp_num, path] = resp.split()
00843         except ValueError:
00844             raise NNTPReplyError(resp)
00845         else:
00846             return resp, path

Here is the call graph for this function:


Member Data Documentation

Definition at line 347 of file nntplib.py.

nntplib._NNTPBase.debug = set_debuglevel [static, inherited]

Definition at line 387 of file nntplib.py.

Definition at line 324 of file nntplib.py.

string nntplib._NNTPBase.encoding = 'utf-8' [static, inherited]

Definition at line 304 of file nntplib.py.

string nntplib._NNTPBase.errors = 'surrogateescape' [static, inherited]

Definition at line 305 of file nntplib.py.

Definition at line 323 of file nntplib.py.

Reimplemented from nntplib._NNTPBase.

Definition at line 1008 of file nntplib.py.

Definition at line 364 of file nntplib.py.

Definition at line 363 of file nntplib.py.

Definition at line 1009 of file nntplib.py.

Definition at line 333 of file nntplib.py.

Reimplemented from nntplib._NNTPBase.

Definition at line 1010 of file nntplib.py.

Definition at line 340 of file nntplib.py.

Definition at line 325 of file nntplib.py.


The documentation for this class was generated from the following file: