IncrementedNamedInt.get()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
dl 0
loc 5
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")