Skip to content
This repository was archived by the owner on Apr 19, 2024. It is now read-only.

Commit 9a688ee

Browse files
committed
allow underscores and hyphens in hash function names in Multihash
1 parent 337b741 commit 9a688ee

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

multihash.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ class Func(Enum):
2828
blake2b = 0x40
2929
blake2s = 0x41
3030

31-
_func_from_name = {f.name.replace('_', '-'): f for f in Func}
31+
# Allows lookup by `Func` member name or CSV table name.
32+
_func_from_name = dict(Func.__members__)
33+
_func_from_name.update({f.name.replace('_', '-'): f for f in Func})
3234

3335

3436
class Multihash(namedtuple('Multihash', 'func length digest')):
@@ -43,7 +45,7 @@ class Multihash(namedtuple('Multihash', 'func length digest')):
4345
True
4446
4547
Although it can also be its integer value (the function code) or its
46-
string name (the function name):
48+
string name (the function name, with either underscore or hyphen):
4749
4850
>>> mhfc = Multihash(Func.sha1.value, mh.length, mh.digest)
4951
>>> mhfc == mh

0 commit comments

Comments
 (0)