build.shared.singleton.Singleton.__call__()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nop 3
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
"""
2
    Metaclass do define singleton classes
3
    Taken from
4
    http://stackoverflow.com/questions/6760685/creating-a-singleton-in-python
5
"""
6
7
8 1
class Singleton(type):
9
    """
10
        Singleton Class
11
    """
12 1
    _instances = {}
13
14 1
    def __call__(cls, *args, **kwargs):
15 1
        if cls not in cls._instances:
16 1
            cls._instances[cls] = super(Singleton, cls).__call__(*args,
17
                                                                 **kwargs)
18
        return cls._instances[cls]
19