#!/usr/bin/python

import re, urllib
from BeautifulSoup import BeautifulSoup
from btsutils.debbugs import debbugs

def open_rc_bugs():
    soup = BeautifulSoup(urllib.urlopen('http://bugs.debian.org/release-critical/other/testing.html'))
    bugnums = (x['name'] for x in soup.findAll('a', attrs={'name': re.compile(r'^[0-9]+')}))

    bts = debbugs()
    allbugs = (bts.get(bug) for bug in bugnums)

    for bug in allbugs:
        if bug.status != 'done':
            yield bug

if __name__ == '__main__':
    for bug in open_rc_bugs():
        print '%s\t%s\t%s' % (bug.bug, bug.package, bug.summary)
