Completed
Push — develop ( 91b426...20989d )
by Wu
11s
created

WeRoBotMetaClass   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
dl 0
loc 14
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 8 4
A __new__() 0 2 1
1
class WeRoBotMetaClass(type):
2
    TYPES = {}
3
4
    def __new__(mcs, name, bases, attrs):
5
        return type.__new__(mcs, name, bases, attrs)
6
7
    def __init__(cls, name, bases, attrs):
8
        if '__type__' in attrs:
9
            if isinstance(attrs['__type__'], list):
10
                for _type in attrs['__type__']:
11
                    cls.TYPES[_type] = cls
12
            else:
13
                cls.TYPES[attrs['__type__']] = cls
14
        type.__init__(cls, name, bases, attrs)
15