IncrementedNamedInt.get_for_name()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
1
class IncrementedNamedInt:
2
    _last_int = 0
3
    _names = {}
4
5
    @classmethod
6
    def get(cls, name):
7
        cls._last_int += 1
8
        cls._names[cls._last_int] = name
9
        return cls._last_int
10
11
    @classmethod
12
    def name_of(cls, int):
13
        return cls._names[int]
14
15
    @classmethod
16
    def get_for_name(cls, name):
17
        for int in cls._names:
18
            if cls._names[int] == name:
19
                return int
20
        raise Exception("Named int not found")