Article View: news.software.nntp
Article #83601RFC 3977 in Python 3.2 (nntplib)
From: 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)
Technical Details
Message-ID:
<ial59n$ieo$1@news.trigofacile.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.ams3.giganews.com!border1.nntp.ams2.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!gegeweb.org!news.trigofacile.com!.POSTED.aaubervilliers-151-1-2-50.w83-114.abo.wanadoo.fr!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <ial59n$ieo$1@news.trigofacile.com> Subject: RFC 3977 in Python 3.2 (nntplib) Date: Mon, 1 Nov 2010 02:31:36 +0100 From: Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.ams3.giganews.com!border1.nntp.ams2.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!gegeweb.org!news.trigofacile.com!.POSTED.aaubervilliers-151-1-2-50.w83-114.abo.wanadoo.fr!not-for-mail Newsgroups: news.software.nntp Organization: TrigoFACILE -- http://www.trigofacile.com/ Lines: 68 Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-15"; reply-type=original Content-Transfer-Encoding: 8bit Injection-Date: Mon, 1 Nov 2010 01:31:35 +0000 (UTC) Injection-Info: news.trigofacile.com; posting-host="aaubervilliers-151-1-2-50.w83-114.abo.wanadoo.fr:83.114.1.50"; logging-data="18904"; mail-complaints-to="abuse@trigofacile.com" X-MSMail-Priority: Normal X-Newsreader: Microsoft Windows Mail 6.0.6002.18197 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18263 X-Original-Bytes: 3348