|
|
@@ -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 |
|
|
|
|
|
|
|