From a7c1e457173aae3113c61a86f3b4c407ba2ec798 Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Thu, 29 Oct 2009 12:56:06 +0100 Subject: Precompile regular expressions --- wnpp-query.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/wnpp-query.py b/wnpp-query.py index 13b7a85..bb39b2d 100755 --- a/wnpp-query.py +++ b/wnpp-query.py @@ -34,16 +34,13 @@ else: url = urllib2.urlopen('http://www.debian.org/devel/wnpp/requeste reports = [] item = [] -for line in url: - - if re.match('^(.*)bugs\.debian\.org(.*)$', line) \ - or re.match('^requested(.*)$', line) \ - or re.match('^in preparation since(.*)$', line) \ - or re.match('^(.*)days in preparation\.$', line): - - if re.match('^\(.*),', line) \ - or re.match ('^ \\,', line): +line_match = re.compile('(^(.*)bugs\.debian\.org(.*)$|^requested(.*)$|^in preparation since(.*)$|^(.*)days in preparation\.$)') +line_match_desc = re.compile('(^\(.*),|^ \\,)') +line_match_age = re.compile('(^requested(.*)$|^(.*)days in preparation(.*)$|^in preparation since(.*)$)') +for line in url: + if re.match(line_match, line): + if re.match(line_match_desc, line): line = line.strip() link = re.sub('
    ', '', line) @@ -65,20 +62,15 @@ for line in url: else: item.append('') - if re.match('^requested(.*)$', line) \ - or re.match('^(.*)days in preparation(.*)$', line) \ - or re.match('^in preparation since(.*)$', line): - + if re.match(line_match_age, line): if options.itp: if re.match('^in preparation since yesterday\.$', line): days = '1' elif re.match('^in preparation since today\.$', line): days = '0' else: days = line.split(' ')[0] - else: if re.match('^requested yesterday\.$', line): days = '1' elif re.match('^requested today\.$', line): days = '0' else: days = line.split(' ')[1] - item.append(days) if len(item) == 4: -- cgit v1.2.3