rev 3565 - scripts
Pierre Habouzit
madcoder at costa.debian.org
Mon Apr 17 15:03:11 UTC 2006
Author: madcoder
Date: 2006-04-17 15:03:09 +0000 (Mon, 17 Apr 2006)
New Revision: 3565
Modified:
scripts/bzlink.py
Log:
Use aba's bts2ldap gateway to guess the debian bug that is related to our
KDE one.
Now, I have: the changes of the kde bugs, the additional comments of the
kde bugs, and the debian bug. let the fest begin !
Modified: scripts/bzlink.py
===================================================================
--- scripts/bzlink.py 2006-04-17 14:36:10 UTC (rev 3564)
+++ scripts/bzlink.py 2006-04-17 15:03:09 UTC (rev 3565)
@@ -1,11 +1,29 @@
#! /usr/bin/env python
-import sys, re, os, email
+import sys, re, os, email, ldap
class InvalidBzMsg(Exception):
def __init__(self, reason):
self.args = (reason)
+class BtsQuery:
+ dn = "dc=current,dc=bugs,dc=debian,dc=org"
+
+ def __init__(self):
+ self.l = ldap.initialize("ldap://bts2ldap.debian.net:10101")
+ self.l.simple_bind_s()
+
+ def search(self, filter):
+ return [i[1] for i in self.l.search_s(BtsQuery.dn, ldap.SCOPE_SUBTREE, filter)]
+
+ def fromBzBug(self, patterns, nb):
+ filter = ''.join(["(debbugsForwardedTo=" + (p % (nb)) + ")" for p in patterns])
+ l = self.search("(|%s)" % filter)
+ if len(l) is 0:
+ return None
+ else:
+ return l[0]
+
class BzMsg:
_blocksRegex = re.compile(r"(^------- [^\n]* -------)\n", re.MULTILINE)
_modifRegex = re.compile(r"^ *([^ |]*)\|([^| ]*) *\|(.*)$")
@@ -83,7 +101,18 @@
for (w, r, a) in modifs:
self.modifs[w] = r, a
-bzm = BzMsg(sys.stdin)
-print "Bug Number: #%i\n" % (bzm.bug)
-print bzm.additional
-print bzm.modifs
+
+
+if __name__ == "__main__":
+
+ bzm = BzMsg(sys.stdin)
+ print "Bug Number: #%i\n" % (bzm.bug)
+ print bzm.additional
+ print bzm.modifs
+
+ patterns = [ "http://bugs.kde.org/show_bug.cgi?id=%i",
+ "http://bugs.kde.org/%i",
+ "%i at bugs.kde.org" ]
+ bts = BtsQuery()
+ print bts.fromBzBug(patterns, bzm.bug)
+
More information about the pkg-kde-commits
mailing list