summaryrefslogtreecommitdiffstats
path: root/rfpquery.py
blob: 79ded945c581d81bf4cab3e19617949432755f19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python

import urllib2, sys, re

if len(sys.argv) < 2:
	print 'Syntax:', sys.argv[0], '[max_days_old]'
	sys.exit()

try:
	max_days_old = int(sys.argv[1])
except:
	print 'Not an integer!'
	sys.exit()


reports = []
item = []

rfpurl = 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):
		# First line
		if re.match('^.ul.(.*),', line) or re.match ('^(.*)li.(.*),', line):
			# Link
			link = re.sub('<ul>', '', line)
			link = re.sub('<li><a href="', '', link).strip()[:29]
			item.append(link)

			# Name
			name = re.sub('<ul>', '', line).strip()
			name = name[44:]
			name = name.split(':', 1)[0]
			item.append(name)

		# Second line
		if re.match('^requested(.*)', line):
			days = re.sub('requested ', '', line)
			days = re.sub(' days ago.', '', days).strip()
			item.append(days)

		if len(item) == 3:
			reports.append(item)
			item = []

for entry in reports:
	if int(entry[2]) <= max_days_old:
		print entry[1] + ': ' + entry[2] + ' days old (' + entry[0] + ')'