From: Mike O'Connor Date: Wed, 14 Jan 2009 07:27:08 +0000 (-0500) Subject: a script that categorizes bugs against ftp.debian.org X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f6d07d01e45ee2049f71b18c91879ad0d6718cc;p=dak a script that categorizes bugs against ftp.debian.org This script uses python-btsutils to look for bugs filed against ftp.debian.org which have not yet been classified with usertags. Any unclassified bugs are matched against regular expression and possibly being classified. Currently the script only classifies bugs with RM: as their subject and moves them into the "Removal Requested" class. Currently the script just outputs a list of commands suitable for emailing to control@debian.org Signed-off-by: Mike O'Connor --- diff --git a/scripts/debian/bts-categorize b/scripts/debian/bts-categorize new file mode 100755 index 00000000..be9687e4 --- /dev/null +++ b/scripts/debian/bts-categorize @@ -0,0 +1,103 @@ +#!/usr/bin/python + +# categorize-bts -- categorize +# +# Copyright 2009 Mike O'Connor +# +# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +# USA. + +import sys +import re +import logging +log = logging.getLogger() + +from btsutils.debbugs import debbugs + +class BugClassifier(object): + """ + classify bugs using usertags based on the bug subject lines + + >>> BugClassifier.rm_re.match( "RM: asdf" ) != None + True + >>> BugClassifier.rm_re.match( "[dak] Packages.diff/Index broken" ) != None + False + >>> BugClassifier.dak_re.match( "[dak] Packages.diff/Index broken" ) != None + True + """ + rm_re = re.compile( "^RM" ) + dak_re = re.compile( "^\[dak\]" ) + classifiers = { rm_re: 'remove', + dak_re: "dak" } + + def __init__( self ): + + self.bts = debbugs() + self.bts.setUsers(['ftp.debian.org@packages.debian.org']) + + + def unclassified_bugs(self): + """ + Returns a list of bugs which have not yet been classified by one + of our usertags. + """ + return [ bug for bug in self.bts.query("pkg:ftp.debian.org") \ + if bug.status=='pending' and not bug.usertags ] + + + def classify_bug(self, bug): + """ + if any of our classifiers match, return a newline terminated + command to set an appropriate usertag, otherwise return an + empty string + """ + retval = "" + + for classifier in self.classifiers.keys(): + if classifier.match(bug.summary): + retval = "usertag %s %s\n" % (bug.bug, + self.classifiers[classifier]) + break + + log.debug( retval ) + return retval + + +def main(): + """ + for now, we just dump a list of commands that could be sent for + control@b.d.o + """ + + level=logging.INFO + level=logging.DEBUG + + logging.basicConfig( level=level, + format='%(asctime)s %(levelname)s %(message)s', + stream = sys.stderr ) + + controls = "user ftp.debian.org@packages.debian.org\n" + + bc = BugClassifier() + for bug in bc.unclassified_bugs(): + controls += bc.classify_bug(bug) + + print controls + + +if __name__ == "__main__": +# import doctest +# doctest.testmod() + main()