Quellcode durchsuchen

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 vor 2 Jahren
committed by Jérôme Deuchnord
Ursprung
Commit
e82af8f4b9
1 geänderte Dateien mit 5 neuen und 11 gelöschten Zeilen
  1. +5
    -11
      _kosmorro/i18n/strings.py

+ 5
- 11
_kosmorro/i18n/strings.py Datei anzeigen

@@ -1,26 +1,20 @@
#!/usr/bin/env python3 #!/usr/bin/env python3


from typing import Union
from .utils import _ from .utils import _


from kosmorrolib import EventType, MoonPhaseType, ObjectIdentifier, Event 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 = { string, details = {
EventType.OPPOSITION: (_("%s is in opposition"), None), EventType.OPPOSITION: (_("%s is in opposition"), None),
EventType.CONJUNCTION: (_("%s and %s are in conjunction"), None), EventType.CONJUNCTION: (_("%s and %s are in conjunction"), None),
EventType.OCCULTATION: (_("%s occults %s"), 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.PERIGEE: (_("%s is at its perigee"), None),
EventType.APOGEE: (_("%s is at its apogee"), None), EventType.APOGEE: (_("%s is at its apogee"), None),
}.get(event.event_type)
}.get(event.event_type, (None, None))


if string is None: if string is None:
return 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]) string = string % tuple([from_object(o.identifier) for o in event.objects])


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


return string return string




Laden…
Abbrechen
Speichern