#!/usr/bin/python #mia-debian shows when a maintainer made his last upload #Copyright (C) 2005 Christian Aichinger # #This program is free software; you can redistribute it and/or #modify it under the terms of the GNU General Public License #as published by the Free Software Foundation; either version 2 #of the License, or (at your option) any later version. # #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. # #You should have received a copy of the GNU General Public License #along with this program; if not, write to the Free Software #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import sys import re import urllib2 import datetime class Proxy: def __init__( self, subject ): self.__subject = subject def __getattr__( self, name ): return getattr( self.__subject, name ) # Can't override datetime.date's __str__ method, so we just proxy it # The new object behaves just like datetime.date, except that it's a class # instead of a type. So we _can_ override its __str__ UNKNOWN = Proxy(datetime.date(1980,1,1)) UNKNOWN.__str__ = lambda: "Unknown" def get_last(f, name): for l in f: l = l.strip('\n') if l.count("Accepted") and l.count("
  • [") and \ l.count(name): l = l[l.find("
  • ["):] last = l.replace("
  • [", "")[0:10] return last return "Unknown" def date_from_last(last): d = last.split('-') if len(d) == 3: d = [int(i) for i in d] date = datetime.date(d[0],d[1],d[2]) return date return UNKNOWN def look_at(URL, name): str = get_last(urllib2.urlopen(URL), name) return date_from_last(str) def pkgname_from_url(URL): pkgname = URL[30:] pkgname = pkgname[pkgname.find('/')+1:][:-5] return pkgname def main(): if len(sys.argv) != 2: print >>sys.stderr, "Usage: %s " % sys.argv[0] sys.exit(1) URL = 'http://qa.debian.org/developer.php?login=' + sys.argv[1].strip() sys.stdout.write("Getting developer information... ") iter = urllib2.urlopen(URL) print "done." max_date = UNKNOWN name = '' for line in iter: if not name and line.count("Packages overview for"): name = re.search(r'Packages overview for ([^<]*)', line).groups()[0] if not line.count("[pts]"): continue match = re.search(r'\[pts\]', line) if match: URL = match.groups()[0] pkgname = pkgname_from_url(URL) sys.stdout.write("Last upload for %-23s " % (pkgname+':')) date = look_at(URL, name) if date > max_date: max_date = date print str(date) print "" print "Last upload by %s (AFAICS):" % name print str(max_date) if __name__ == '__main__': main()