ソースを参照

fix: use Babel to translate the dates

tags/v0.10.10
Jérôme Deuchnord 3年前
committed by Jérôme Deuchnord
コミット
9268113106
14個のファイルの変更128行の追加157行の削除
  1. +1
    -2
      Dockerfile
  2. +1
    -1
      Makefile
  3. +1
    -1
      Pipfile
  4. +16
    -16
      Pipfile.lock
  5. +36
    -69
      _kosmorro/dumper.py
  6. +3
    -2
      _kosmorro/exceptions.py
  7. +36
    -36
      _kosmorro/locales/messages.pot
  8. +5
    -4
      _kosmorro/main.py
  9. +1
    -0
      setup.py
  10. +4
    -4
      tests/dates.py
  11. +3
    -1
      tests/general.py
  12. +13
    -13
      tests/position.py
  13. +6
    -6
      tests/timezone.py
  14. +2
    -2
      tests/utils.py

+ 1
- 2
Dockerfile ファイルの表示

@@ -18,7 +18,6 @@ COPY _kosmorro/ _kosmorro/
COPY kosmorro . COPY kosmorro .


# Compile the translations # Compile the translations
RUN pip install Babel
COPY setup.py setup.py COPY setup.py setup.py
COPY setup.cfg setup.cfg COPY setup.cfg setup.cfg
COPY README.md README.md COPY README.md README.md
@@ -27,7 +26,7 @@ RUN python setup.py compile_catalog
# Clean the image # Clean the image
RUN rm setup.py setup.cfg README.md && \ RUN rm setup.py setup.cfg README.md && \
rm _kosmorro/locales/messages.pot _kosmorro/locales/*/LC_MESSAGES/messages.po && \ rm _kosmorro/locales/messages.pot _kosmorro/locales/*/LC_MESSAGES/messages.po && \
pip uninstall --yes Babel pipenv
pip uninstall --yes pipenv


USER kosmorro USER kosmorro




+ 1
- 1
Makefile ファイルの表示

@@ -8,7 +8,7 @@ tests:
echo; \ echo; \
fi fi


