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.
 
 
 
 

45 lines
1.7 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. EventType.CONJUNCTION: _("%s and %s are in conjunction"),
  8. EventType.OCCULTATION: _("%s occults %s"),
  9. EventType.MAXIMAL_ELONGATION: _("Elongation of %s is maximal"),
  10. EventType.MOON_PERIGEE: _("%s is at its perigee"),
  11. EventType.MOON_APOGEE: _("%s is at its apogee"),
  12. }.get(event.event_type) % tuple([from_object(o.identifier) for o in event.objects])
  13. def from_moon_phase(moon_phase: MoonPhaseType) -> str:
  14. return {
  15. MoonPhaseType.NEW_MOON: _("New Moon"),
  16. MoonPhaseType.WAXING_CRESCENT: _("Waxing Crescent"),
  17. MoonPhaseType.FIRST_QUARTER: _("First Quarter"),
  18. MoonPhaseType.WAXING_GIBBOUS: _("Waxing Gibbous"),
  19. MoonPhaseType.FULL_MOON: _("Full Moon"),
  20. MoonPhaseType.WANING_GIBBOUS: _("Waning Gibbous"),
  21. MoonPhaseType.LAST_QUARTER: _("Last Quarter"),
  22. MoonPhaseType.WANING_CRESCENT: _("Waning Crescent"),
  23. }.get(moon_phase, _("Unknown phase"))
  24. def from_object(identifier: ObjectIdentifier) -> str:
  25. return {
  26. ObjectIdentifier.SUN: _("Sun"),
  27. ObjectIdentifier.MOON: _("Moon"),
  28. ObjectIdentifier.MERCURY: _("Mercury"),
  29. ObjectIdentifier.VENUS: _("Venus"),
  30. ObjectIdentifier.MARS: _("Mars"),
  31. ObjectIdentifier.JUPITER: _("Jupiter"),
  32. ObjectIdentifier.SATURN: _("Saturn"),
  33. ObjectIdentifier.URANUS: _("Uranus"),
  34. ObjectIdentifier.NEPTUNE: _("Neptune"),
  35. ObjectIdentifier.PLUTO: _("Pluto"),
  36. }.get(identifier, _("Unknown object"))