-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenum_complex_values.py
More file actions
38 lines (32 loc) · 1.04 KB
/
enum_complex_values.py
File metadata and controls
38 lines (32 loc) · 1.04 KB
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
import enum
class BugStatus(enum.Enum):
new = {
"num": 7,
"transitions": [
"incomplete",
"invalid",
"wont_fix",
"in_progress",
],
}
incomplete = {"num": 6, "transitions": ["new", "wont_fix"]}
invalid = {"num": 5, "transitions": ["new"]}
wont_fix = {"num": 4, "transitions": ["new"]}
in_progress = {
"num": 3,
"transitions": [
"new",
"fix_committed",
],
}
fix_committed = {"num": 2, "transitions": ["in_progress", "fix_released"]}
fix_released = {"num": 1, "transitions": ["new"]}
def __init__(self, vals):
self.num = vals["num"]
self.transitions = vals["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))