Passed
Push — master ( db2481...3bd527 )
by Fabio
03:28
created

benedict.core.invert   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A invert() 0 9 3
1
# -*- coding: utf-8 -*-
2
3
4
def invert(d, flat=False):
5
    new_dict = d.copy()
6
    new_dict.clear()
7
    for key, value in d.items():
8
        if flat:
9
            new_dict.setdefault(value, key)
10
        else:
11
            new_dict.setdefault(value, []).append(key)
12
    return new_dict
13