Precompile regular expressions
This commit is contained in:
parent
f503783ea5
commit
a7c1e45717
1 changed files with 7 additions and 15 deletions
|
@ -34,16 +34,13 @@ else: url = urllib2.urlopen('http://www.debian.org/devel/wnpp/requeste
|
|||
reports = []
|
||||
item = []
|
||||
|
||||
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('^(.*)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):
|
||||
|
||||
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:
|
||||
|
|
Loading…
Reference in a new issue