Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: NoneType error on JSON output without position (#199)
  • Loading branch information
Deuchnord committed Aug 26, 2021
1 parent cbc5f6a commit 6988e77
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .scripts/tests-e2e.sh
Expand Up @@ -98,6 +98,8 @@ assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-0
assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=json"
assertFailure "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf"

assertSuccess "$KOSMORRO_COMMAND -d 2020-01-27 --format=json"

# Environment variables
assertSuccess "LATITUDE=50.5876 LONGITUDE=3.0624 TIMEZONE=1 kosmorro -d 2020-01-27"
assertSuccess "LATITUDE=50.5876 LONGITUDE=3.0624 TIMEZONE=-1 kosmorro -d 2020-01-27"
Expand Down
24 changes: 16 additions & 8 deletions _kosmorro/dumper.py
Expand Up @@ -43,15 +43,23 @@


class Dumper(ABC):
ephemerides: [AsterEphemerides]
moon_phase: MoonPhase
events: [Event]
date: datetime.date
timezone: int
with_colors: bool
show_graph: bool

def __init__(
self,
ephemerides: [AsterEphemerides] = None,
moon_phase: MoonPhase = None,
events: [Event] = None,
date: datetime.date = datetime.date.today(),
timezone: int = 0,
with_colors: bool = True,
show_graph: bool = False,
ephemerides: [AsterEphemerides],
moon_phase: MoonPhase,
events: [Event],
date: datetime.date,
timezone: int,
with_colors: bool,
show_graph: bool,
):
self.ephemerides = ephemerides
self.moon_phase = moon_phase
Expand Down Expand Up @@ -99,7 +107,7 @@ class TextDumper(Dumper):
def to_string(self):
text = [self.style(self.get_date_as_string(capitalized=True), "h1")]

if self.ephemerides is not None:
if len(self.ephemerides) > 0:
text.append(self.stringify_ephemerides())

text.append(self.get_moon(self.moon_phase))
Expand Down
38 changes: 19 additions & 19 deletions _kosmorro/locales/messages.pot
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: kosmorro 0.10.1\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-07-19 12:19+0200\n"
"POT-Creation-Date: 2021-08-26 11:37+0000\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:111
#: _kosmorro/dumper.py:119
msgid "Expected events:"
msgstr ""

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

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

#: _kosmorro/dumper.py:193 _kosmorro/dumper.py:323
#: _kosmorro/dumper.py:201 _kosmorro/dumper.py:331
msgid "Object"
msgstr ""

#: _kosmorro/dumper.py:194 _kosmorro/dumper.py:324
#: _kosmorro/dumper.py:202 _kosmorro/dumper.py:332
msgid "Rise time"
msgstr ""

#: _kosmorro/dumper.py:195 _kosmorro/dumper.py:326
#: _kosmorro/dumper.py:203 _kosmorro/dumper.py:334
msgid "Culmination time"
msgstr ""

#: _kosmorro/dumper.py:196 _kosmorro/dumper.py:328
#: _kosmorro/dumper.py:204 _kosmorro/dumper.py:336
msgid "Set time"
msgstr ""

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

#: _kosmorro/dumper.py:228 _kosmorro/dumper.py:332
#: _kosmorro/dumper.py:236 _kosmorro/dumper.py:340
msgid "Moon phase:"
msgstr ""

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

#: _kosmorro/dumper.py:296
#: _kosmorro/dumper.py:304
msgid "Overview of your sky"
msgstr ""

#: _kosmorro/dumper.py:304
#: _kosmorro/dumper.py:312
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:314
#: _kosmorro/dumper.py:322
msgid ""
"Don't forget to check the weather forecast before you go out with your "
"equipment."
msgstr ""

#: _kosmorro/dumper.py:321
#: _kosmorro/dumper.py:329
msgid "Ephemerides of the day"
msgstr ""

#: _kosmorro/dumper.py:330
#: _kosmorro/dumper.py:338
msgid "hours"
msgstr ""

#: _kosmorro/dumper.py:337
#: _kosmorro/dumper.py:345
msgid "Expected events"
msgstr ""

#: _kosmorro/dumper.py:491
#: _kosmorro/dumper.py:499
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:544
#: _kosmorro/dumper.py:552
#, python-format
msgid ""
"An error occurred during the compilation of the PDF.\n"
Expand Down
2 changes: 1 addition & 1 deletion _kosmorro/main.py
Expand Up @@ -152,7 +152,7 @@ def get_information(
except OutOfRangeDateError as error:
raise DateRangeError(error.min_date, error.max_date)
else:
eph = None
eph = []

try:
moon_phase = get_moon_phase(compute_date)
Expand Down
Empty file removed test/events.py
Empty file.

0 comments on commit 6988e77

Please sign in to comment.