a little simplification and minor TODO-ing

This commit is contained in:
brent s 2018-05-08 12:46:52 -04:00
parent e18ebb24fb
commit ba53a8d162

View File

@ -239,13 +239,26 @@ class CertParse(object):
l = [y for y in i.split(':', 1) if y not in ('', None)] l = [y for y in i.split(':', 1) if y not in ('', None)]
if len(l) > 1: if len(l) > 1:
# It MAY be a key:value. # It MAY be a key:value.
if re.search('^\s+', l[1]) and last_key != 'User Notice': if re.search('^\s+', l[1]):
# It's a value. val = l[1].strip()
last_key = l[0].strip() if last_key == 'Policy':
exts['certificatePolicies'][last_key] = l[1].strip() if not isinstance(exts['certificatePolicies']\
elif re.search('^\s+', l[1]): [last_key],
k = l[0].strip() list):
exts['certificatePolicies'][last_key][k] = l[1].strip() exts['certificatePolicies'][last_key] = [
exts['certificatePolicies'][last_key]]
exts['certificatePolicies'][last_key].append(val)
# I can't seem to get CPS as a separate dict.
# Patches welcome.
# Also, are CPS and User Notice *subitems* of Policy
# items?
elif last_key not in ('User Notice', 'CPS'):
# It's a value.
last_key = l[0].strip()
exts['certificatePolicies'][last_key] = val
else:
k = l[0].strip()
exts['certificatePolicies'][last_key][k] = val
else: else:
# Standalone key line # Standalone key line
last_key = l[0].strip() last_key = l[0].strip()