ubuntu-dev-tools/hugdaylist

124 lines
3.7 KiB
Plaintext
Raw Normal View History

#!/usr/bin/python
# -*- coding: utf-8 -*-
#
2008-08-10 23:03:05 +02:00
# Copyright (C) 2007 Canonical Ltd., Daniel Holbach
# Copyright (C) 2008 Jonathan Patrick Davies <jpds@ubuntu.com>
#
# 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, version 3 of the License.
#
# 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, see <http://www.gnu.org/licenses/>.
#
#
# hugdaylist - produces MoinMoin wiki formatted tables based on a Launchpad bug
# list.
#
# hugdaylist <url>
# - produces lists like https://wiki.ubuntu.com/UbuntuBugDay/20070912?action=raw
#
# hugdaylist -n <howmany> <url>
# - will only list <howmany> URLs.
#
import os
import re
import string
import sys
from optparse import OptionParser
try:
import launchpadbugs.connector as Connector
BugList = Connector.ConnectBugList()
Bug = Connector.ConnectBug(method="Text")
except ImportError:
print >> sys.stderr, \
"python-launchpad-bugs (>= 0.2.25) needs to be installed to use hugdaylist."
sys.exit(1)
def check_args():
howmany = -1
url = ""
# Our usage options.
usage = "usage: %prog [-n <number>] launchpad-buglist-url"
optParser = OptionParser(usage)
# Options - namely just the number of bugs to output.
optParser.add_option("-n", "--number", action = "store_true",
dest = "number", help = "Number of entries to output.")
# Parse arguments.
(options, args) = optParser.parse_args()
# Check if we want a number other than the default.
if options.number:
try:
howmany = int(args[0])
except:
print >> sys.stderr, "Option '-n' requires an integer for an " \
"argument."
optParser.print_help()
sys.exit(1)
# Check that we have an URL.
if not args:
print >> sys.stderr, "An URL pointing to a Launchpad bug list is " \
"required."
optParser.print_help()
sys.exit(1)
else:
url = args[0]
return (howmany, url)
def filter_unsolved(b):
bug = Bug(int(b))
# Filter out special types of bugs:
# - https://wiki.ubuntu.com/Bugs/HowToTriage#Special%20types%20of%20bugs
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] and \
'ubuntu-archive' 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 """
## ||<rowbgcolor="#CCFFCC"> This task is done || somebody || ||
## ||<rowbgcolor="#FFFFCC"> This task is assigned || somebody || <status> ||
## ||<rowbgcolor="#FFEBBB"> This task isn't || ... || ||
## ||<rowbgcolor="#FFCCCC"> This task is blocked on something || somebody || <explanation> ||
|| Bug || Subject || Triager ||"""
for i in list(l)[:howmany]:
print '||<rowbgcolor="#FFEBBB"> [%s %s] || %s || ||' % \
(i.url, i.bugnumber, i.summary)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print >> sys.stderr, "Aborted."
sys.exit(1)