[Debtags-commits] [SCM] Debian Data Export - A tool to publish Debian information branch, master, updated. 049668d1ebfe4e37668216e5b398b47add874ceb

Enrico Zini enrico at enricozini.org
Thu Nov 5 23:17:30 UTC 2009


The following commit has been merged in the master branch:
commit 049668d1ebfe4e37668216e5b398b47add874ceb
Author: David Paleino <d.paleino at gmail.com>
Date:   Thu Nov 5 23:06:08 2009 +0100

    First incomplete implementation of BTS plugin (uses SOAPpy)
    
    Signed-off-by: David Paleino <d.paleino at gmail.com>

diff --git a/plugins/bts.py b/plugins/bts.py
new file mode 100644
index 0000000..8d6d68c
--- /dev/null
+++ b/plugins/bts.py
@@ -0,0 +1,150 @@
+# -*- coding: utf-8 -*-
+import octofuss
+import re
+import SOAPpy
+
+class ByPackage(octofuss.Tree):
+    def __init__(self, name, soap):
+        doc = """List bugs of given package"""
+        super(ByPackage, self).__init__(name, doc=doc)
+        self.soap = soap
+
+    def ldoc(self, path, **kw):
+        if len(path) == 0: return super(ByPackage, self).ldoc(path)
+        if len(path) == 1: return "List bugs filed to the package %s" % path[0]
+        #if len(path) == 2: return "Bug #%s filed to the package %s" % (path[1], path[0])
+        if len(path) > 1: return None
+
+    def lget(self, path, **kw):
+        if len(path) == 0: return None
+        if len(path) == 1:
+            split = path[0].split(":")
+            if len(split) == 2:
+                # path[0] is in the form src:foo
+                return list(self.soap.get_bugs('src', split[1]))
+            else:
+                return list(self.soap.get_bugs('package', split[0]))
+
+        #if len(path) == 2: return self.soap.get_bug_log(path[1])
+
+        if len(path) > 1: return []
+
+    def lhas(self, path, **kw):
+        return True
+
+    def llist(self, path, **kw):
+        return []
+
+class ByMaint(octofuss.Tree):
+    def __init__(self, name, soap):
+        doc = """List bugs of given maintainer"""
+        super(ByMaint, self).__init__(name, doc=doc)
+        self.soap = soap
+
+    def ldoc(self, path, **kw):
+        if len(path) == 0: return super(ByMaint, self).ldoc(path)
+        if len(path) > 1: return None
+        return "Listing bugs assigned to %s" % path[0]
+
+    def lget(self, path, **kw):
+        if len(path) == 0: return None
+        if len(path) > 1: return None
+
+        return list(self.soap.get_bugs('maint', path[0]))
+
+    def lhas(self, path, **kw):
+        return True
+
+    def llist(self, path, **kw):
+        return []
+
+class ByEmail(octofuss.Tree):
+    def __init__(self, name, soap):
+        doc = """List bugs of given reporter"""
+        super(ByEmail, self).__init__(name, doc=doc)
+        self.soap = soap
+
+    def ldoc(self, path, **kw):
+        if len(path) == 0: return super(ByEmail, self).ldoc(path)
+        if len(path) == 1: return "Listing bugs filed by %s" % path[0]
+        if len(path) > 1: return None
+
+    def lget(self, path, **kw):
+        # /bts/byemail/<foo>
+        if len(path) == 0: return None
+        if len(path) == 1: return list(self.soap.get_bugs('submitter', path[0]))
+        if len(path) > 1: return None
+
+    def lhas(self, path, **kw):
+        return True
+
+    def llist(self, path, **kw):
+        return []
+
+class ByNumber(octofuss.Tree):
+    def __init__(self, name, soap):
+        doc = """Show bug number"""
+        super(ByNumber, self).__init__(name, doc=doc)
+        self.soap = soap
+
+    def ldoc(self, path, **kw):
+        if len(path) == 0: return super(ByNumber, self).ldoc(path)
+        if len(path) == 1: return "Listing status of bug #%s" % path[0]
+        if len(path) > 1: pass
+
+    def lget(self, path, **kw):
+        if len(path) == 0: return None
+        if len(path) == 1:
+            res = self.soap.get_status(path[0])
+
+            if res == "" or res == " ":
+                return []
+
+            if isinstance(res.item, list):
+                ret = [item.value._asdict() for item in res.item]
+            else:
+                ret = [res.item.value._asdict()]
+
+            # Fix statuses given by SOAP
+            for item in ret:
+                if item['pending'] == "pending":
+                    item['pending'] = "open"
+                elif item['pending'] == "pending-fixed":
+                    item['pending'] = "pending"
+                elif item['pending'] == "done":
+                    item['pending'] = "closed"
+
+                # FIXME: is this correct?
+                item['found'] = item['found'].item.key
+
+            return ret
+
+        if len(path) > 1: return None
+
+    def lhas(self, path, **kw):
+        return True
+
+    def llist(self, path, **kw):
+        return []
+
+def init(**kw):
+    conf = kw.get("conf", None)
+    canMock = False
+    forceMock = False
+    if conf:
+        canMock = conf.get("dde.mock.allow", canMock)
+        forceMock = conf.get("dde.mock.force", forceMock)
+
+    url = 'http://bugs-rietz.debian.org/cgi-bin/soap.cgi'
+    #url = 'http://bugs.donarmstrong.com/cgi-bin/soap.cgi'
+    ns = 'Debbugs/SOAP'
+    soap = SOAPpy.SOAPProxy(url, ns)
+
+    top = octofuss.Forest("bts", doc="Debian Bug Tracking System")
+
+    top.register(ByPackage("bypackage", soap))
+    top.register(ByMaint("bymaint", soap))
+    top.register(ByEmail("byemail", soap))
+    top.register(ByNumber("bynumber", soap))
+
+    yield dict(tree = top, root="/")

-- 
Debian Data Export - A tool to publish Debian information



More information about the Debtags-commits mailing list