Completed
Push — master ( 0c702e...f32b73 )
by P.R.
01:15
created

WhitespaceCleaner   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A clean() 0 14 2
1
class WhitespaceCleaner:
2
    """
3
    Utility class for cleaning whitespace from strings.
4
    """
5
6
    # ------------------------------------------------------------------------------------------------------------------
7
    @staticmethod
8
    def clean(string):
9
        """
10
        Prunes whitespace from a string.
11
12
        :param str string: The string.
13
14
        :rtype str:
15
        """
16
        # Return empty input immediately.
17
        if not string:
18
            return string
19
20
        return string.replace('  ', ' ').strip()
21
22
# ----------------------------------------------------------------------------------------------------------------------
23