help="Report additional debugging while loading USNs",
                  action='store_true')
parser.add_option(
    "-v",
    "--verbose",
    help="Show isummary and package descriptions for each reported USN",
    action='store_true')
parser.add_option("-u",
                  "--update",
                  help="Clear unfilled isummary template fields",
                  action='store_true')
(opt, args) = parser.parse_args()

cves = dict()

config = cve_lib.read_config()

changed = False
dbfile = None
if len(args) < 1:
    dbfile = config['usn_db_copy']
else:
    dbfile = args[0]

if opt.debug:
    print("Loading %s ..." % (dbfile), file=sys.stderr)
db = usn_lib.load_database(dbfile)

if len(args) < 2:
    usns = sorted(db, key=lambda a: list(map(int, a.split('-'))))
else:
def get_cves(bug):
    cves = []
    if bug.cves != None:
        for c in bug.cves:
            cves.append("CVE-" + c.sequence)

    return cves


#
# This should be api-ified
# Need to figure out a way to get a list of bugs via an API query
#
from launchpadbugs.connector import ConnectBugList
BugList = ConnectBugList()
cve_lib.read_config()
BugList.authentication = cve_lib.config["plb_authentication"]

url = "https://bugs.launchpad.net/~ubuntu-security/+bugs?field.searchtext=&orderby=-importance&field.status%3Alist=INPROGRESS&assignee_option=any&field.assignee=&field.bug_reporter=&field.bug_supervisor=&field.bug_commenter=&field.subscriber=&field.status_upstream-empty-marker=1&field.omit_dupes.used=&field.has_patch.used=&field.has_patch=on&field.has_cve.used=&field.tag=&field.tags_combinator=ANY&search=Search"
if opt.any:
    url = "https://bugs.launchpad.net/~ubuntu-security/+bugs?field.searchtext=&orderby=-importance&field.status%3Alist=NEW&field.status%3Alist=CONFIRMED&field.status%3Alist=TRIAGED&field.status%3Alist=INPROGRESS&field.status%3Alist=FIXCOMMITTED&assignee_option=any&field.assignee=&field.bug_reporter=&field.bug_supervisor=&field.bug_commenter=&field.subscriber=ubuntu-security&field.status_upstream-empty-marker=1&field.omit_dupes.used=&field.omit_dupes=on&field.has_patch.used=&field.has_patch=on&field.has_cve.used=&field.tag=&field.tags_combinator=ANY&search=Search"
#
# end should be api-ified section
#

for info in BugList(url):
    num = info.bugnumber
    bug = lp.bugs[num]

    bug_url = "http://launchpad.net/bugs/%s" % (num)
    bug_cves = get_cves(bug)