Browse Source

fix(events): ignore unsupported event types

tags/v0.10.10
Jérôme Deuchnord 2 years ago
committed by Jérôme Deuchnord
parent
commit
9bfa8f503d
2 changed files with 38 additions and 21 deletions
  1. +19
    -2
      _kosmorro/dumper.py
  2. +19
    -19
      _kosmorro/locales/messages.pot

+ 19
- 2
_kosmorro/dumper.py View File

@@ -25,10 +25,11 @@ import subprocess
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
@@ -89,6 +90,15 @@ class Dumper(ABC):


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(
{
@@ -96,11 +106,18 @@ class JsonDumper(Dumper):
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):


+ 19
- 19
_kosmorro/locales/messages.pot View File

@@ -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"
@@ -27,76 +27,76 @@ 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"
@@ -104,7 +104,7 @@ msgid ""
"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"


Loading…
Cancel
Save