#!/usr/bin/env python # Licensed under the GPLv3 by Kenneth Prugh (C) 2008 # DOM example adapted from one of my Java projects which displays info about # the desired bug from the Gentoo Bugzilla from xml.dom import minidom import urllib2 class gbug(): def getValueForTag(self, Element, tag): NodeList = Element.getElementsByTagName(tag) Element = NodeList.item(0) return Element.firstChild.nodeValue def getBug(self, bugID): self.bugID = bugID bugURL = urllib2.urlopen("http://bugs.gentoo.org/show_bug.cgi?ctype=xml&id="+bugID) doc = minidom.parse(bugURL) Element = doc.documentElement bugNodes = doc.getElementsByTagName("bug") bugEL = bugNodes.item(0) print "Description: " + self.getValueForTag(bugEL, "short_desc") print "Reporter: " + self.getValueForTag(bugEL, "reporter") print "Created: " + self.getValueForTag(bugEL, "creation_ts") print "Status: " + self.getValueForTag(bugEL, "bug_status") print "Assigned to: " + self.getValueForTag(bugEL, "assigned_to") main = gbug() input = raw_input("bug #: ") main.getBug(input)