content_hash.decodes   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 29
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A get_decode() 0 19 2
1
"""Known decoding."""
2
3
import importlib
4
5
6
CACHE = {}
7
"""dict: a cache of known decoding"""
8
9
10
def get_decode(name):
11
    """
12
    Get decoding function by name.
13
14
    Decoding should be a function that takes
15
    a `bytes` input and returns a `str` result.
16
17
    :param str name: a decode name
18
19
    :return: the resulting decode
20
    :rtype: callable
21
    """
22
23
    decode = CACHE.get(name)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable CACHE does not seem to be defined.
Loading history...
24
25
    if not decode:
26
        decode = CACHE[name] = importlib.import_module(f".{name}", __name__).decode
27
28
    return decode
29