Skip to content

Commit

Permalink
fix(events): ignore unsupported event types
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérôme Deuchnord authored and Deuchnord committed Feb 5, 2022
1 parent 2fd0d57 commit 9bfa8f5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 21 deletions.
21 changes: 19 additions & 2 deletions _kosmorro/dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
import shutil
from pathlib import Path

import kosmorrolib
from tabulate import tabulate
from termcolor import colored

from kosmorrolib import AsterEphemerides, Event
from kosmorrolib import AsterEphemerides, Event, EventType
from kosmorrolib.model import ASTERS, MoonPhase

from .i18n.utils import _, FULL_DATE_FORMAT, SHORT_DATETIME_FORMAT, TIME_FORMAT
Expand Down Expand Up @@ -89,18 +90,34 @@ def is_file_output_needed() -> bool:


class JsonDumper(Dumper):
SUPPORTED_EVENTS = [
EventType.OPPOSITION,
EventType.CONJUNCTION,
EventType.OCCULTATION,
EventType.MAXIMAL_ELONGATION,
EventType.PERIGEE,
EventType.APOGEE,
]

def to_string(self):
return json.dumps(
{
"ephemerides": [
ephemeris.serialize() for ephemeris in self.ephemerides
],
"moon_phase": self.moon_phase.serialize(),
"events": [event.serialize() for event in self.events],
"events": list(self.get_events()),
},
indent=4,
)

def get_events(self) -> [{str: any}]:
for event in self.events:
if event.event_type not in self.SUPPORTED_EVENTS:
continue

yield event.serialize()


class TextDumper(Dumper):
def to_string(self):
Expand Down
38 changes: 19 additions & 19 deletions _kosmorro/locales/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2022-01-12 13:59+0100\n"
"POT-Creation-Date: 2022-02-04 13:30+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -27,84 +27,84 @@ msgid ""
"offset format."
msgstr ""

#: _kosmorro/dumper.py:120
#: _kosmorro/dumper.py:137
msgid "Expected events:"
msgstr ""

#: _kosmorro/dumper.py:127
#: _kosmorro/dumper.py:144
msgid "Note: All the hours are given in UTC."
msgstr ""

#: _kosmorro/dumper.py:134
#: _kosmorro/dumper.py:151
msgid "Note: All the hours are given in the UTC{offset} timezone."
msgstr ""

#: _kosmorro/dumper.py:202 _kosmorro/dumper.py:335
#: _kosmorro/dumper.py:219 _kosmorro/dumper.py:352
msgid "Object"
msgstr ""

#: _kosmorro/dumper.py:203 _kosmorro/dumper.py:336
#: _kosmorro/dumper.py:220 _kosmorro/dumper.py:353
msgid "Rise time"
msgstr ""

#: _kosmorro/dumper.py:204 _kosmorro/dumper.py:338
#: _kosmorro/dumper.py:221 _kosmorro/dumper.py:355
msgid "Culmination time"
msgstr ""

#: _kosmorro/dumper.py:205 _kosmorro/dumper.py:340
#: _kosmorro/dumper.py:222 _kosmorro/dumper.py:357
msgid "Set time"
msgstr ""

#: _kosmorro/dumper.py:236
#: _kosmorro/dumper.py:253
msgid "Moon phase is unavailable for this date."
msgstr ""

#: _kosmorro/dumper.py:240 _kosmorro/dumper.py:344
#: _kosmorro/dumper.py:257 _kosmorro/dumper.py:361
msgid "Moon phase:"
msgstr ""

#: _kosmorro/dumper.py:244
#: _kosmorro/dumper.py:261
msgid "{next_moon_phase} on {next_moon_phase_date} at {next_moon_phase_time}"
msgstr ""

#: _kosmorro/dumper.py:308
#: _kosmorro/dumper.py:325
msgid "Overview of your sky"
msgstr ""

#: _kosmorro/dumper.py:316
#: _kosmorro/dumper.py:333
msgid ""
"This document summarizes the ephemerides and the events of {date}. It "
"aims to help you to prepare your observation session. All the hours are "
"given in {timezone}."
msgstr ""

#: _kosmorro/dumper.py:326
#: _kosmorro/dumper.py:343
msgid ""
"Don't forget to check the weather forecast before you go out with your "
"equipment."
msgstr ""

#: _kosmorro/dumper.py:333
#: _kosmorro/dumper.py:350
msgid "Ephemerides of the day"
msgstr ""

#: _kosmorro/dumper.py:342
#: _kosmorro/dumper.py:359
msgid "hours"
msgstr ""

#: _kosmorro/dumper.py:349
#: _kosmorro/dumper.py:366
msgid "Expected events"
msgstr ""

#: _kosmorro/dumper.py:503
#: _kosmorro/dumper.py:520
msgid ""
"Building PDF was not possible, because some dependencies are not "
"installed.\n"
"Please look at the documentation at https://kosmorro.space/cli/generate-"
"pdf/ for more information."
msgstr ""

#: _kosmorro/dumper.py:556
#: _kosmorro/dumper.py:573
#, python-format
msgid ""
"An error occurred during the compilation of the PDF.\n"
Expand Down

0 comments on commit 9bfa8f5

Please sign in to comment.