This repository was archived by the owner on Apr 19, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -178,22 +178,23 @@ class Codecs:
178
178
def reset (cls ):
179
179
"""Reset the registry to the standard codecs."""
180
180
# Try to import codecs mentioned in the hashlib spec.
181
- import binascii as ba
182
- import base64 as b64
183
- try :
184
- import base58 as b58
185
- except ImportError :
186
- b58 = None
181
+ import binascii
182
+ import base64
187
183
188
184
c = cls ._codec
189
185
cls ._codecs = {
190
- 'hex' : c (ba .b2a_hex , ba .a2b_hex ),
191
- 'base32' : c (b64 .b32encode , b64 .b32decode ),
192
- 'base64' : c (b64 .b64encode , b64 .b64decode )
186
+ 'hex' : c (binascii .b2a_hex , binascii .a2b_hex ),
187
+ 'base32' : c (base64 .b32encode , base64 .b32decode ),
188
+ 'base64' : c (base64 .b64encode , base64 .b64decode )
193
189
}
194
- if b58 :
190
+
191
+ # The spec doesn't have compulsory codes, though.
192
+ try :
193
+ import base58
195
194
cls ._codecs ['base58' ] = c (
196
- lambda s : bytes (b58 .b58encode (s )), b58 .b58decode )
195
+ lambda s : bytes (base58 .b58encode (s )), base58 .b58decode )
196
+ except ImportError :
197
+ pass
197
198
198
199
@classmethod
199
200
def get_encoder (cls , encoding ):
You can’t perform that action at this time.
0 commit comments