diff options
author | Stefan Ritter <xeno@thehappy.de> | 2009-10-27 16:39:44 +0100 |
---|---|---|
committer | Stefan Ritter <xeno@thehappy.de> | 2009-10-27 16:39:44 +0100 |
commit | b527c7554963282859602d9b9f0828ea3a50f4fd (patch) | |
tree | 3d7cd95bce5253a5984ed94796b9c4a39ef8a585 | |
parent | 5731cd1f12df5e8e75f117201a5e76e3e664b036 (diff) |
Added ITP functionality
* Renamed to wnpp-query
* Removed some more regexp
-rwxr-xr-x | wnpp-query.py (renamed from rfpquery.py) | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/rfpquery.py b/wnpp-query.py index 0f3ef95..7839fe3 100755 --- a/rfpquery.py +++ b/wnpp-query.py @@ -7,38 +7,41 @@ # http://sam.zoy.org/wtfpl/COPYING for more details. # Author: Stefan Ritter <xeno@thehappy.de> -# Description: Query Debian WNPP Page (RFP) +# Description: Query Debian WNPP pages import urllib2, sys, re from optparse import OptionParser # Parse commandline arguments parser = OptionParser() -parser.add_option('--min', dest='min_days_old', type="int", help='Minimum age of reports (in days)') -parser.add_option('--max', dest='max_days_old', type="int", help='Maximum age of reports (in days)') +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)') (options, args) = parser.parse_args() -if not options.min_days_old and not options.max_days_old: - parser.error('You have to give at least one of --min or --max') +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.') sys.exit if not options.min_days_old: options.min_days_old = 0 if not options.max_days_old: options.max_days_old = 9999 # Here we go... -print 'Output reports that are older then', options.min_days_old, 'days and younger then', options.max_days_old, 'days:\n' - reports = [] item = [] -rfpurl = urllib2.urlopen('http://www.debian.org/devel/wnpp/requested') +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') -for line in rfpurl: - if re.findall('bugs\.debian\.org', line) or re.match('requested(.*)ago', line): +for line in url: + if re.findall('bugs\.debian\.org', line) or re.match('requested(.*)ago', line) or re.match('(.*)days in preparation', line): # First line if re.match('^.ul.(.*),', line) or re.match ('^(.*)li.(.*),', line): # Link link = re.sub('<ul>', '', line).strip() # First line starts with <ul> - link = re.sub('<li><a href="', '', link)[:29] + link = line[14:43] item.append(link) # Name @@ -48,9 +51,11 @@ for line in rfpurl: item.append(name) # Second line - if re.match('^requested(.*)', line): - days = line[10:].strip() # Remove leading 'requests ' - days = re.sub(' days ago.', '', days) + if re.match('^requested(.*)', line) or re.match('^(.*)days in preparation', line): + if options.itp: + days = line.split(' ')[0] + else: + days = line.split(' ')[1] item.append(days) if len(item) == 3: @@ -59,4 +64,4 @@ for line in rfpurl: for entry in reports: if int(entry[2]) <= options.max_days_old and int(entry[2]) >= options.min_days_old: - print entry[1] + ': ' + entry[2] + ' days old (' + entry[0] + ')' + print entry[1] + ': ' + entry[2] + ' days ago (' + entry[0] + ')' |