rev 3586 - in debbugs-illa: . bz

Pierre Habouzit madcoder at costa.debian.org
Tue Apr 18 14:15:58 UTC 2006


Author: madcoder
Date: 2006-04-18 14:15:57 +0000 (Tue, 18 Apr 2006)
New Revision: 3586

Added:
   debbugs-illa/bz/
   debbugs-illa/bz/__init__.py
   debbugs-illa/bz/report.py
Modified:
   debbugs-illa/
   debbugs-illa/bzlink.py
   debbugs-illa/bzsync.py
Log:
clean bzsync a bit.
put the bzInterface into the bz/ lib.

will do the same for the bts related functions




Property changes on: debbugs-illa
___________________________________________________________________
Name: svn:ignore
   + *.pyc



Property changes on: debbugs-illa/bz
___________________________________________________________________
Name: svn:ignore
   + *.pyc



Added: debbugs-illa/bz/__init__.py
===================================================================
--- debbugs-illa/bz/__init__.py	2006-04-18 13:45:27 UTC (rev 3585)
+++ debbugs-illa/bz/__init__.py	2006-04-18 14:15:57 UTC (rev 3586)
@@ -0,0 +1,45 @@
+# vim:set encoding=utf-8:
+###############################################################################
+# Copyright:
+#   © 2006 Pierre Habouzit <madcoder at debian.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the University nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+###############################################################################
+
+from report import Report as BzReport
+
+import commands
+
+class BzInterface:
+    def __init__(self, bzUrl):
+        self.baseurl   = bzUrl.rstrip('/')
+        self._wget_cmd = "wget -O - -o /dev/null %s/xml.cgi?id=%%s" % (self.baseurl)
+
+    def getReport(self, bugNum):
+        return BzReport(bugNum, commands.getoutput(self._wget_cmd % (bugNum)))
+
+
+__all__ = ['BzInterface', 'BzReport']
+

Added: debbugs-illa/bz/report.py
===================================================================
--- debbugs-illa/bz/report.py	2006-04-18 13:45:27 UTC (rev 3585)
+++ debbugs-illa/bz/report.py	2006-04-18 14:15:57 UTC (rev 3586)
@@ -0,0 +1,59 @@
+# vim:set encoding=utf-8:
+###############################################################################
+# Copyright:
+#   © 2006 Pierre Habouzit <madcoder at debian.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the University nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+###############################################################################
+
+from xml.dom import minidom, Node
+
+class Report:
+    def __init__(self, bugNum, str):
+        self.bug = bugNum
+        self.doc = minidom.parseString(str)
+
+    def unlink(self):
+        self.doc.unlink()
+
+    def getStatus(self):
+        try:
+            return self.doc.getElementsByTagName('bug_status')[0].childNodes[0].data
+        except:
+            return None
+
+    def getResolution(self):
+        try:
+            return self.doc.getElementsByTagName('resolution')[0].childNodes[0].data
+        except:
+            return None
+
+    def getCC(self):
+        try:
+            ccs = self.doc.getElementsByTagName('cc')[0]
+            return map(lambda n: n.childNodes[0].data, ccs)
+        except:
+            return None
+

Modified: debbugs-illa/bzlink.py
===================================================================
--- debbugs-illa/bzlink.py	2006-04-18 13:45:27 UTC (rev 3585)
+++ debbugs-illa/bzlink.py	2006-04-18 14:15:57 UTC (rev 3586)
@@ -1,6 +1,8 @@
 #! /usr/bin/env python
+# vim:set encoding=utf-8:
 ###############################################################################
-# Cppyright: Pierre Habouzit <madcoder at debian.org>
+# Copyright:
+#   © 2006 Pierre Habouzit <madcoder at debian.org>
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions

Modified: debbugs-illa/bzsync.py
===================================================================
--- debbugs-illa/bzsync.py	2006-04-18 13:45:27 UTC (rev 3585)
+++ debbugs-illa/bzsync.py	2006-04-18 14:15:57 UTC (rev 3586)
@@ -1,6 +1,8 @@
 #! /usr/bin/env python
+# vim:set encoding=utf-8:
 ###############################################################################
-# Cppyright: Pierre Habouzit <madcoder at debian.org>
+# Copyright:
+#   © 2006 Pierre Habouzit <madcoder at debian.org>
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -35,35 +37,35 @@
 
 """
 
-import sys, re, os, commands, email, smtplib
-from xml.dom import minidom, Node
+import sys, re, os, email, smtplib
 from email.MIMEText import MIMEText
 from bzlink import BtsQuery, Config
 
-wget    = "wget -o /dev/null -O - http://bugs.kde.org/xml.cgi?id=%s"
+import bz
+
 bugurl = re.compile(r"^http://bugs.kde.org/(?:show_bug.cgi\?id=)?([0-9]*)$")
 
 def usage(exitCode = 1):
     print >> sys.stderr, (__doc__ % (sys.argv[0].split('/')[-1]))
     sys.exit(exitCode)
 
-def prepareMail(bug, bzBug, needsForwarded):
+def prepareMail(bug, rep, needsForwarded):
     body  = "user %s\n" % (Config.User)
     if needsForwarded:
-        body += "forwarded %s http://bugs.kde.org/%s\n" % (bug, bzBug)
-    body += "usertag %s =\n" % (bug)
+        body += "forwarded %s http://bugs.kde.org/%s\n" % (bug, rep.bug)
+    
+    tmp = rep.getStatus()
+    if tmp is not None:
+        body += "usertag %s + bzStatus-%s\n" % (rep.bug, tmp.lower())
 
+    tmp = rep.getResolution()
+    if tmp is not None:
+        body += "usertag %s + bzRes-%s\n" % (rep.bug, tmp.lower())
 
-    doc = minidom.parseString(commands.getoutput(wget % (bzBug)))
-    status = doc.getElementsByTagName('bug_status')[0].childNodes[0].data
-    body += "usertag %s + bzStatus-%s\n" % (bug, status.lower())
-    try:
-        resol = doc.getElementsByTagName('resolution')[0].childNodes[0].data
-        body += "usertag %s + bzRes-%s\n" % (bug, resol.lower())
-    except:
-        pass
-    doc.unlink()
+    body += "thanks\n"
 
+    print body
+    sys.exit(0)
     return body
 
 if __name__ == "__main__":
@@ -87,7 +89,10 @@
         bug = sys.argv[1]
     else: usage(1)
 
-    msg = MIMEText(prepareMail(bug, bzBug, fwd))
+    bzi = bz.BzInterface("http://bugs.kde.org")
+    rep = bzi.getReport(bzBug)
+
+    msg = MIMEText(prepareMail(bug, rep, fwd))
     msg['From'] = Config.From
     msg['To']   = 'control at bugs.debian.org'
     msg['X-Debbugs-No-Ack'] = 'no-acks'




More information about the pkg-kde-commits mailing list