def load_pem(contents, pem_marker):
 (pem_start, pem_end) = _markers(pem_marker)
 pem_lines = []
 in_pem_part = False
 for line in contents.splitlines():
  line = line.strip()
  if (not line):
   continue
  if (line == pem_start):
   if in_pem_part:
    raise ValueError(('Seen start marker "%s" twice' % pem_start))
   in_pem_part = True
   continue
  if (not in_pem_part):
   continue
  if (in_pem_part and (line == pem_end)):
   in_pem_part = False
   break
  if (b(':') in line):
   continue
  pem_lines.append(line)
 if (not pem_lines):
  raise ValueError(('No PEM start marker "%s" found' % pem_start))
 if in_pem_part:
  raise ValueError(('No PEM end marker "%s" found' % pem_end))
 pem = b('').join(pem_lines)
 return base64.decodestring(pem)

def load_pem ( contents , pem_marker ) : ( pem_start , pem_end ) = _markers ( pem_marker ) pem_lines = [ ] in_pem_part = False for line in contents . splitlines ( ) : line = line . strip ( ) if ( not line ) : continue if ( line == pem_start ) : if in_pem_part : raise ValueError ( ( 'Seen start marker "%s" twice' % pem_start ) ) in_pem_part = True continue if ( not in_pem_part ) : continue if ( in_pem_part and ( line == pem_end ) ) : in_pem_part = False break if ( b ( ':' ) in line ) : continue pem_lines . append ( line ) if ( not pem_lines ) : raise ValueError ( ( 'No PEM start marker "%s" found' % pem_start ) ) if in_pem_part : raise ValueError ( ( 'No PEM end marker "%s" found' % pem_end ) ) pem = b ( '' ) . join ( pem_lines ) return base64 . decodestring ( pem )
loads a pem file .