diff options
author | elie <elie> | 2012-04-12 20:43:13 +0000 |
---|---|---|
committer | elie <elie> | 2012-04-12 20:43:13 +0000 |
commit | 112d7881b9cdcbbaa42594a599637549fb336d20 (patch) | |
tree | dca64257a6b90425ba9913fc847cac9f1807e983 /pyasn1_modules | |
parent | 785070f09615ba1f879de0c626af4f969d1ba553 (diff) | |
download | pyasn1-modules-112d7881b9cdcbbaa42594a599637549fb336d20.tar.gz |
pem.readPemFromFile() re-worked to remain backward compatible
with earlier versions
Diffstat (limited to 'pyasn1_modules')
-rw-r--r-- | pyasn1_modules/pem.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/pyasn1_modules/pem.py b/pyasn1_modules/pem.py index abef3e7..d8d8158 100644 --- a/pyasn1_modules/pem.py +++ b/pyasn1_modules/pem.py @@ -4,7 +4,7 @@ stSpam, stHam, stDump = 0, 1, 2 # The markers parameters is in form ('start1', 'stop1'), ('start2', 'stop2')... # Return is (marker-index, substrate) -def readPemFromFile(fileObj, *markers): +def readPemBlocksFromFile(fileObj, *markers): startMarkers = dict(map(lambda x: (x[1],x[0]), enumerate(map(lambda x: x[0], markers)))) stopMarkers = dict(map(lambda x: (x[1],x[0]), @@ -35,6 +35,13 @@ def readPemFromFile(fileObj, *markers): break return idx, substrate +# Backward compatibility routine +def readPemFromFile(fileObj, + startMarker='-----BEGIN CERTIFICATE-----', + endMarker='-----END CERTIFICATE-----'): + idx, substrate = readPemBlocksFromFile(fileObj, (startMarker, endMarker)) + return substrate + def readBase64FromFile(fileObj): if sys.version_info[0] <= 2: return ''.join([ base64.b64decode(x) for x in fileObj.readlines() ]) |