forked from Roilek/logistique-agepoly-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccred.py
68 lines (54 loc) · 1.74 KB
/
accred.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from enum import Enum
class Accred(Enum):
"""Accreditation status of a user."""
NONE = -1
EXTERNAL = 0
INTERNAL = 1
TEAM_MEMBER = 2
TEAM_LEADER = 3
ADMIN = 4
def __str__(self) -> str:
if self == Accred.NONE:
return ""
info = {
Accred.EXTERNAL: "Externe",
Accred.INTERNAL: "Equipe ou CdD",
Accred.TEAM_MEMBER: "Equipe Logistique",
Accred.TEAM_LEADER: "Responsable Logistique",
Accred.ADMIN: "Admin"
}
return info[self]
def __repr__(self) -> str:
return str(self)
def __int__(self) -> int:
return self.value
def __eq__(self, other: object) -> bool:
if isinstance(other, Accred):
return self.value == other.value
return False
def __ne__(self, other: object) -> bool:
if isinstance(other, Accred):
return self.value != other.value
return True
def __lt__(self, other: object) -> bool:
if isinstance(other, Accred):
return self.value < other.value
return False
def __le__(self, other: object) -> bool:
if isinstance(other, Accred):
return self.value <= other.value
return False
def __gt__(self, other: object) -> bool:
if isinstance(other, Accred):
return self.value > other.value
return False
def __ge__(self, other: object) -> bool:
if isinstance(other, Accred):
return self.value >= other.value
return False
def __hash__(self) -> int:
return hash(self.value)
@classmethod
def from_value(cls, value: int) -> "Accred":
"""Return the Accred enum from a value."""
return cls(value)