#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright 2007, Canonical, Daniel Holbach # # GPL 3 # # hugdaylist # - produces lists like https://wiki.ubuntu.com/UbuntuBugDay/20070912?action=raw # # hugdaylist -n # - will only list URLs # import re import os import sys import string try: import launchpadbugs.connector as Connector BugList = Connector.ConnectBugList() Bug = Connector.ConnectBug(method="Text") except ImportError: print >> sys.stderr, \ "You need python-launchpad-bugs (>= 0.2.25) installed to use hugdaylist." sys.exit(1) USAGE = "hugdaylist [-n ] " def check_args(): howmany = -1 url = "" if len(sys.argv) < 2: print >> sys.stderr, USAGE sys.exit(1) if sys.argv[1] == "-n": try: howmany = int(sys.argv[2]) except IndexError: print "Option '-n' requires a number." if len(sys.argv) < 4: print USAGE sys.exit(1) url = sys.argv[3] else: url = sys.argv[1] return (howmany, url) def filter_unsolved(b): bug = Bug(int(b)) return filter(lambda a: a.status != 'Fix Committed' and \ (a.assignee in ['motu','desktop-bugs'] or \ not a.assignee), bug.infotable) and \ 'ubuntu-main-sponsors' not in [str(s) for s in bug.subscribers] and \ 'ubuntu-universe-sponsors' not in [str(s) for s in bug.subscribers] def main(): (howmany, url) = check_args() bl = BugList(url) l = filter(filter_unsolved, bl) if not l: print "BugList of %s is empty." % url sys.exit(0) if howmany == -1: howmany = len(l) print """ ## || This task is done || somebody || || ## || This task is assigned || somebody || || ## || This task isn't || ... || || ## || This task is blocked on something || somebody || || || Bug || Subject || Triager ||""" for i in list(l)[:howmany]: print '|| [%s %s] || %s || ||' % \ (i.url, i.bugnumber, i.summary) if __name__ == '__main__': try: main() except KeyboardInterrupt: print >> sys.stderr, "Aborted" sys.exit(1)