2009-10-27 13:27:32 +01:00
|
|
|
#!/usr/bin/python
|
2009-10-28 12:38:09 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2009-10-27 13:27:32 +01:00
|
|
|
|
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
|
|
|
|
2010-10-27 10:48:59 +02:00
|
|
|
import sys, re
|
|
|
|
from urllib2 import urlopen
|
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 21:35:07 +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('-d', action='store_true', dest='description', default=False, help='show description of each package')
|
|
|
|
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-12-10 15:02:14 +01:00
|
|
|
sys.exit(0)
|
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
|
|
|
|
|
2010-10-27 10:48:59 +02:00
|
|
|
if options.itp: url = urlopen('http://www.debian.org/devel/wnpp/being_packaged')
|
|
|
|
else: url = urlopen('http://www.debian.org/devel/wnpp/requested')
|
2009-10-27 13:27:32 +01:00
|
|
|
|
2010-10-27 10:48:59 +02:00
|
|
|
reports, item = [], []
|
2009-10-28 15:51:41 +01:00
|
|
|
|
2009-11-03 15:00:34 +01:00
|
|
|
line_match = re.compile('(^(.*)bugs\.debian\.org(.*)$|^requested(.*)$|^in preparation since(.*)$|^(.*)days in preparation\.$)')
|
|
|
|
line_match_desc = re.compile('(^\<ul\>(.*),|^ \<li\>\<a href(.*)\</a\>,)')
|
|
|
|
line_match_age = re.compile('(^requested(.*)$|^(.*)days in preparation(.*)$|^in preparation since(.*)$)')
|
|
|
|
|
|
|
|
req_today = re.compile('^requested today\.$')
|
|
|
|
req_yesterday = re.compile('^requested yesterday\.$')
|
|
|
|
in_prep_today = re.compile('^in preparation since today\.$')
|
2009-11-03 15:02:44 +01:00
|
|
|
in_prep_yesterday = re.compile('^in preparation since yesterday\.$')
|
2009-10-27 17:02:56 +01:00
|
|
|
|
2009-10-29 12:56:06 +01:00
|
|
|
for line in url:
|
2009-12-09 13:18:48 +01:00
|
|
|
if line_match.match(line):
|
|
|
|
if line_match_desc.match(line):
|
2009-10-28 15:51:41 +01:00
|
|
|
line = line.strip()
|
|
|
|
|
2009-12-09 13:18:48 +01:00
|
|
|
link = line.replace('<ul>', '')
|
2009-10-29 10:34:47 +01:00
|
|
|
link = line[13:42]
|
2009-10-27 13:27:32 +01:00
|
|
|
item.append(link)
|
|
|
|
|
2009-12-09 13:18:48 +01:00
|
|
|
name = line.replace('<ul>', '')
|
2009-10-27 13:27:32 +01:00
|
|
|
name = name[44:]
|
|
|
|
name = name.split(':', 1)[0]
|
|
|
|
item.append(name)
|
|
|
|
|
2009-10-27 21:30:50 +01:00
|
|
|
if options.description:
|
2009-10-28 14:22:58 +01:00
|
|
|
try:
|
2009-12-09 13:18:48 +01:00
|
|
|
description = line.replace('</a>,', '')
|
2009-10-29 10:34:47 +01:00
|
|
|
description = ' (' + description.split(':')[2].strip() + ')'
|
2009-10-28 14:22:58 +01:00
|
|
|
except:
|
|
|
|
description = ''
|
2009-10-27 21:30:50 +01:00
|
|
|
item.append(description)
|
|
|
|
else:
|
|
|
|
item.append('')
|
|
|
|
|
2009-12-09 13:18:48 +01:00
|
|
|
if line_match_age.match(line):
|
2009-10-27 16:39:44 +01:00
|
|
|
if options.itp:
|
2009-12-09 13:18:48 +01:00
|
|
|
if in_prep_yesterday.match(line): days = '1'
|
2010-10-27 10:48:59 +02:00
|
|
|
elif in_prep_today.match(line): days = '0'
|
2010-10-29 10:40:22 +02:00
|
|
|
else: days = line.split(' ')[0]
|
2009-10-27 21:30:50 +01:00
|
|
|
else:
|
2010-10-27 10:48:59 +02:00
|
|
|
if req_yesterday.match(line): days = '1'
|
|
|
|
elif req_today.match(line): days = '0'
|
|
|
|
else: days = line.split(' ')[1]
|
2009-10-27 13:27:32 +01:00
|
|
|
item.append(days)
|
|
|
|
|
2009-10-27 21:30:50 +01:00
|
|
|
if len(item) == 4:
|
2009-10-27 13:27:32 +01:00
|
|
|
reports.append(item)
|
|
|
|
item = []
|
|
|
|
|
2009-10-30 16:56:38 +01:00
|
|
|
reports.sort(key = lambda x: int(x[3]))
|
2009-10-27 13:27:32 +01:00
|
|
|
for entry in reports:
|
2009-10-27 21:30:50 +01:00
|
|
|
if int(entry[3]) <= options.max_days_old \
|
|
|
|
and int(entry[3]) >= options.min_days_old:
|
2010-03-10 15:33:58 +01:00
|
|
|
entry[2] = re.sub('&', '&', entry[2])
|
|
|
|
entry[2] = re.sub('"', '"', entry[2])
|
|
|
|
entry[2] = re.sub(''', '\'', entry[2])
|
2009-10-29 10:34:47 +01:00
|
|
|
print entry[3], 'days ago:', entry[1], entry[0], entry[2]
|
2010-03-10 15:33:58 +01:00
|
|
|
|
2010-10-27 10:48:59 +02:00
|
|
|
# vim: set tw=0 ts=4:
|