-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenum_tuple_values.py
More file actions
44 lines (38 loc) · 969 Bytes
/
enum_tuple_values.py
File metadata and controls
44 lines (38 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import enum
class BugStatus(enum.Enum):
new = (
7,
[
"incomplete",
"invalid",
"wont_fix",
"in_progress",
],
)
incomplete = (
6,
[
"new",
"wont_fix",
],
)
invalid = (5, ["new"])
wont_fix = (4, ["new"])
in_progress = (
3,
[
"new",
"fix_committed",
],
)
fix_committed = (2, ["in_progress", "fix_released"])
fix_released = (1, ["new"])
def __init__(self, num, transitions):
self.num = num
self.transitions = transitions
def can_transition(self, new_state):
return new_state.name in self.transitions
print("Name: ", BugStatus.in_progress)
print("Value: ", BugStatus.in_progress.value)
print("Custom attribute: ", BugStatus.in_progress.transitions)
print("Using attribute: ", BugStatus.in_progress.can_transition(BugStatus.new))