locals.py 566 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. from typing import Optional
  4. class Enum:
  5. group: Optional[str] = None
  6. def __init__(self, label: str) -> None:
  7. self.label = label
  8. def __repr__(self) -> str:
  9. return f"<{self.group}: {self.label}>"
  10. def __str__(self) -> str:
  11. return self.label
  12. class StatusEnum(Enum):
  13. group = "Status"
  14. OFFLINE = Enum("Offline")
  15. ONLINE = Enum("Online")
  16. AWAY = Enum("Away")
  17. class OfflineError(Exception):
  18. """The requested action can't happen while offline."""