attachers.py 608 B

12345678910111213141516171819202122232425262728293031
  1. def with_help(help_msg):
  2. def getter(self):
  3. return help_msg
  4. def decorator(cls):
  5. setattr(cls, "help_msg", getter)
  6. return cls
  7. return decorator
  8. def with_startup(startup):
  9. def new_startup(self, db):
  10. return startup(self, db)
  11. def decorator(cls):
  12. setattr(cls, "on_start", new_startup)
  13. return cls
  14. return decorator
  15. def with_shutdown(shutdown):
  16. def new_shutdown(self, db):
  17. return shutdown(self, db)
  18. def decorator(cls):
  19. setattr(cls, "on_shutdown", new_shutdown)
  20. return cls
  21. return decorator