pipenv run python3 -m pytest tests/*.py
LANG=C pipenv run python3 -m pytest tests/*.py


.PHONY: build .PHONY: build
build: manpage build: manpage


+ 1
- 1
Pipfile ファイルの表示

@@ -4,7 +4,6 @@ url = "https://pypi.org/simple"
verify_ssl = true verify_ssl = true


[dev-packages] [dev-packages]
babel = "*"
black = "*" black = "*"
pytest = "*" pytest = "*"
aurornis = "*" aurornis = "*"
@@ -14,6 +13,7 @@ tabulate = "*"
termcolor = "*" termcolor = "*"
kosmorrolib = ">=1.0.0,<2.0.0" kosmorrolib = ">=1.0.0,<2.0.0"
python-dateutil = "*" python-dateutil = "*"
babel = ">=2.9.0,<3.0.0"


[requires] [requires]
python_version = "3" python_version = "3"


+ 16
- 16
Pipfile.lock ファイルの表示

@@ -1,7 +1,7 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "3ff7290b32da63ca9585dbe947830ae1d1e4692f0ca9a0faeaa3601d7f9c4b8b"
"sha256": "7c87215e821ad4c88dadc31960030f52957e2eaa41d451bfa3a53feb91b8d856"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": { "requires": {
@@ -16,6 +16,14 @@
] ]
}, },
"default": { "default": {
"babel": {
"hashes": [
"sha256:ab49e12b91d937cd11f0b67cb259a57ab4ad2b59ac7a3b41d6c06c0ac5b0def9",
"sha256:bc0c176f9f6a994582230df350aa6e05ba2ebe4b3ac317eab29d9be5d2768da0"
],
"index": "pypi",
"version": "==2.9.1"
},
"certifi": { "certifi": {
"hashes": [ "hashes": [
"sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872", "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872",
@@ -69,6 +77,13 @@
"index": "pypi", "index": "pypi",
"version": "==2.8.2" "version": "==2.8.2"
}, },
"pytz": {
"hashes": [
"sha256:3672058bc3453457b622aab7a1c3bfd5ab0bdae451512f6cf25f64ed37f5b87c",
"sha256:acad2d8b20a1af07d4e4c9d2e9285c5ed9104354062f275f3fcd88dcef4f1326"
],
"version": "==2021.3"
},
"sgp4": { "sgp4": {
"hashes": [ "hashes": [
"sha256:05f22b4fd91861ee2e0e03a528c1aef11a8b263a60ab5f723d32cdb65dac3eaa", "sha256:05f22b4fd91861ee2e0e03a528c1aef11a8b263a60ab5f723d32cdb65dac3eaa",
@@ -155,14 +170,6 @@
"index": "pypi", "index": "pypi",
"version": "==1.2.0" "version": "==1.2.0"
}, },
"babel": {
"hashes": [
"sha256:ab49e12b91d937cd11f0b67cb259a57ab4ad2b59ac7a3b41d6c06c0ac5b0def9",
"sha256:bc0c176f9f6a994582230df350aa6e05ba2ebe4b3ac317eab29d9be5d2768da0"
],
"index": "pypi",
"version": "==2.9.1"
},
"black": { "black": {
"hashes": [ "hashes": [
"sha256:07e5c049442d7ca1a2fc273c79d1aecbbf1bc858f62e8184abe1ad175c4f7cc2", "sha256:07e5c049442d7ca1a2fc273c79d1aecbbf1bc858f62e8184abe1ad175c4f7cc2",
@@ -263,13 +270,6 @@
"index": "pypi", "index": "pypi",
"version": "==7.0.1" "version": "==7.0.1"
}, },
"pytz": {
"hashes": [
"sha256:3672058bc3453457b622aab7a1c3bfd5ab0bdae451512f6cf25f64ed37f5b87c",
"sha256:acad2d8b20a1af07d4e4c9d2e9285c5ed9104354062f275f3fcd88dcef4f1326"
],
"version": "==2021.3"
},
"tomli": { "tomli": {
"hashes": [ "hashes": [
"sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc",


+ 36
- 69
_kosmorro/dumper.py ファイルの表示

@@ -25,7 +25,7 @@ import subprocess
import shutil import shutil
from pathlib import Path from pathlib import Path


import kosmorrolib
from babel.dates import format_date, format_time
from tabulate import tabulate from tabulate import tabulate
from termcolor import colored from termcolor import colored


@@ -70,7 +70,7 @@ class Dumper(ABC):
self.show_graph = show_graph self.show_graph = show_graph


def get_date_as_string(self, capitalized: bool = False) -> str: def get_date_as_string(self, capitalized: bool = False) -> str:
date = self.date.strftime(FULL_DATE_FORMAT)
date = format_date(self.date, "full")


if capitalized: if capitalized:
return "".join([date[0].upper(), date[1:]]) return "".join([date[0].upper(), date[1:]])
@@ -181,35 +181,21 @@ class TextDumper(Dumper):


name = self.style(object_name, "th") name = self.style(object_name, "th")


if ephemeris.rise_time is not None:
time_fmt = (
TIME_FORMAT
if ephemeris.rise_time.day == self.date.day
else SHORT_DATETIME_FORMAT
)
planet_rise = ephemeris.rise_time.strftime(time_fmt)
else:
planet_rise = "-"

if ephemeris.culmination_time is not None:
time_fmt = (
TIME_FORMAT
if ephemeris.culmination_time.day == self.date.day
else SHORT_DATETIME_FORMAT
)
planet_culmination = ephemeris.culmination_time.strftime(time_fmt)
else:
planet_culmination = "-"

if ephemeris.set_time is not None:
time_fmt = (
TIME_FORMAT
if ephemeris.set_time.day == self.date.day
else SHORT_DATETIME_FORMAT
)
planet_set = ephemeris.set_time.strftime(time_fmt)
else:
planet_set = "-"
planet_rise = (
"-"
if ephemeris.rise_time is None
else format_time(ephemeris.rise_time, "short")
)
planet_culmination = (
"-"
if ephemeris.culmination_time is None
else format_time(ephemeris.culmination_time, "short")
)
planet_set = (
"-"
if ephemeris.set_time is None
else format_time(ephemeris.set_time, "short")
)


data.append([name, planet_rise, planet_culmination, planet_set]) data.append([name, planet_rise, planet_culmination, planet_set])


@@ -234,14 +220,9 @@ class TextDumper(Dumper):
if description is None: if description is None:
continue continue


time_fmt = (
TIME_FORMAT
if event.start_time.day == self.date.day
else SHORT_DATETIME_FORMAT
)
data.append( data.append(
[ [
self.style(event.start_time.strftime(time_fmt), "th"),
self.style(format_time(event.start_time, "short"), "th"),
description, description,
] ]
) )
@@ -262,8 +243,8 @@ class TextDumper(Dumper):
"{next_moon_phase} on {next_moon_phase_date} at {next_moon_phase_time}" "{next_moon_phase} on {next_moon_phase_date} at {next_moon_phase_time}"
).format( ).format(
next_moon_phase=_(strings.from_moon_phase(moon_phase.get_next_phase())), next_moon_phase=_(strings.from_moon_phase(moon_phase.get_next_phase())),
next_moon_phase_date=moon_phase.next_phase_date.strftime(FULL_DATE_FORMAT),
next_moon_phase_time=moon_phase.next_phase_date.strftime(TIME_FORMAT),
next_moon_phase_date=format_date(moon_phase.next_phase_date, "full"),
next_moon_phase_time=format_time(moon_phase.next_phase_date, "short"),
) )


return "\n".join([current_moon_phase, new_moon_phase]) return "\n".join([current_moon_phase, new_moon_phase])
@@ -384,35 +365,21 @@ class _LatexDumper(Dumper):


if self.ephemerides is not None: if self.ephemerides is not None:
for ephemeris in self.ephemerides: for ephemeris in self.ephemerides:
if ephemeris.rise_time is not None:
time_fmt = (
TIME_FORMAT
if ephemeris.rise_time.day == self.date.day
else SHORT_DATETIME_FORMAT
)
aster_rise = ephemeris.rise_time.strftime(time_fmt)
else:
aster_rise = "-"

if ephemeris.culmination_time is not None:
time_fmt = (
TIME_FORMAT
if ephemeris.culmination_time.day == self.date.day
else SHORT_DATETIME_FORMAT
)
aster_culmination = ephemeris.culmination_time.strftime(time_fmt)
else:
aster_culmination = "-"

if ephemeris.set_time is not None:
time_fmt = (
TIME_FORMAT
if ephemeris.set_time.day == self.date.day
else SHORT_DATETIME_FORMAT
)
aster_set = ephemeris.set_time.strftime(time_fmt)
else:
aster_set = "-"
aster_rise = (
"-"
if ephemeris.rise_time is None
else format_time(ephemeris.rise_time, "short")
)
aster_culmination = (
"-"
if ephemeris.culmination_time is None
else format_time(ephemeris.culmination_time, "short")
)
aster_set = (
"-"
if ephemeris.set_time is None
else format_time(ephemeris.set_time, "short")
)


if not self.show_graph: if not self.show_graph:
object_name = strings.from_object(ephemeris.object.identifier) object_name = strings.from_object(ephemeris.object.identifier)
@@ -476,7 +443,7 @@ class _LatexDumper(Dumper):
continue continue


latex.append( latex.append(
r"\event{%s}{%s}" % (event.start_time.strftime(TIME_FORMAT), event_name)
r"\event{%s}{%s}" % (format_time(event.start_time, "short"), event_name)
) )


return "".join(latex) return "".join(latex)


+ 3
- 2
_kosmorro/exceptions.py ファイルの表示

@@ -17,6 +17,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.


from datetime import date from datetime import date
from babel.dates import format_date
from _kosmorro.i18n.utils import _, SHORT_DATE_FORMAT from _kosmorro.i18n.utils import _, SHORT_DATE_FORMAT




@@ -34,8 +35,8 @@ class OutOfRangeDateError(RuntimeError):
self.msg = _( self.msg = _(
"The date must be between {minimum_date} and {maximum_date}" "The date must be between {minimum_date} and {maximum_date}"
).format( ).format(
minimum_date=min_date.strftime(SHORT_DATE_FORMAT),
maximum_date=max_date.strftime(SHORT_DATE_FORMAT),
minimum_date=format_date(min_date, "long"),
maximum_date=format_date(max_date, "long"),
) )






+ 36
- 36
_kosmorro/locales/messages.pot ファイルの表示

@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PROJECT VERSION\n" "Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2022-02-16 13:58+0100\n"
"POT-Creation-Date: 2022-03-07 16:45+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -39,64 +39,64 @@ msgstr ""
msgid "Note: All the hours are given in the UTC{offset} timezone." msgid "Note: All the hours are given in the UTC{offset} timezone."
msgstr "" msgstr ""


#: _kosmorro/dumper.py:219 _kosmorro/dumper.py:352
#: _kosmorro/dumper.py:205 _kosmorro/dumper.py:333
msgid "Object" msgid "Object"
msgstr "" msgstr ""


#: _kosmorro/dumper.py:220 _kosmorro/dumper.py:353
#: _kosmorro/dumper.py:206 _kosmorro/dumper.py:334
msgid "Rise time" msgid "Rise time"
msgstr "" msgstr ""


#: _kosmorro/dumper.py:221 _kosmorro/dumper.py:355
#: _kosmorro/dumper.py:207 _kosmorro/dumper.py:336
msgid "Culmination time" msgid "Culmination time"
msgstr "" msgstr ""


#: _kosmorro/dumper.py:222 _kosmorro/dumper.py:357
#: _kosmorro/dumper.py:208 _kosmorro/dumper.py:338
msgid "Set time" msgid "Set time"
msgstr "" msgstr ""


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


#: _kosmorro/dumper.py:257 _kosmorro/dumper.py:361
#: _kosmorro/dumper.py:238 _kosmorro/dumper.py:342
msgid "Moon phase:" msgid "Moon phase:"
msgstr "" msgstr ""


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


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


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


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


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


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


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


#: _kosmorro/dumper.py:520
#: _kosmorro/dumper.py:487
msgid "" msgid ""
"Building PDF was not possible, because some dependencies are not " "Building PDF was not possible, because some dependencies are not "
"installed.\n" "installed.\n"
@@ -104,7 +104,7 @@ msgid ""
"pdf/ for more information." "pdf/ for more information."
msgstr "" msgstr ""


#: _kosmorro/dumper.py:573
#: _kosmorro/dumper.py:540
#, python-format #, python-format
msgid "" msgid ""
"An error occurred during the compilation of the PDF.\n" "An error occurred during the compilation of the PDF.\n"
@@ -112,102 +112,102 @@ msgid ""
"share the content of the log file at /tmp/kosmorro-%s.log" "share the content of the log file at /tmp/kosmorro-%s.log"
msgstr "" msgstr ""


#: _kosmorro/exceptions.py:34
#: _kosmorro/exceptions.py:35
msgid "The date must be between {minimum_date} and {maximum_date}" msgid "The date must be between {minimum_date} and {maximum_date}"
msgstr "" msgstr ""


#: _kosmorro/main.py:62
#: _kosmorro/main.py:63
msgid "" msgid ""
"Save the planet and paper!\n" "Save the planet and paper!\n"
"Consider printing your PDF document only if really necessary, and use the" "Consider printing your PDF document only if really necessary, and use the"
" other side of the sheet." " other side of the sheet."
msgstr "" msgstr ""


#: _kosmorro/main.py:71
#: _kosmorro/main.py:72
msgid "" msgid ""
"PDF output will not contain the ephemerides, because you didn't provide " "PDF output will not contain the ephemerides, because you didn't provide "
"the observation coordinates." "the observation coordinates."
msgstr "" msgstr ""


#: _kosmorro/main.py:116
#: _kosmorro/main.py:117
msgid "The file could not be saved in \"{path}\": {error}" msgid "The file could not be saved in \"{path}\": {error}"
msgstr "" msgstr ""


#: _kosmorro/main.py:130
#: _kosmorro/main.py:131
msgid "Please provide a file path to export in this format (--output)." msgid "Please provide a file path to export in this format (--output)."
msgstr "" msgstr ""


#: _kosmorro/main.py:163
msgid "Moon phase can only be displayed between {min_date} and {max_date}"
#: _kosmorro/main.py:164
msgid "Moon phase can only be computed between {min_date} and {max_date}"
msgstr "" msgstr ""


#: _kosmorro/main.py:202
#: _kosmorro/main.py:203
msgid "Running on Python {python_version} with Kosmorrolib v{kosmorrolib_version}" msgid "Running on Python {python_version} with Kosmorrolib v{kosmorrolib_version}"
msgstr "" msgstr ""


#: _kosmorro/main.py:215
#: _kosmorro/main.py:216
msgid "" msgid ""
"Compute the ephemerides and the events for a given date and a given " "Compute the ephemerides and the events for a given date and a given "
"position on Earth." "position on Earth."
msgstr "" msgstr ""


#: _kosmorro/main.py:218
#: _kosmorro/main.py:219
msgid "" msgid ""
"By default, only the events will be computed for today.\n" "By default, only the events will be computed for today.\n"
"To compute also the ephemerides, latitude and longitude arguments are " "To compute also the ephemerides, latitude and longitude arguments are "
"needed." "needed."
msgstr "" msgstr ""


#: _kosmorro/main.py:231
#: _kosmorro/main.py:232
msgid "Show the program version" msgid "Show the program version"
msgstr "" msgstr ""


#: _kosmorro/main.py:239
#: _kosmorro/main.py:240
msgid "The format to output the information to" msgid "The format to output the information to"
msgstr "" msgstr ""


#: _kosmorro/main.py:246
#: _kosmorro/main.py:247
msgid "" msgid ""
"The observer's latitude on Earth. Can also be set in the " "The observer's latitude on Earth. Can also be set in the "
"KOSMORRO_LATITUDE environment variable." "KOSMORRO_LATITUDE environment variable."
msgstr "" msgstr ""


#: _kosmorro/main.py:256
#: _kosmorro/main.py:257
msgid "" msgid ""
"The observer's longitude on Earth. Can also be set in the " "The observer's longitude on Earth. Can also be set in the "
"KOSMORRO_LONGITUDE environment variable." "KOSMORRO_LONGITUDE environment variable."
msgstr "" msgstr ""


#: _kosmorro/main.py:266
#: _kosmorro/main.py:267
msgid "" msgid ""
"The date for which the ephemerides must be calculated. Can be in the " "The date for which the ephemerides must be calculated. Can be in the "
"YYYY-MM-DD format or an interval in the \"[+-]YyMmDd\" format (with Y, M," "YYYY-MM-DD format or an interval in the \"[+-]YyMmDd\" format (with Y, M,"
" and D numbers). Defaults to current date." " and D numbers). Defaults to current date."
msgstr "" msgstr ""


#: _kosmorro/main.py:277
#: _kosmorro/main.py:278
msgid "" msgid ""
"The timezone to display the hours in (e.g. 2 for UTC+2 or -3 for UTC-3). " "The timezone to display the hours in (e.g. 2 for UTC+2 or -3 for UTC-3). "
"Can also be set in the KOSMORRO_TIMEZONE environment variable." "Can also be set in the KOSMORRO_TIMEZONE environment variable."
msgstr "" msgstr ""


#: _kosmorro/main.py:286
#: _kosmorro/main.py:287
msgid "Disable the colors in the console." msgid "Disable the colors in the console."
msgstr "" msgstr ""


#: _kosmorro/main.py:293
#: _kosmorro/main.py:294
msgid "" msgid ""
"A file to export the output to. If not given, the standard output is " "A file to export the output to. If not given, the standard output is "
"used. This argument is needed for PDF format." "used. This argument is needed for PDF format."
msgstr "" msgstr ""


#: _kosmorro/main.py:302
#: _kosmorro/main.py:303
msgid "" msgid ""
"Do not generate a graph to represent the rise and set times in the PDF " "Do not generate a graph to represent the rise and set times in the PDF "
"format." "format."
msgstr "" msgstr ""


#: _kosmorro/main.py:310
#: _kosmorro/main.py:311
msgid "Show debugging messages" msgid "Show debugging messages"
msgstr "" msgstr ""




+ 5
- 4
_kosmorro/main.py ファイルの表示

@@ -19,6 +19,7 @@
import argparse import argparse
import sys import sys


from babel.dates import format_date
from kosmorrolib import Position, get_ephemerides, get_events, get_moon_phase from kosmorrolib import Position, get_ephemerides, get_events, get_moon_phase
from kosmorrolib.__version__ import __version__ as kosmorrolib_version from kosmorrolib.__version__ import __version__ as kosmorrolib_version
from kosmorrolib.exceptions import OutOfRangeDateError from kosmorrolib.exceptions import OutOfRangeDateError
@@ -161,10 +162,10 @@ def get_information(
print( print(
colored( colored(
_( _(
"Moon phase can only be displayed between {min_date} and {max_date}"
"Moon phase can only be computed between {min_date} and {max_date}"
).format( ).format(
min_date=error.min_date.strftime(SHORT_DATE_FORMAT),
max_date=error.max_date.strftime(SHORT_DATE_FORMAT),
min_date=format_date(error.min_date, "long"),
max_date=format_date(error.max_date, "long"),
), ),
"yellow", "yellow",
) )
@@ -218,7 +219,7 @@ def get_args(output_formats: [str]):
epilog=_( epilog=_(
"By default, only the events will be computed for today.\n" "By default, only the events will be computed for today.\n"
"To compute also the ephemerides, latitude and longitude arguments are needed." "To compute also the ephemerides, latitude and longitude arguments are needed."
).format(date=today.strftime(dumper.FULL_DATE_FORMAT)),
),
) )


parser.add_argument( parser.add_argument(


+ 1
- 0
setup.py ファイルの表示

@@ -47,6 +47,7 @@ setup(
"tabulate", "tabulate",
"termcolor", "termcolor",
"python-dateutil", "python-dateutil",
"babel",
], ],
classifiers=[ classifiers=[
"Development Status :: 3 - Alpha", "Development Status :: 3 - Alpha",


+ 4
- 4
tests/dates.py ファイルの表示

@@ -10,13 +10,13 @@ def test_with_date():


assert ( assert (
result.stdout result.stdout
== """Monday January 27, 2020
== """Monday, January 27, 2020


Moon phase: New Moon Moon phase: New Moon
First Quarter on Sunday February 02, 2020 at 01:41
First Quarter on Sunday, February 2, 2020 at 1:41 AM


Expected events: Expected events:
20:00 Venus and Neptune are in conjunction
8:00 PM Venus and Neptune are in conjunction


Note: All the hours are given in UTC. Note: All the hours are given in UTC.
""" """
@@ -48,5 +48,5 @@ def test_with_out_of_range_dates():
assert not result.is_successful() assert not result.is_successful()
assert ( assert (
result.stdout result.stdout
== "Moon phase can only be displayed between Aug 09, 1899 and Sep 26, 2053\n"
== "Moon phase can only be computed between August 9, 1899 and September 26, 2053\n"
) )

+ 3
- 1
tests/general.py ファイルの表示

@@ -8,6 +8,7 @@ from .utils import (
NEXT_MOON_PHASE_PATTERN, NEXT_MOON_PHASE_PATTERN,
) )
from datetime import date from datetime import date
from babel.dates import format_date




def test_run_without_argument(): def test_run_without_argument():
@@ -15,9 +16,10 @@ def test_run_without_argument():
assert result.is_successful() assert result.is_successful()


stdout = result.stdout.split("\n") stdout = result.stdout.split("\n")
print(stdout)


# It always starts with the current date, an empty line and the current and next Moon date: # It always starts with the current date, an empty line and the current and next Moon date:
assert stdout[0] == date.today().strftime("%A %B %d, %Y")
assert stdout[0] == format_date(date.today(), "full")
assert stdout[1] == "" assert stdout[1] == ""
assert CURRENT_MOON_PHASE_PATTERN.match(stdout[2]) assert CURRENT_MOON_PHASE_PATTERN.match(stdout[2])
assert NEXT_MOON_PHASE_PATTERN.match(stdout[3]) assert NEXT_MOON_PHASE_PATTERN.match(stdout[3])


+ 13
- 13
tests/position.py ファイルの表示

@@ -10,26 +10,26 @@ def check_command_return(result):
assert result.is_successful() assert result.is_successful()
assert ( assert (
result.stdout result.stdout
== """Monday January 27, 2020
== """Monday, January 27, 2020


Object Rise time Culmination time Set time Object Rise time Culmination time Set time
-------- ----------- ------------------ ---------- -------- ----------- ------------------ ----------
Sun 07:31 12:01 16:30
Moon 09:06 14:09 19:13
Mercury 08:10 12:49 17:28
Venus 09:01 14:35 20:10
Mars 04:19 08:23 12:28
Jupiter 06:15 10:18 14:21
Saturn 06:56 11:09 15:22
Uranus 10:21 17:25 00:33
Neptune 09:01 14:36 20:10
Pluto 06:57 11:04 15:11
Sun 7:31 AM 12:01 PM 4:30 PM
Moon 9:06 AM 2:09 PM 7:13 PM
Mercury 8:10 AM 12:49 PM 5:28 PM
Venus 9:01 AM 2:35 PM 8:10 PM
Mars 4:19 AM 8:23 AM 12:28 PM
Jupiter 6:15 AM 10:18 AM 2:21 PM
Saturn 6:56 AM 11:09 AM 3:22 PM
Uranus 10:21 AM 5:25 PM 12:33 AM
Neptune 9:01 AM 2:36 PM 8:10 PM
Pluto 6:57 AM 11:04 AM 3:11 PM


Moon phase: New Moon Moon phase: New Moon
First Quarter on Sunday February 02, 2020 at 01:41
First Quarter on Sunday, February 2, 2020 at 1:41 AM


Expected events: Expected events:
20:00 Venus and Neptune are in conjunction
8:00 PM Venus and Neptune are in conjunction


Note: All the hours are given in UTC. Note: All the hours are given in UTC.
""" """


+ 6
- 6
tests/timezone.py ファイルの表示

@@ -10,13 +10,13 @@ def check_command_return_t_plus_one(result):
assert result.is_successful() assert result.is_successful()
assert ( assert (
result.stdout result.stdout
== """Monday January 27, 2020
== """Monday, January 27, 2020


Moon phase: New Moon Moon phase: New Moon
First Quarter on Sunday February 02, 2020 at 02:41
First Quarter on Sunday, February 2, 2020 at 2:41 AM


Expected events: Expected events:
21:00 Venus and Neptune are in conjunction
9:00 PM Venus and Neptune are in conjunction


Note: All the hours are given in the UTC+1 timezone. Note: All the hours are given in the UTC+1 timezone.
""" """
@@ -27,13 +27,13 @@ def check_command_return_t_minus_one(result):
assert result.is_successful() assert result.is_successful()
assert ( assert (
result.stdout result.stdout
== """Monday January 27, 2020
== """Monday, January 27, 2020


Moon phase: New Moon Moon phase: New Moon
First Quarter on Sunday February 02, 2020 at 00:41
First Quarter on Sunday, February 2, 2020 at 12:41 AM


Expected events: Expected events:
19:00 Venus and Neptune are in conjunction
7:00 PM Venus and Neptune are in conjunction


Note: All the hours are given in the UTC-1 timezone. Note: All the hours are given in the UTC-1 timezone.
""" """


+ 2
- 2
tests/utils.py ファイルの表示

@@ -24,10 +24,10 @@ NEXT_MOON_PHASE_PATTERN = re.compile(
r"(Full Moon)|(Waning Gibbous)|" r"(Full Moon)|(Waning Gibbous)|"
r"(Last Quarter)|(Waning Crescent)" r"(Last Quarter)|(Waning Crescent)"
r") " r") "
r"on ((Monday)|(Tuesday)|(Wednesday)|(Thursday)|(Friday)|(Saturday)|(Sunday)) "
r"on ((Monday)|(Tuesday)|(Wednesday)|(Thursday)|(Friday)|(Saturday)|(Sunday)), "
r"((January)|(February)|(March)|(April)|(May)|(June)|" r"((January)|(February)|(March)|(April)|(May)|(June)|"
r"(July)|(August)|(September)|(October)|(November)|(December)) " r"(July)|(August)|(September)|(October)|(November)|(December)) "
r"[0-9]{2}, [0-9]{4} at [0-9]{2}:[0-9]{2}$"
r"[0-9]{1,2}, [0-9]{4} at [0-9]{2}:[0-9]{2} [AP]M$"
) )






読み込み中…
キャンセル
保存