Improve regexp performance

This commit is contained in:
Alexandre Dulaunoy 2015-02-01 13:04:27 +01:00
parent 65f283253e
commit 9ba1adc8f4

View file

@ -15,11 +15,14 @@ import OpenSSL
cert = None
certstring = ""
certtag = re.compile('^\s+Certificate\s*$')
certtagend = re.compile('^\S+')
for l in fileinput.input():
if re.match('^\s+Certificate\s*$', l):
if certtag.match(l):
cert = True
continue
elif re.match('^\S+', l):
elif certtagend.match(l):
cert = None
if (cert is True):