fastest.utils   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 10
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A to_camel_case() 0 13 1
A count_truthy() 0 17 3
1
def count_truthy(items):
2
    """
3
    Count non None values viz, but includes 0
4
    ----
5
    examples:
6
7
    1) count_truthy([1, 2, None, 'a']) -> 3
8
    2) count_truthy([1, 2, 0, 'a']) -> 4
9
    ----
10
    :param items: list
11
    :return: int
12
    """
13
    counter = 0
14
    for item in items:
15
        if item is not None:
16
            counter += 1
17
    return counter
18
19
20
def to_camel_case(snake_str):
21
    """
22
    Convert snake case to CamelCase
23
    -----
24
    examples:
25
26
    1) to_camel_case('snake_cased_string') -> 'SnakeCasedString'
27
    -----
28
    :param snake_str: str
29
    :return: str
30
    """
31
    components = snake_str.split('_')
32
    return components[0].title() + ''.join(x.title() for x in components[1:])
33