3 # vi:si:et:sw=4:sts=4:ts=4
6 # parse HTML from bugzilla.gnome.org to create a list of bugs for a given
7 # product, component and target_milestone
16 # a sample bug line we parse for future reference:
17 #<TR VALIGN=TOP ALIGN=LEFT CLASS="Nor" ><TD><A HREF="show_bug.cgi?id=78267">78267</A> <td class=severity><nobr>min</nobr></td><td class=priority><nobr>Nor</nobr></td><td class=owner><nobr>thomas@apestaart.org</nobr></td><td class=status><nobr>RESO</nobr></td><td class=resolution><nobr>FIXE</nobr></td><td class=summary>autogen.sh doesn't take --prefix and similar to configure</td></TR>
19 # a sample bug section after olav's updating of bugzilla
20 # <td class="first-child">
21 # <a href="show_bug.cgi?id=147641">147641</a>
22 # <span style="display: none"></span>
25 # <td style="white-space: nowrap">nor
27 # <td style="white-space: nowrap">Nor
29 # <td style="white-space: nowrap">Linu
31 # <td style="white-space: nowrap">GStreamer
33 # <td style="white-space: nowrap">RESO
35 # <td style="white-space: nowrap">FIXE
37 # <td >[docs] pydoc segfaults when viewing gst package doc
43 URL
= 'http://bugzilla.gnome.org/buglist.cgi?product=%s&component=%s&target_milestone=%s'
45 # reg = re.compile('<TR.*id=(\d+)".*summary>(.*)<\/td')
49 FOOTER
= '\n Contributors\n'
51 default_product
= "gtk-doc"
55 # after Olav's changes, it's now number 8
58 # Horrible, don't look here
59 class HP(HTMLParser
.HTMLParser
):
61 HTMLParser
.HTMLParser
.__init
__(self
)
68 def handle_starttag(self
, tag
, data
):
73 elif self
.tr
and tag
.startswith('td'):
76 # all > refs are handled through this method; append them to self.descr
77 def handle_entityref(self
, name
):
78 self
.descr
+= " &%s; " % name
80 # can be called more than once for one td
81 def handle_data(self
, data
):
88 #print self.td, self.tr, repr(data)
90 # check what td it is in
93 self
.bugno
= int(data
)
94 #print "got id: ", self.bugno
97 elif self
.td
== TD_SUMMARY
:
100 #print "got descr: ", self.descr
102 def handle_endtag(self
, tag
):
106 #print "end tag: ", self.bugno, self.descr
108 self
.bugs
.append((self
.bugno
, self
.descr
))
114 print 'Usage: %s component milestone [product] [file]' % args
[0]
121 product
= default_product
130 url
= URL
% (product
, urllib
.quote(component
), milestone
)
131 fd
= urllib
.urlopen(url
)
138 for bug_id
, summary
in hp
.bugs
:
139 lines
.append(ITEM
% (bug_id
, summary
))
141 bugs
= "\n".join(lines
)
147 #doc = codecs.open(output, "r", encoding='utf-8').read()
148 doc
= open(output
, "r").read()
149 matcher
= re
.compile('(.*)<bugs>.*</bugs>(.*)',
151 match
= matcher
.search(doc
)
152 pre
= match
.expand('\\1')
153 post
= match
.expand('\\2')
155 backup
= output
+ ".bugs.bak"
156 os
.rename(output
, backup
)
157 handle
= open(output
, "w")
158 handle
.write(pre
+ bugs
+ post
)
160 if __name__
== '__main__':
161 sys
.exit(main(sys
.argv
))