A corporation manager and dashboard for EVE Online
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

56 lignes
1.4 KiB

  1. # -*- coding: utf-8 -*-
  2. import platform
  3. import requests
  4. from .clock import Clock
  5. from .esi import EVESwaggerInterface
  6. from .image import ImageServer
  7. from .sso import SSOManager
  8. from .. import __release__
  9. __all__ = ["EVE"]
  10. class EVE:
  11. """Interface to EVE's various APIs."""
  12. def __init__(self, config):
  13. session = requests.Session()
  14. agent = self._get_user_agent(config.get("site.contact"))
  15. session.headers["User-Agent"] = agent
  16. self._clock = Clock()
  17. self._esi = EVESwaggerInterface(session)
  18. self._image = ImageServer()
  19. self._sso = SSOManager(session)
  20. @staticmethod
  21. def _get_user_agent(contact):
  22. """Return the user agent when accessing APIs."""
  23. template = ("Calefaction/{} ({}; Python/{}; {}; "
  24. "https://github.com/earwig/calefaction)")
  25. return template.format(
  26. __release__, requests.utils.default_user_agent(),
  27. platform.python_version(), contact)
  28. @property
  29. def clock(self):
  30. """The Clock API module."""
  31. return self._clock
  32. @property
  33. def esi(self):
  34. """The EVE Swagger Interface API module."""
  35. return self._esi
  36. @property
  37. def image(self):
  38. """The ImageServer API module."""
  39. return self._image
  40. @property
  41. def sso(self):
  42. """The Single Sign-On API module."""
  43. return self._sso