Browse Source

fix: fix a display issue on the events list when Kosmorrolib returns events not supported by the CLI

tags/v0.10.5
Jérôme Deuchnord 2 years ago
committed by Jérôme Deuchnord
parent
commit
e82af8f4b9
1 changed files with 5 additions and 11 deletions
  1. +5
    -11
      _kosmorro/i18n/strings.py

+ 5
- 11
_kosmorro/i18n/strings.py View File

@@ -1,26 +1,20 @@
#!/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),
EventType.MAXIMAL_ELONGATION: (
_("Elongation of %s is maximal"),
(
"{:.3n}°".format(event.details["deg"])
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)
}.get(event.event_type, (None, None))

if string is None:
return None
@@ -28,7 +22,7 @@ def from_event(event: Event, with_description: bool = True) -> str:
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



Loading…
Cancel
Save