def _make_regex(pem_type):
 return re.compile('\\s*(?P<pem_header>-----BEGIN {0}-----)\\s+(?:(?P<proc_type>Proc-Type: 4,ENCRYPTED)\\s*)?(?:(?P<dek_info>DEK-Info: (?:DES-[3A-Z\\-]+,[0-9A-F]{{16}}|[0-9A-Z\\-]+,[0-9A-F]{{32}}))\\s*)?(?P<pem_body>.+?)\\s+(?P<pem_footer>-----END {1}-----)\\s*'.format(pem_type, pem_type), re.DOTALL)

def _make_regex ( pem_type ) : return re . compile ( '\\s*(?P<pem_header>-----BEGIN {0}-----)\\s+(?:(?P<proc_type>Proc-Type: 4,ENCRYPTED)\\s*)?(?:(?P<dek_info>DEK-Info: (?:DES-[3A-Z\\-]+,[0-9A-F]{{16}}|[0-9A-Z\\-]+,[0-9A-F]{{32}}))\\s*)?(?P<pem_body>.+?)\\s+(?P<pem_footer>-----END {1}-----)\\s*' . format ( pem_type , pem_type ) , re . DOTALL )
dynamically generate a regex to match pem_type .