so_magic.utils.singleton   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A Singleton.__call__() 0 6 2
1
2
__all__ = ['Singleton']
3
4
5
class Singleton(type):
6
    _instances = {}
7
8
    def __call__(cls, *args, **kwargs):
9
        instance = cls._instances.get(cls)
10
        if not instance:
11
            instance = super(Singleton, cls).__call__(*args, **kwargs)
12
            cls._instances[cls] = instance
13
        return instance
14