nntplib: abstraction of threads

Steve Holden steve at holdenweb.com
Sun Jan 16 12:28:56 EST 2005


Werner Amann wrote:

> Rakesh schrieb:
> 
> 
>>What I want is to *group the messages belonging to each thread* .
> 
> 
> Hello
> 
> Why not sort with Message-ID and References?
> Attention - it is a Newbie-Solution.
> 
> import nntplib
> 
> hamster = nntplib.NNTP('127.0.0.1', 119, 'user', 'pass')
> resp, count, first, last, name = hamster.group('comp.lang.python')
> resp, items = hamster.xover(first,last)
> 
> start_dic = {}
> re_dic = {}
> numb = 1
>     
> for id,subject,author,date,message_id,references,size,lines in items:
>     if 'Re:' not in subject:
>         start_dic[subject] = (author, message_id)
>     else:
>         re_dic[numb] = (subject, author, references)
>     numb += 1
> 
> resp = hamster.quit()
> 
> for a in start_dic:
>     print a
>     print start_dic[a][0]
>     for b in re_dic:
>         if start_dic[a][1] in re_dic[b][2]:
>             print '|'
>             print ' ->', re_dic[b][0]
>             print '   ', re_dic[b][1]
>     print 
> 
Better still, do a Google search on "mail threading algorithm", 
implement the algorithm described in

   http://www.jwz.org/doc/threading.html

and post your implementation back to the newsgroup :-)

regards
  Steve
-- 
Steve Holden               http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC      +1 703 861 4237  +1 800 494 3119



More information about the Python-list mailing list