3 # categorize-bts -- categorize
5 # Copyright 2009 Mike O'Connor <stew@vireo.org>
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 2, or (at your option) any
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25 log = logging.getLogger()
27 from btsutils.debbugs import debbugs
29 class BugClassifier(object):
31 classify bugs using usertags based on the bug subject lines
33 >>> BugClassifier.rm_re.match( "RM: asdf" ) != None
35 >>> BugClassifier.rm_re.match( "[dak] Packages.diff/Index broken" ) != None
37 >>> BugClassifier.dak_re.match( "[dak] Packages.diff/Index broken" ) != None
40 rm_re = re.compile( "^RM" )
41 dak_re = re.compile( "^\[dak\]" )
42 classifiers = { rm_re: 'remove',
48 self.bts.setUsers(['ftp.debian.org@packages.debian.org'])
51 def unclassified_bugs(self):
53 Returns a list of bugs which have not yet been classified by one
56 return [ bug for bug in self.bts.query("pkg:ftp.debian.org") \
57 if bug.status=='pending' and not bug.usertags ]
60 def classify_bug(self, bug):
62 if any of our classifiers match, return a newline terminated
63 command to set an appropriate usertag, otherwise return an
68 for classifier in self.classifiers.keys():
69 if classifier.match(bug.summary):
70 retval = "usertag %s %s\n" % (bug.bug,
71 self.classifiers[classifier])
80 for now, we just dump a list of commands that could be sent for
86 logging.basicConfig( level=level,
87 format='%(asctime)s %(levelname)s %(message)s',
90 controls = "user ftp.debian.org@packages.debian.org\n"
93 for bug in bc.unclassified_bugs():
94 controls += bc.classify_bug(bug)
99 if __name__ == "__main__":