benedict.core.clean   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 15
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A clean() 0 5 3
A _clean_item() 0 9 2
1
from benedict.utils import type_util
2
3
4
def _clean_item(d, key, strings, collections):
5
    value = d.get(key, None)
6
    if not value:
7
        del_none = value is None
8
        del_string = strings and type_util.is_string(value)
9
        del_collection = collections and type_util.is_collection(value)
10
        return any([del_none, del_string, del_collection])
11
12
    return False
13
14
15
def clean(d, strings=True, collections=True):
16
    keys = list(d.keys())
17
    for key in keys:
18
        if _clean_item(d, key, strings, collections):
19
            del d[key]
20