2009-10-27 13:27:32 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2009-10-27 14:19:12 +01:00
|
|
|
# This program is free software. It comes without any warranty, to
|
|
|
|
# the extent permitted by applicable law. You can redistribute it
|
|
|
|
# and/or modify it under the terms of the Do What The Fuck You Want
|
|
|
|
# To Public License, Version 2, as published by Sam Hocevar. See
|
|
|
|
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
|
|
|
|
|
|
|
# Author: Stefan Ritter <xeno@thehappy.de>
|
2009-10-27 16:39:44 +01:00
|
|
|
# Description: Query Debian WNPP pages
|
2009-10-27 14:19:12 +01:00
|
|
|
|
2009-10-27 13:27:32 +01:00
|
|
|
import urllib2, sys, re
|
2009-10-27 14:19:12 +01:00
|
|
|
from optparse import OptionParser
|
2009-10-27 13:27:32 +01:00
|
|
|
|
2009-10-27 14:19:12 +01:00
|
|
|
parser = OptionParser()
|
2009-10-27 16:39:44 +01:00
|
|
|
parser.add_option('-i', action='store_true', dest='itp', default=False, help='Query ITPs')
|
|
|
|
parser.add_option('-r', action='store_true', dest='rfp', default=False, help='Query RFPs')
|
|
|
|
parser.add_option('--min', dest='min_days_old', type="int", help='Minimum age (in days)')
|
|
|
|
parser.add_option('--max', dest='max_days_old', type="int", help='Maximum age (in days)')
|
2009-10-27 14:19:12 +01:00
|
|
|
(options, args) = parser.parse_args()
|
2009-10-27 13:27:32 +01:00
|
|
|
|
2009-10-27 16:39:44 +01:00
|
|
|
if not options.min_days_old and not options.max_days_old or not options.itp and not options.rfp or options.itp and options.rfp:
|
|
|
|
parser.error('You have to give at least one of --min or --max and one of -r or -i options.')
|
2009-10-27 14:19:12 +01:00
|
|
|
sys.exit
|
2009-10-27 13:27:32 +01:00
|
|
|
|
2009-10-27 14:19:12 +01:00
|
|
|
if not options.min_days_old: options.min_days_old = 0
|
|
|
|
if not options.max_days_old: options.max_days_old = 9999
|
|
|
|
|
2009-10-27 13:27:32 +01:00
|
|
|
reports = []
|
|
|
|
item = []
|
2009-10-27 17:02:56 +01:00
|
|
|
|
|
|
|
if options.itp: url = urllib2.urlopen('http://www.debian.org/devel/wnpp/being_packaged')
|
|
|
|
else: url = urllib2.urlopen('http://www.debian.org/devel/wnpp/requested')
|
2009-10-27 13:27:32 +01:00
|
|
|
|
2009-10-27 16:39:44 +01:00
|
|
|
for line in url:
|
2009-10-27 17:02:56 +01:00
|
|
|
|
|
|
|
if re.findall('bugs\.debian\.org', line) \
|
|
|
|
or re.match('requested(.*)ago', line) \
|
|
|
|
or re.match('^(.*)days in preparation\.$', line) \
|
|
|
|
or re.match('^in preparation since(.*)$', line):
|
|
|
|
|
|
|
|
if re.match('^\<ul\>(.*),', line) \
|
|
|
|
or re.match ('^ \<li\>\<a href(.*)\</a\>,', line):
|
|
|
|
|
|
|
|
link = re.sub('<ul>', '', line).strip()
|
2009-10-27 16:39:44 +01:00
|
|
|
link = line[14:43]
|
2009-10-27 13:27:32 +01:00
|
|
|
item.append(link)
|
|
|
|
|
2009-10-27 17:02:56 +01:00
|
|
|
name = re.sub('<ul>', '', line).strip()
|
2009-10-27 13:27:32 +01:00
|
|
|
name = name[44:]
|
|
|
|
name = name.split(':', 1)[0]
|
|
|
|
item.append(name)
|
|
|
|
|
2009-10-27 17:02:56 +01:00
|
|
|
if re.match('^requested(.*)$', line) \
|
|
|
|
or re.match('^(.*)days in preparation(.*)$', line) \
|
|
|
|
or re.match('^in preparation since yesterday(.*)$', line):
|
|
|
|
|
2009-10-27 16:39:44 +01:00
|
|
|
if options.itp:
|
2009-10-27 17:02:56 +01:00
|
|
|
|
|
|
|
if re.match('^in preparation since yesterday', line): days = '1'
|
|
|
|
else: days = line.split(' ')[0]
|
|
|
|
|
|
|
|
else: days = line.split(' ')[1]
|
2009-10-27 13:27:32 +01:00
|
|
|
item.append(days)
|
|
|
|
|
|
|
|
if len(item) == 3:
|
|
|
|
reports.append(item)
|
|
|
|
item = []
|
|
|
|
|
|
|
|
for entry in reports:
|
2009-10-27 17:02:56 +01:00
|
|
|
if int(entry[2]) <= options.max_days_old \
|
|
|
|
and int(entry[2]) >= options.min_days_old:
|
|
|
|
|
2009-10-27 16:39:44 +01:00
|
|
|
print entry[1] + ': ' + entry[2] + ' days ago (' + entry[0] + ')'
|