A corporation manager and dashboard for EVE Online
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

57 lines
1.5 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__, baseLogger
  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. logger = baseLogger.getChild("eve")
  17. self._clock = Clock()
  18. self._esi = EVESwaggerInterface(session, logger.getChild("esi"))
  19. self._image = ImageServer()
  20. self._sso = SSOManager(session, logger.getChild("sso"))
  21. @staticmethod
  22. def _get_user_agent(contact):
  23. """Return the user agent when accessing APIs."""
  24. template = ("Calefaction/{} ({}; Python/{}; {}; "
  25. "https://github.com/earwig/calefaction)")
  26. return template.format(
  27. __release__, requests.utils.default_user_agent(),
  28. platform.python_version(), contact)
  29. @property
  30. def clock(self):
  31. """The Clock API module."""
  32. return self._clock
  33. @property
  34. def esi(self):
  35. """The EVE Swagger Interface API module."""
  36. return self._esi
  37. @property
  38. def image(self):
  39. """The ImageServer API module."""
  40. return self._image
  41. @property
  42. def sso(self):
  43. """The Single Sign-On API module."""
  44. return self._sso