MCPcopy Index your code
hub / github.com/RustPython/RustPython / __get_builtin_constructor

Function __get_builtin_constructor

Lib/hashlib.py:82–123  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

80}
81
82def __get_builtin_constructor(name):
83 cache = __builtin_constructor_cache
84 constructor = cache.get(name)
85 if constructor is not None:
86 return constructor
87 try:
88 if name in {'SHA1', 'sha1'}:
89 import _sha1
90 cache['SHA1'] = cache['sha1'] = _sha1.sha1
91 elif name in {'MD5', 'md5'}:
92 import _md5
93 cache['MD5'] = cache['md5'] = _md5.md5
94 elif name in {'SHA256', 'sha256', 'SHA224', 'sha224'}:
95 import _sha2
96 cache['SHA224'] = cache['sha224'] = _sha2.sha224
97 cache['SHA256'] = cache['sha256'] = _sha2.sha256
98 elif name in {'SHA512', 'sha512', 'SHA384', 'sha384'}:
99 import _sha2
100 cache['SHA384'] = cache['sha384'] = _sha2.sha384
101 cache['SHA512'] = cache['sha512'] = _sha2.sha512
102 elif name in {'blake2b', 'blake2s'}:
103 import _blake2
104 cache['blake2b'] = _blake2.blake2b
105 cache['blake2s'] = _blake2.blake2s
106 elif name in {'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512'}:
107 import _sha3
108 cache['sha3_224'] = _sha3.sha3_224
109 cache['sha3_256'] = _sha3.sha3_256
110 cache['sha3_384'] = _sha3.sha3_384
111 cache['sha3_512'] = _sha3.sha3_512
112 elif name in {'shake_128', 'shake_256'}:
113 import _sha3
114 cache['shake_128'] = _sha3.shake_128
115 cache['shake_256'] = _sha3.shake_256
116 except ImportError:
117 pass # no extension module, this hash is unsupported.
118
119 constructor = cache.get(name)
120 if constructor is not None:
121 return constructor
122
123 raise ValueError('unsupported hash type ' + name)
124
125
126def __get_openssl_constructor(name):

Callers 3

__py_newFunction · 0.85
__hash_newFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected