Skip to content


fix: fix a display issue on the events list when Kosmorrolib returns …
Browse files Browse the repository at this point in the history
…events not supported by the CLI
  • Loading branch information
Jérôme Deuchnord authored and Deuchnord committed Nov 9, 2021
1 parent be6bf53 commit e82af8f
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions _kosmorro/i18n/
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
#!/usr/bin/env python3

from typing import Union
from .utils import _

from kosmorrolib import EventType, MoonPhaseType, ObjectIdentifier, Event

def from_event(event: Event, with_description: bool = True) -> str:
def from_event(event: Event, with_description: bool = True) -> Union[None, str]:
string, details = {
EventType.OPPOSITION: (_("%s is in opposition"), None),
EventType.CONJUNCTION: (_("%s and %s are in conjunction"), None),
EventType.OCCULTATION: (_("%s occults %s"), None),
_("Elongation of %s is maximal"),
if type(event.details) is dict
else event.details
EventType.MAXIMAL_ELONGATION: (_("Elongation of %s is maximal"), lambda e: "{:.3n}°".format(e.details["deg"])),
EventType.PERIGEE: (_("%s is at its perigee"), None),
EventType.APOGEE: (_("%s is at its apogee"), None),
}.get(event.event_type, (None, None))

if string is None:
return None

string = string % tuple([from_object(o.identifier) for o in event.objects])

if details is not None and with_description:
return "%s (%s)" % (string, details)
return "%s (%s)" % (string, details())

return string

Expand Down

0 comments on commit e82af8f

Please sign in to comment.