Passed
Branch master (17b603)
by P.R.
01:31
created

etlt.cleaner.WhitespaceCleaner   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 30
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A WhitespaceCleaner.clean() 0 14 2
1
"""
2
ETLT
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
9
10
class WhitespaceCleaner:
11
    """
12
    Utility class for cleaning whitespace from strings.
13
    """
14
15
    # ------------------------------------------------------------------------------------------------------------------
16
    @staticmethod
17
    def clean(string):
18
        """
19
        Prunes whitespace from a string.
20
21
        :param str string: The string.
22
23
        :rtype: str
24
        """
25
        # Return empty input immediately.
26
        if not string:
27
            return string
28
29
        return string.replace('  ', ' ').strip()
30
31
# ----------------------------------------------------------------------------------------------------------------------
32