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
2.1 KiB

  1. #!/usr/bin/env python3
  2. from .utils import _
  3. from kosmorrolib import EventType, MoonPhaseType, ObjectIdentifier, Event
  4. def from_event(event: Event) -> str:
  5. return {
  6. EventType.OPPOSITION: _("%s is in opposition")
  7. % (from_object(event.objects[0].identifier)),
  8. EventType.CONJUNCTION: _("%s and %s are in conjunction")
  9. % (
  10. from_object(event.objects[0].identifier),
  11. from_object(event.objects[1].identifier),
  12. ),
  13. EventType.OCCULTATION: _("%s occults %s")
  14. % (
  15. from_object(event.objects[0].identifier),
  16. from_object(event.objects[1].identifier),
  17. ),
  18. EventType.MAXIMAL_ELONGATION: _("%s's largest elongation")
  19. % (from_object(event.objects[0].identifier)),
  20. EventType.MOON_PERIGEE: _("%s is at its perigee")
  21. % (from_object(event.objects[0].identifier)),
  22. EventType.MOON_APOGEE: _("%s is at its apogee")
  23. % (from_object(event.objects[0].identifier)),
  24. }.get(event.event_type)
  25. def from_moon_phase(moon_phase: MoonPhaseType) -> str:
  26. return {
  27. MoonPhaseType.NEW_MOON: _("New Moon"),
  28. MoonPhaseType.WAXING_CRESCENT: _("Waxing Crescent"),
  29. MoonPhaseType.FIRST_QUARTER: _("First Quarter"),
  30. MoonPhaseType.WAXING_GIBBOUS: _("Waxing Gibbous"),
  31. MoonPhaseType.FULL_MOON: _("Full Moon"),
  32. MoonPhaseType.WANING_GIBBOUS: _("Waning Gibbous"),
  33. MoonPhaseType.LAST_QUARTER: _("Last Quarter"),
  34. MoonPhaseType.WANING_CRESCENT: _("Waning Crescent"),
  35. }.get(moon_phase, _("Unknown phase"))
  36. def from_object(identifier: ObjectIdentifier) -> str:
  37. return {
  38. ObjectIdentifier.SUN: _("Sun"),
  39. ObjectIdentifier.MOON: _("Moon"),
  40. ObjectIdentifier.MERCURY: _("Mercury"),
  41. ObjectIdentifier.VENUS: _("Venus"),
  42. ObjectIdentifier.MARS: _("Mars"),
  43. ObjectIdentifier.JUPITER: _("Jupiter"),
  44. ObjectIdentifier.SATURN: _("Saturn"),
  45. ObjectIdentifier.URANUS: _("Uranus"),
  46. ObjectIdentifier.NEPTUNE: _("Neptune"),
  47. ObjectIdentifier.PLUTO: _("Pluto"),
  48. }.get(identifier, _("Unknown object"))