[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Prototype script to determine last commit and last upload.



On Wed, Apr 14, 2010 at 09:17:29AM +0200, Stefano Zacchiroli wrote:

> > > that. I've never looked at the code, but you can find it here:
> > > 
> > >   svn+ssh://svn.debian.org/svn/nm/trunk/nm-templates/minechangelogs
> > 
> > It does:
> >   exec ssh lintian.debian.org "~enrico/bin/minechangelogs $ARGS"
> > 
> > I have to admit it is not the best reference I have seen so far, since I
> > do not (to my knowledge) have ssh access to l.d.o. It is possible to
> > fetch this from another location?
> 
> I've no idea, but I'm Cc-ing Enrico now which surely knows :)

It's only on lintian.debian.org I'm afraid, but since there's nothing
secret about it I'm attaching it to this mail.


Ciao,

Enrico

-- 
GPG key: 4096R/E7AD5568 2009-05-08 Enrico Zini <enrico@enricozini.org>
#!/usr/bin/python

import sys
import os
import os.path
import re
import time

TOP="/srv/lintian.debian.org/laboratory/source"
re_ts = re.compile(r"^ --.+>\s+(\w+\s*,\s*\d+\s+\w+\s*\d+\s+\d+:\d+:\d+)")

def parse_changelog(fname):
	block = []
	tstamp = ""
	for line in open(fname):
		mo = re_ts.match(line)
		if mo:
			tstamp = mo.group(1)
			
		if line and not line[0].isspace():
			if block: yield "".join(block).rstrip(), tstamp
			block = []
		block.append(line)
	if block: yield "".join(block).rstrip(), tstamp

parsed = 0
count = 0
blocks = []
for pkg in os.listdir(TOP):
	if pkg == "debian-keyring": continue
	chfile = os.path.join(TOP, pkg, "debfiles/changelog")
	if not os.path.exists(chfile): continue
	for block, tstamp in parse_changelog(chfile):
		count += 1
		found = False
		for pattern in sys.argv[1:]:
			if block.find(pattern) != -1:
				found = True
				break
		if not found: continue
		try:
			ts = time.mktime(time.strptime(tstamp, "%a, %d %b %Y %H:%M:%S"))
		except:
			print >>sys.stderr, "Cannot parse timestamp:", tstamp
			ts = 0
		blocks.append((block, ts))
	parsed += 1
	if parsed % 500 == 0:
		print >>sys.stderr, "Parsed %d changelogs, found %d matches" % (parsed, len(blocks))

blocks.sort(key=lambda x:x[1], reverse=True)

for block, ts in blocks:
	print block
	print

print "Looked at %d changelog blocks in %d files, found %d matching blocks" % (count, parsed, len(blocks))

Attachment: signature.asc
Description: Digital signature


Reply to: