diff options
author | Stefan Ritter <xeno@thehappy.de> | 2009-10-29 12:56:06 +0100 |
---|---|---|
committer | Stefan Ritter <xeno@thehappy.de> | 2009-10-29 12:56:06 +0100 |
commit | a7c1e457173aae3113c61a86f3b4c407ba2ec798 (patch) | |
tree | 315128f90e91685122fa423e7e5f48498ac3db1c | |
parent | f503783ea5d944578d1fda18cbbcd6c139d655b1 (diff) |
Precompile regular expressions
-rwxr-xr-x | wnpp-query.py | 22 |
1 files 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('^\<ul\>(.*),', line) \ - or re.match ('^ \<li\>\<a href(.*)\</a\>,', line): +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(.*)$)') +for line in url: + if re.match(line_match, line): + if re.match(line_match_desc, line): line = line.strip() link = re.sub('<ul>', '', 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: |