Thread View: news.software.nntp
1 messages
1 total messages
Started by Julien ÉLIE
Mon, 01 Nov 2010 01:31
RFC 3977 in Python 3.2 (nntplib)
Author: Julien ÉLIE
Date: Mon, 01 Nov 2010 01:31
Date: Mon, 01 Nov 2010 01:31
68 lines
3524 bytes
3524 bytes
Hi all,
Just a quick note to tell a good news: RFC 3977 is being implemented
in Python 3.2.
http://docs.python.org/dev/library/nntplib.html
Here are a few excerpts:
># Other changes from the 2.x/3.1 nntplib:
># - automatic querying of capabilities at connect
># - New method NNTP.getcapabilities()
># - New method NNTP.over()
># - New helper function decode_header()
(HDR is in TODO.)
>.. method:: NNTP.getcapabilities()
>
> Return the :rfc:`3977` capabilities advertised by the server, as a
> :class:`dict` instance mapping capability names to (possibly empty) lists
> of values. On legacy servers which don't understand the ``CAPABILITIES``
> command, an empty dictionary is returned instead.
>
> >>> s = NNTP('news.gmane.org')
> >>> 'POST' in s.getcapabilities()
> True
> {'VERSION': ['2'], 'OVER': [], LIST: ['ACTIVE', 'HEADERS'] }
>.. method:: NNTP.over(message_spec, *, file=None)
>
> Send a ``OVER`` command, or a ``XOVER`` command on legacy servers.
> *message_spec* can be either a string representing a message id, or
> a ``(first, last)`` tuple of numbers indicating a range of articles in
> the current group, or a ``(first, None)`` tuple indicating a range of
> articles starting from *first* to the last article in the current group,
> or :const:`None` to select the current article in the current group.
[...]
>
> >>> _, _, first, last, _ = s.group('gmane.comp.python.devel')
> >>> resp, overviews = s.over((last, last))
> >>> art_num, over = overviews[0]
> >>> art_num
> 117216
> >>> list(over.keys())
> ['xref', 'from', ':lines', ':bytes', 'references', 'date', 'message-id',
> 'subject']
> >>> over['from']
> '=?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= <martin@v.loewis.de>'
> >>> nntplib.decode_header(over['from'])
> '"Martin v. Löwis" <martin@v.loewis.de>'
Interesting API, and very easy to use!
--
Julien ÉLIE
« Les amis de la vérité sont ceux qui la cherchent,
et non ceux qui se vantent de l'avoir trouvée. » (Condorcet)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads