Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.advocacy > #355512
| From | owl <owl@rooftop.invalid> |
|---|---|
| Newsgroups | comp.os.linux.advocacy |
| Subject | Re: Melzzzzz, where's your stats source code? |
| Date | 2016-05-15 17:07 +0000 |
| Organization | O.W.L. |
| Message-ID | <fhjgoz03.a33@rooftop.invalid> (permalink) |
| References | (2 earlier) <nh64ll$tib$1@dont-email.me> <fhgvm.fkf0iz@rooftop.invalid> <nh67q5$4pu$2@dont-email.me> <fhgjvncmd00ae.fju@rooftop.invalid> <nha68h$9re$1@dont-email.me> |
DFS <nospam@dfs.com> wrote:
> On 5/14/2016 1:09 AM, owl wrote:
>
>
>> Have your code do that kind of stuff over and over, toss in a little
>> math and some text formatting, and you're done.
>
>
> ?!?!
>
> I'm all over it. I know how to write frickin' newsgroup stats code...
>
> ----------------------------------------------------------
> import sys, nntplib
> SRV = "reader80.eternal-september.org"
> GRP = "comp.os.linux.advocacy"
> news = nntplib.NNTP(SRV,80,"<usr>","<pwd>")
> resp, IDs, beginID, endID, grpNm = news.group(GRP)
> getLatest = int(sys.argv[2])
> firstID = int(endID) - getLatest + 1
> lastID = int(endID)
> articles = "%s-%s" % (firstID, lastID)
> def calcStat(stat, hdr, rng):
> p = []
> for item in stat:
> resp, data = news.xhdr(item,rng)
> for i in range(len(data)): p.append(data[i][1])
> x = [(i,p.count(i)) for i in set(p)]
> x.sort(key=lambda s: (-s[1], s[0].lower()))
> print "Posts %s %s" % (len(set(p)), hdr)
> print "----- --------------------------------------------------"
> for val in x: print " %s %s" % (val[1], val[0])
> print "---------------------------------------------------------"
> if len(p) == getLatest: print " " + str(len(p)) + " total"
> if len(p) != getLatest: print " %s total (%s posts missing the header)"
> % (len(p), getLatest-len(p))
> print; print
> def newThreadCount(rng):
> resp, references = news.xhdr("References", rng)
> resp, subjects = news.xhdr("Subject", rng)
> resp, messageIDs = news.xhdr("Message-ID",rng)
> t1,t2 = [],[]
> for refID, refs in references:
> if refs == "":
> for subID, subject in subjects:
> if refID == subID:
> for articleID, msgID in messageIDs:
> if refID == articleID:
> t1.append((refID, subject, msgID))
> for articleID, sub, msgID in t1:
> i = 0
> for refID, refs in references:
> if msgID in refs:i += 1
> t2.append((articleID, sub, msgID, i))
> t2.sort(key=lambda s: (-s[3], s[1].lower()))
> print "Posts %s %s" % (len(t2), "New Threads")
> print "----- ---------------------------------------------------------"
> for val in t2: print " %s %s" % (val[3], val[1])
> print "----- ---------------------------------------------------------"
> calcStat(['From'],"Posters", articles)
> calcStat(['User-Agent','X-Newsreader'],"Newsreaders", articles)
> calcStat(['Organization'],"Organizations", articles)
> newThreadCount(articles)
> news.quit()
> ----------------------------------------------------------
>
> (note: that's 50 TIGHT lines of hi-kualitee hobbyware)
>
> usage: python filename.py last N
>
>
>
> Melzzzzz ran away a while back when I asked why his code split a thread
> into 3 parts and counted them separately, while Thunderbird threaded and
> displayed it correctly.
>
> That's the main reason I wanted to see his code. But for some reason,
> he's afraid to give it up.
>
Cool, but you have to feed a number of posts, not all posts since a
particular date, like last week.
Back to comp.os.linux.advocacy | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Melzzzzz, where's your stats source code? DFS <nospam@dfs.com> - 2016-05-13 21:27 -0400
Re: Melzzzzz, where's your stats source code? Melzzzzz <mel@zzzzz.com> - 2016-05-14 04:11 +0200
Re: Melzzzzz, where's your stats source code? DFS <nospam@dfs.com> - 2016-05-13 23:08 -0400
Re: Melzzzzz, where's your stats source code? owl <owl@rooftop.invalid> - 2016-05-14 03:16 +0000
Re: Melzzzzz, where's your stats source code? Melzzzzz <mel@zzzzz.com> - 2016-05-14 05:22 +0200
Re: Melzzzzz, where's your stats source code? DFS <nospam@dfs.com> - 2016-05-14 20:47 -0400
Re: Melzzzzz, where's your stats source code? DFS <nospam@dfs.com> - 2016-05-14 00:02 -0400
Re: Melzzzzz, where's your stats source code? owl <owl@rooftop.invalid> - 2016-05-14 05:09 +0000
Re: Melzzzzz, where's your stats source code? DFS <nospam@dfs.com> - 2016-05-15 12:00 -0400
Re: Melzzzzz, where's your stats source code? owl <owl@rooftop.invalid> - 2016-05-15 17:07 +0000
Re: Melzzzzz, where's your stats source code? DFS <nospam@dfs.com> - 2016-05-15 14:12 -0400
Re: Melzzzzz, where's your stats source code? DFS <nospam@dfs.com> - 2016-05-15 20:05 -0400
Re: Melzzzzz, where's your stats source code? owl <owl@rooftop.invalid> - 2016-05-16 01:45 +0000
Re: Melzzzzz, where's your stats source code? owl <owl@rooftop.invalid> - 2016-05-16 02:06 +0000
Re: Melzzzzz, where's your stats source code? Melzzzzz <mel@zzzzz.com> - 2016-05-14 15:00 +0200
Re: Melzzzzz, where's your stats source code? DFS <nospam@dfs.com> - 2016-05-16 19:16 -0400
Re: Melzzzzz, where's your stats source code? Melzzzzz <mel@zzzzz.com> - 2016-05-17 01:28 +0200
Re: Melzzzzz, where's your stats source code? DFS <nospam@dfs.com> - 2016-05-16 19:45 -0400
Re: Melzzzzz, where's your stats source code? Steve Carroll <fretwizzer@gmail.com> - 2016-05-16 18:19 -0700
Re: Melzzzzz, where's your stats source code? DFS <nospam@dfs.com> - 2016-05-18 09:14 -0400
No body wants your defective source code John Gohde <john.h.gohde@gmail.com> - 2016-05-13 20:27 -0700
Re: No body wants your defective source code owl <owl@rooftop.invalid> - 2016-05-14 03:45 +0000
Can owl kindly STOP pooping crap all over the place? John Gohde <john.h.gohde@gmail.com> - 2016-05-14 05:26 -0700
Re: Melzzzzz, where's your stats source code? 7 <7@enemygadgets.com> - 2016-05-14 11:14 +0000
Re: Melzzzzz, where's your stats source code? John Gohde <john.h.gohde@gmail.com> - 2016-05-14 05:28 -0700
csiph-web