Skip to content

Instantly share code, notes, and snippets.

@h0rn3t
Created February 12, 2021 06:55
Show Gist options
  • Save h0rn3t/8d649d6ae84f13532902568872e86c10 to your computer and use it in GitHub Desktop.
Save h0rn3t/8d649d6ae84f13532902568872e86c10 to your computer and use it in GitHub Desktop.
enum
class States(Enum):
# each Value have priority. Need when getting random event we know its more priority then last or not.
# y = YealinkStates.ANSWER_IN_CALL
# y = YealinkStates('ANSWER_NEW_IN_CALL')
# y.name -> 'ANSWER_IN_CALL'
# str(y) -> 'ANSWER_NEW_IN_CALL'
# y.priority -> 3
# y.title -> 'ANSWER_NEW_IN_CALL'
INCOMING_CALL = (1, 'INCOMING_CALL')
OUTGOING_CALL = (2, 'OUTGOING_CALL')
ANSWER_IN_CALL = (3, 'ANSWER_NEW_IN_CALL')
ESTABLISHED = (4, 'ESTABLISHED')
HOLD = (5, 'HOLD')
UNHOLD = (6, 'UNHOLD')
HELD = (7, 'HELD')
UNHELD = (8, 'UNHELD')
MUTE = (9, 'MUTE')
UNMUTE = (10, 'UNMUTE')
TERMINATED = (11, 'NORMAL_CLEARING')
REJECT_INCOMING = (12, 'REJECT_INCOMING_CALL')
CANCEL_OUTGOING = (13, 'CANCEL_CALL_OUT')
REMOTE_BUSY = (14, 'REMOTE_BUSY')
REMOTE_CANCELED = (15, 'CALL_REMOTE_CANCELED')
MISSED_CALL = (16, 'MISSED_CALL')
def __init__(self, priority, title):
self.priority = priority
self.title = title
def __str__(self):
return self.title
def __repr__(self):
return '<%s.%s>' % (self.__class__.__name__, self.title)
def __new__(cls, int_value, *value_aliases):
obj = object.__new__(cls)
obj._value_ = int_value
for alias in value_aliases:
cls._value2member_map_[alias] = obj
return obj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment