Browse Source

Merge branch 'master' into features

pull/182/head
Jérôme Deuchnord 2 years ago
parent
commit
b8d0f782ca
9 changed files with 194 additions and 236 deletions
  1. +0
    -20
      .github/workflows/commitlint.yml
  2. +10
    -0
      CHANGELOG.md
  3. +37
    -39
      Pipfile.lock
  4. +3
    -64
      README.md
  5. +1
    -1
      _kosmorro/__version__.py
  6. +5
    -4
      _kosmorro/debug.py
  7. +71
    -48
      _kosmorro/dumper.py
  8. +27
    -12
      _kosmorro/i18n/strings.py
  9. +40
    -48
      _kosmorro/locales/messages.pot

+ 0
- 20
.github/workflows/commitlint.yml View File

@@ -1,20 +0,0 @@
name: Commit lint

on:
push:
branches: [master, features]
pull_request:
branches: [master, features]

jobs:
commitlint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v2
with:
helpURL: 'https://github.com/Kosmorro/kosmorro/blob/master/CONTRIBUTING.md#commiting'


+ 10
- 0
CHANGELOG.md View File

@@ -1,3 +1,13 @@
# [v0.10.1](https://github.com/Kosmorro/kosmorro/compare/v0.10.0...v0.10.1) (2021-06-20)


### Bug Fixes

* enhance forward compatibility with Kosmorrolib ([#189](https://github.com/Kosmorro/kosmorro/issues/189)) ([1fe90d2](https://github.com/Kosmorro/kosmorro/commit/1fe90d2603edbe68d7a119a0a7fb3649b55abe68))
* **PDF export:** fix the failure on PDF saving ([#186](https://github.com/Kosmorro/kosmorro/issues/186)) ([8d71b61](https://github.com/Kosmorro/kosmorro/commit/8d71b611e036c7cbb39683054dd6485c774076f7))



# [v0.10.0](https://github.com/Kosmorro/kosmorro/compare/v0.9.0...v0.10.0) (2021-05-30)




+ 37
- 39
Pipfile.lock View File

@@ -18,10 +18,10 @@
"default": {
"certifi": {
"hashes": [
"sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c",
"sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830"
"sha256:2bbf76fd432960138b3ef6dda3dde0544f27cbf8546c458e60baf371917ba9ee",
"sha256:50b1e4f8446b06f41be7dd6338db18e0990601dce795c2b1686458aa7e8fa7d8"
],
"version": "==2020.12.5"
"version": "==2021.5.30"
},
"jplephem": {
"hashes": [
@@ -39,33 +39,34 @@
},
"numpy": {
"hashes": [
"sha256:1676b0a292dd3c99e49305a16d7a9f42a4ab60ec522eac0d3dd20cdf362ac010",
"sha256:16f221035e8bd19b9dc9a57159e38d2dd060b48e93e1d843c49cb370b0f415fd",
"sha256:43909c8bb289c382170e0282158a38cf306a8ad2ff6dfadc447e90f9961bef43",
"sha256:4e465afc3b96dbc80cf4a5273e5e2b1e3451286361b4af70ce1adb2984d392f9",
"sha256:55b745fca0a5ab738647d0e4db099bd0a23279c32b31a783ad2ccea729e632df",
"sha256:5d050e1e4bc9ddb8656d7b4f414557720ddcca23a5b88dd7cff65e847864c400",
"sha256:637d827248f447e63585ca3f4a7d2dfaa882e094df6cfa177cc9cf9cd6cdf6d2",
"sha256:6690080810f77485667bfbff4f69d717c3be25e5b11bb2073e76bb3f578d99b4",
"sha256:66fbc6fed94a13b9801fb70b96ff30605ab0a123e775a5e7a26938b717c5d71a",
"sha256:67d44acb72c31a97a3d5d33d103ab06d8ac20770e1c5ad81bdb3f0c086a56cf6",
"sha256:6ca2b85a5997dabc38301a22ee43c82adcb53ff660b89ee88dded6b33687e1d8",
"sha256:6e51534e78d14b4a009a062641f465cfaba4fdcb046c3ac0b1f61dd97c861b1b",
"sha256:70eb5808127284c4e5c9e836208e09d685a7978b6a216db85960b1a112eeace8",
"sha256:830b044f4e64a76ba71448fce6e604c0fc47a0e54d8f6467be23749ac2cbd2fb",
"sha256:8b7bb4b9280da3b2856cb1fc425932f46fba609819ee1c62256f61799e6a51d2",
"sha256:a9c65473ebc342715cb2d7926ff1e202c26376c0dcaaee85a1fd4b8d8c1d3b2f",
"sha256:c1c09247ccea742525bdb5f4b5ceeacb34f95731647fe55774aa36557dbb5fa4",
"sha256:c5bf0e132acf7557fc9bb8ded8b53bbbbea8892f3c9a1738205878ca9434206a",
"sha256:db250fd3e90117e0312b611574cd1b3f78bec046783195075cbd7ba9c3d73f16",
"sha256:e515c9a93aebe27166ec9593411c58494fa98e5fcc219e47260d9ab8a1cc7f9f",
"sha256:e55185e51b18d788e49fe8305fd73ef4470596b33fc2c1ceb304566b99c71a69",
"sha256:ea9cff01e75a956dbee133fa8e5b68f2f92175233de2f88de3a682dd94deda65",
"sha256:f1452578d0516283c87608a5a5548b0cdde15b99650efdfd85182102ef7a7c17",
"sha256:f39a995e47cb8649673cfa0579fbdd1cdd33ea497d1728a6cb194d6252268e48"
],
"markers": "python_version >= '3.7'",
"version": "==1.20.3"
"sha256:068cfc78963ce8b9dd2dc7ad1f2d5ebebc47e10103ea0166074e6bd31e78aeb8",
"sha256:17f3ac57e19740f1c064c284ad361148be245fabbd6390bec3ffa814fb287fd6",
"sha256:19e076e4d9b66fd63477e907ed2a4c6662bbcd5a74b2cf50a9b0753afb4ee167",
"sha256:234fc98750ada00204ebf3acd94baea213c6f9f0ff6b097d06952f734f67e58a",
"sha256:305aff30d8976eccf14751a1095dac0e60e0c071f1fb82e6c53948fc5b6b346c",
"sha256:35180d82f457f0857963a486c16bd472582f217827c839dcb3a3de298b532f11",
"sha256:438129e0d1dd03d235ae25c45b5621888d699935cf5b813d08a0bb2e7221c9d4",
"sha256:4796c196faa5f5418ce9a8ee0e993c925755e505778e32442263422c4fe88013",
"sha256:4c6395cc3eefdd1c9ede1c84ad8e728edfc97ea506b04b9600d4cb61c7b80cb4",
"sha256:56d67935694d9270e0a9bcfd6b9169f81ef2c2e5e154acd57ac7afe2d48d7b29",
"sha256:57410c33aef7b3fd4ef2e5f09f1c084a21021055c74034748b8d2957a72dad01",
"sha256:63b3d66f5610c61d3d1b47687b99584fdf7734192344814d80f2670e0c7b05ef",
"sha256:6ed13704d67934d458abeaacd96079bb8ae5f0ea000765777449e94288590097",
"sha256:723fff54844d9c1e01703ed2bc177f892fd89530b7671e8191a639d799cd75b7",
"sha256:7ada705e3e9364f874c41fc370c23247f4c1466888dfd61ac5ec9277524928c2",
"sha256:80929da75a678433dcc8c79db94eb373408778d17fe9b49c4521501a5923a3e2",
"sha256:8b92d27414779f568484c4a0aeddbff8e1fa9d9403cff122161fa25bc94e7f44",
"sha256:97faf00577c74a4f4b6304c1b7f6223fb0825d1a7cfaad5601cbeadd8282cd70",
"sha256:9abfe8ef4f8898d0448de735a3270de466553b61de8e6ddc31fc8770003fdfa4",
"sha256:a1c3737f659085eeaab83e016569368157d8d46d6a3be317c864dadd3c28fa42",
"sha256:a3a480ac4077c868124427456c6a64dcb7da12817bd3e770006980a4fd0d2526",
"sha256:b58c8c1ea4b80a5cbc756a11e446eec16088ebd9e080e71a64c458f6c07cb3c7",
"sha256:da0797286c299c426e5b6cf03ca9e1dab0dace161b64d7a1879c4d15eb12ceba",
"sha256:dcc194082d94c45fe8a005861cdce6ec33b51c1dccf2a7e6044b33038b82f579",
"sha256:f5e7cd7068df4aa803be68edc7c6fc5e3ed934d53a7ab1f21539fb5925e0172e",
"sha256:ff442e4fe6e66019b2070352e0cd6e7dde994ff1267d45343b587ed621e4ec47"
],
"version": "==1.21.0rc1"
},
"python-dateutil": {
"hashes": [
@@ -113,7 +114,6 @@
"sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
"sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.16.0"
},
"skyfield": {
@@ -156,19 +156,18 @@
},
"black": {
"hashes": [
"sha256:23695358dbcb3deafe7f0a3ad89feee5999a46be5fec21f4f1d108be0bcdb3b1",
"sha256:8a60071a0043876a4ae96e6c69bd3a127dad2c1ca7c8083573eb82f92705d008"
"sha256:1fc0e0a2c8ae7d269dfcf0c60a89afa299664f3e811395d40b1922dff8f854b5",
"sha256:e5cf21ebdffc7a9b29d73912b6a6a9a4df4ce70220d523c21647da2eae0751ef"
],
"index": "pypi",
"version": "==21.5b1"
"version": "==21.5b2"
},
"click": {
"hashes": [
"sha256:7d8c289ee437bcb0316820ccee14aefcb056e58d31830ecab8e47eda6540e136",
"sha256:e90e62ced43dc8105fb9a26d62f0d9340b5c8db053a814e25d95c19873ae87db"
"sha256:8c04c11192119b1ef78ea049e0a6f0463e4c48ef00a30160c704337586f3ad7a",
"sha256:fba402a4a47334742d782209a7c79bc448911afe1149d07bdabdf480b3e2f4b6"
],
"markers": "python_version >= '3.6'",
"version": "==8.0.0"
"version": "==8.0.1"
},
"mypy-extensions": {
"hashes": [
@@ -242,7 +241,6 @@
"sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b",
"sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"
],
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==0.10.2"
}
}


+ 3
- 64
README.md View File

@@ -1,5 +1,5 @@
# ![Kosmorro](https://raw.githubusercontent.com/Kosmorro/logos/main/png/kosmorro-logo-grey.png)
[![Coverage Status](https://coveralls.io/repos/github/Kosmorro/kosmorro/badge.svg?branch=master)](https://coveralls.io/github/Kosmorro/kosmorro?branch=master) [![Version on PyPI](https://img.shields.io/pypi/v/kosmorro)](https://pypi.org/project/kosmorro) [![Discord](https://img.shields.io/discord/650237632533757965?logo=discord&label=%23kosmorro)](https://discord.gg/TVX4MSKGaa) ![Docker Pulls](https://img.shields.io/docker/pulls/kosmorro/kosmorro) [![Help translating Kosmorro!](https://hosted.weblate.org/widgets/kosmorro/-/cli/svg-badge.svg)](https://hosted.weblate.org/engage/kosmorro/)
[![Coverage Status](https://coveralls.io/repos/github/Kosmorro/kosmorro/badge.svg?branch=master)](https://coveralls.io/github/Kosmorro/kosmorro?branch=master) [![Version on PyPI](https://img.shields.io/pypi/v/kosmorro)](https://pypi.org/project/kosmorro) [![Packaging status](https://repology.org/badge/tiny-repos/kosmorro.svg)](https://repology.org/project/kosmorro/versions) [![Docker Pulls](https://img.shields.io/docker/pulls/kosmorro/kosmorro)](https://hub.docker.com/r/kosmorro/kosmorro) [![Help translating Kosmorro!](https://hosted.weblate.org/widgets/kosmorro/-/cli/svg-badge.svg)](https://hosted.weblate.org/engage/kosmorro/) [![Discord](https://img.shields.io/discord/650237632533757965?logo=discord&label=%23kosmorro)](https://discord.gg/TVX4MSKGaa)

A program that calculates your astronomical ephemerides!

@@ -7,60 +7,7 @@ A program that calculates your astronomical ephemerides!

### Production environment

Keep in mind that Kosmorro is still in alpha development stage and is not considered as stable.

#### Available packages

First thing first, check on the badge below (or on [Repology](https://repology.org/project/kosmorro/packages)) if your distribution has a package for Kosmorro.
If possible, prefer these packages, since they provide the best integration with your system, especially the update routine.

[![Packaging status](https://repology.org/badge/vertical-allrepos/kosmorro.svg)](https://repology.org/project/kosmorro/versions)

If it doesn't, then follow the methods ways below.

#### Install from PyPI (Linux, macOS)

> Note: Python 3 and PIP3 is necessary on your machine.
> Please check you have installed it before you install Kosmorro.
> If you need help to install Python 3 and PIP3, please refer to your distribution's manual.

Kosmorro is available [on PyPI](https://pypi.org/project/kosmorro/), a repository dedicated to Python.
To install it, invoke the following command: `pip3 install kosmorro`.

#### Windows

Kosmorro being at an early-stage development, Windows is not supported officially for now.

#### Docker

Kosmorro is available on [Docker Hub](https://hub.docker.com/r/kosmorro/kosmorro)!
You can get it by running `docker pull kosmorro/kosmorro`.

Now that you have the image, you can run it with `docker run -it kosmorro/kosmorro`.
Run Kosmorro by executing `kosmorro` in the container.

You can also run the image with the command: `docker run kosmorro/kosmorro kosmorro [args]`.

Note that for more convenience, you might add the following in your `.bashrc`/`.zshrc`/etc.:

```bash
alias kosmorro="docker run kosmorro/kosmorro kosmorro"
```

##### Image versioning on Docker Hub

By default, running `docker pull kosmorro/kosmorro` will download the `latest` tag by default, which corresponds to the last version of Kosmorro.
If you prefer, you can also force pulling a specific version by specifying it after the `:` character: `docker pull kosmorro/kosmorro:[version]`.

As of version 0.10, five kinds of tags are available:

| Tag | Description | Example
| --- | --- | ---
| `unstable` | the current code in the `master` branch, for testing purpose | `kosmorro/kosmorro:unstable`
| `latest` | the last version (equivalent to not specifying any tag) | `kosmorro/kosmorro:latest`
| `x` | the last version in the `x` major version | `kosmorro/kosmorro:0`: will pull the ![last version in the `0` major branch](https://img.shields.io/docker/v/kosmorro/kosmorro/0?style=flat-square)
| `x.y` | the last version in the `x.y` minor version | `kosmorro/kosmorro:0.10`: will pull the ![last version in the `0` major branch](https://img.shields.io/docker/v/kosmorro/kosmorro/0.10?style=flat-square)
| `x.y.z` | the exact specified version | `kosmorro/kosmorro:0.10.0`
If you want to give a try to Kosmorro, head to [its official download page](https://kosmorro.space/cli/download/) and follow the instructions that correspond to your operating system.

### Development environment

@@ -89,15 +36,7 @@ Note: the first time it runs, Kosmorro will download some important files needed
### Exporting to PDF

Kosmorro can export the computation results to PDF files, but this feature requires first that you install some additional dependencies.
Before you use this feature, make sure you have installed a LaTeX distribution:

- **Linux:** install TeXLive through your packages manager. Kosmorro just needs the minimal installation, you don't need any extension.
Note: **on Ubuntu 20.04+**, you will also need the `texlive-latex-extra` package.
- **macOS**: install basic version of [MacTeX](https://www.tug.org/mactex/):
- from the official website, choose the _smaller download_
- with Brew: `brew install basictex`

These dependencies are not installed by default, because they take a lot of place and are not necessary if you are not interested in generating PDF files.
You can find documentation about this on [Kosmorro's website](https://kosmorro.space/cli/generate-pdf/).

## Help translating Kosmorro!



+ 1
- 1
_kosmorro/__version__.py View File

@@ -19,7 +19,7 @@
__title__ = "kosmorro"
__description__ = "A program that computes your ephemerides"
__url__ = "https://kosmorro.space"
__version__ = '0.10.0'
__version__ = '0.10.1'
__author__ = "Jérôme Deuchnord"
__author_email__ = "jerome@deuchnord.fr"
__license__ = "AGPL"


+ 5
- 4
_kosmorro/debug.py View File

@@ -1,15 +1,16 @@
#!/usr/bin/env python3

from traceback import print_exc
from traceback import print_exception

show_debug_messages = False


def debug_print(what):
if not show_debug_messages:
def debug_print(what, force: bool = False):
if not force and not show_debug_messages:
return

if isinstance(what, Exception):
print_exc(what)
print_exception(type(what), value=what, tb=None)
else:
print("[DEBUG] %s" % what)


+ 71
- 48
_kosmorro/dumper.py View File

@@ -35,7 +35,10 @@ from kosmorrolib.model import ASTERS, MoonPhase
from .i18n.utils import _, FULL_DATE_FORMAT, SHORT_DATETIME_FORMAT, TIME_FORMAT
from .i18n import strings
from .__version__ import __version__ as version
from .exceptions import CompileError
from .exceptions import (
CompileError,
UnavailableFeatureError as KosmorroUnavailableFeatureError,
)
from .debug import debug_print


@@ -146,7 +149,11 @@ class TextDumper(Dumper):
data = []

for ephemeris in self.ephemerides:
name = self.style(strings.from_object(ephemeris.object.identifier), "th")
object_name = strings.from_object(ephemeris.object.identifier)
if object_name is None:
continue

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

if ephemeris.rise_time is not None:
time_fmt = (
@@ -194,16 +201,10 @@ class TextDumper(Dumper):
)

def get_events(self, events: [Event]) -> str:
def get_event_description(ev: Event):
description = strings.from_event(ev)

if ev.details is not None:
description += " ({:s})".format(ev.details)
return description

data = []

for event in events:
description = strings.from_event(event)
time_fmt = (
TIME_FORMAT
if event.start_time.day == self.date.day
@@ -212,7 +213,7 @@ class TextDumper(Dumper):
data.append(
[
self.style(event.start_time.strftime(time_fmt), "th"),
get_event_description(event),
description,
]
)

@@ -337,9 +338,13 @@ class _LatexDumper(Dumper):
document = document.replace("+++EVENTS+++", self._make_events())

for aster in ASTERS:
object_name = strings.from_object(aster.identifier)
if object_name is None:
continue

document = document.replace(
"+++ASTER_%s+++" % aster.skyfield_name.upper().split(" ")[0],
strings.from_object(aster.identifier),
object_name,
)

return document
@@ -381,15 +386,17 @@ class _LatexDumper(Dumper):
aster_set = "-"

if not self.show_graph:
latex.append(
r"\object{%s}{%s}{%s}{%s}"
% (
strings.from_object(ephemeris.object.identifier),
aster_rise,
aster_culmination,
aster_set,
object_name = strings.from_object(ephemeris.object.identifier)
if object_name is not None:
latex.append(
r"\object{%s}{%s}{%s}{%s}"
% (
object_name,
aster_rise,
aster_culmination,
aster_set,
)
)
)
else:
if ephemeris.rise_time is not None:
raise_hour = ephemeris.rise_time.hour
@@ -435,9 +442,13 @@ class _LatexDumper(Dumper):
latex = []

for event in self.events:
event_name = strings.from_event(event)
if event_name is None:
continue

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

return "".join(latex)
@@ -474,12 +485,13 @@ class PdfDumper(Dumper):
with_colors=self.with_colors,
show_graph=self.show_graph,
)

return self._compile(latex_dumper.to_string())
except RuntimeError as error:
raise UnavailableFeatureError(
raise KosmorroUnavailableFeatureError(
_(
"Building PDF was not possible, because some dependencies are not"
" installed.\nPlease look at the documentation at http://kosmorro.space "
" installed.\nPlease look at the documentation at https://kosmorro.space/cli/generate-pdf/ "
"for more information."
)
) from error
@@ -491,37 +503,48 @@ class PdfDumper(Dumper):
@staticmethod
def _compile(latex_input) -> bytes:
package = str(Path(__file__).parent.absolute()) + "/assets/pdf/kosmorro.sty"
timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
current_dir = (
os.getcwd()
) # Keep the current directory to return to it after the PDFLaTeX execution

with tempfile.TemporaryDirectory() as tempdir:
timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
shutil.copy(package, tempdir)
try:
temp_dir = tempfile.mkdtemp()

shutil.copy(package, temp_dir)

with open("%s/%s.tex" % (tempdir, timestamp), "w") as texfile:
texfile.write(latex_input)
temp_tex = "%s/%s.tex" % (temp_dir, timestamp)

os.chdir(tempdir)
with open(temp_tex, "w") as tex_file:
tex_file.write(latex_input)

os.chdir(temp_dir)
debug_print("LaTeX content:\n%s" % latex_input)

try:
subprocess.run(
["pdflatex", "-interaction", "nonstopmode", "%s.tex" % timestamp],
capture_output=True,
check=True,
)
except FileNotFoundError as error:
raise RuntimeError("pdflatex is not installed.") from error
except subprocess.CalledProcessError as error:
with open("/tmp/kosmorro-%s.log" % timestamp, "wb") as file:
file.write(error.stdout)
subprocess.run(
["pdflatex", "-interaction", "nonstopmode", "%s.tex" % timestamp],
capture_output=True,
check=True,
)

raise CompileError(
_(
"An error occurred during the compilation of the PDF.\n"
"Please open an issue at https://github.com/Kosmorro/kosmorro/issues and share "
"the content of the log file at /tmp/kosmorro-%s.log"
% timestamp
)
) from error
os.chdir(current_dir)

with open("%s.pdf" % timestamp, "rb") as pdffile:
with open("%s/%s.pdf" % (temp_dir, timestamp), "rb") as pdffile:
return bytes(pdffile.read())

except FileNotFoundError as error:
raise KosmorroUnavailableFeatureError(
"TeXLive is not installed."
) from error

except subprocess.CalledProcessError as error:
with open("/tmp/kosmorro-%s.log" % timestamp, "wb") as file:
file.write(error.stdout)

raise CompileError(
_(
"An error occurred during the compilation of the PDF.\n"
"Please open an issue at https://github.com/Kosmorro/kosmorro/issues and share "
"the content of the log file at /tmp/kosmorro-%s.log" % timestamp
)
) from error

+ 27
- 12
_kosmorro/i18n/strings.py View File

@@ -5,19 +5,29 @@ from .utils import _
from kosmorrolib import EventType, MoonPhaseType, ObjectIdentifier, Event


def from_event(event: Event) -> str:
return {
EventType.OPPOSITION: _("%s is in opposition"),
EventType.CONJUNCTION: _("%s and %s are in conjunction"),
EventType.OCCULTATION: _("%s occults %s"),
EventType.MAXIMAL_ELONGATION: _("Elongation of %s is maximal"),
EventType.MOON_PERIGEE: _("%s is at its perigee"),
EventType.MOON_APOGEE: _("%s is at its apogee"),
}.get(event.event_type) % tuple([from_object(o.identifier) for o in event.objects])
def from_event(event: Event, with_description: bool = True) -> 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.MOON_PERIGEE: (_("%s is at its perigee"), None),
EventType.MOON_APOGEE: (_("%s is at its apogee"), None),
}.get(event.event_type)

if string is None:
return None

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 string


def from_moon_phase(moon_phase: MoonPhaseType) -> str:
return {
string = {
MoonPhaseType.NEW_MOON: _("New Moon"),
MoonPhaseType.WAXING_CRESCENT: _("Waxing Crescent"),
MoonPhaseType.FIRST_QUARTER: _("First Quarter"),
@@ -26,7 +36,12 @@ def from_moon_phase(moon_phase: MoonPhaseType) -> str:
MoonPhaseType.WANING_GIBBOUS: _("Waning Gibbous"),
MoonPhaseType.LAST_QUARTER: _("Last Quarter"),
MoonPhaseType.WANING_CRESCENT: _("Waning Crescent"),
}.get(moon_phase, _("Unknown phase"))
}.get(moon_phase)

if string is None:
raise RuntimeError("Unknown moon phase: %s." % moon_phase)

return string


def from_object(identifier: ObjectIdentifier) -> str:
@@ -41,4 +56,4 @@ def from_object(identifier: ObjectIdentifier) -> str:
ObjectIdentifier.URANUS: _("Uranus"),
ObjectIdentifier.NEPTUNE: _("Neptune"),
ObjectIdentifier.PLUTO: _("Pluto"),
}.get(identifier, _("Unknown object"))
}.get(identifier)

+ 40
- 48
_kosmorro/locales/messages.pot View File

@@ -6,9 +6,9 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: kosmorro 0.10.0\n"
"Project-Id-Version: kosmorro 0.10.1\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-05-30 17:22+0200\n"
"POT-Creation-Date: 2021-06-20 16:08+0200\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,84 +27,84 @@ msgid ""
"offset format."
msgstr ""

#: _kosmorro/dumper.py:108
#: _kosmorro/dumper.py:111
msgid "Expected events:"
msgstr ""

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

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

#: _kosmorro/dumper.py:186 _kosmorro/dumper.py:322
#: _kosmorro/dumper.py:193 _kosmorro/dumper.py:323
msgid "Object"
msgstr ""

#: _kosmorro/dumper.py:187 _kosmorro/dumper.py:323
#: _kosmorro/dumper.py:194 _kosmorro/dumper.py:324
msgid "Rise time"
msgstr ""

#: _kosmorro/dumper.py:188 _kosmorro/dumper.py:325
#: _kosmorro/dumper.py:195 _kosmorro/dumper.py:326
msgid "Culmination time"
msgstr ""

#: _kosmorro/dumper.py:189 _kosmorro/dumper.py:327
#: _kosmorro/dumper.py:196 _kosmorro/dumper.py:328
msgid "Set time"
msgstr ""

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

#: _kosmorro/dumper.py:227 _kosmorro/dumper.py:331
#: _kosmorro/dumper.py:228 _kosmorro/dumper.py:332
msgid "Moon phase:"
msgstr ""

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

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

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

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

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

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

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

#: _kosmorro/dumper.py:518
#: _kosmorro/dumper.py:545
#, python-format
msgid ""
"An error occurred during the compilation of the PDF.\n"
@@ -253,86 +253,78 @@ msgstr ""
msgid "%s is at its apogee"
msgstr ""

#: _kosmorro/i18n/strings.py:21
#: _kosmorro/i18n/strings.py:31
msgid "New Moon"
msgstr ""

#: _kosmorro/i18n/strings.py:22
#: _kosmorro/i18n/strings.py:32
msgid "Waxing Crescent"
msgstr ""

#: _kosmorro/i18n/strings.py:23
#: _kosmorro/i18n/strings.py:33
msgid "First Quarter"
msgstr ""

#: _kosmorro/i18n/strings.py:24
#: _kosmorro/i18n/strings.py:34
msgid "Waxing Gibbous"
msgstr ""

#: _kosmorro/i18n/strings.py:25
#: _kosmorro/i18n/strings.py:35
msgid "Full Moon"
msgstr ""

#: _kosmorro/i18n/strings.py:26
#: _kosmorro/i18n/strings.py:36
msgid "Waning Gibbous"
msgstr ""

#: _kosmorro/i18n/strings.py:27
#: _kosmorro/i18n/strings.py:37
msgid "Last Quarter"
msgstr ""

#: _kosmorro/i18n/strings.py:28
#: _kosmorro/i18n/strings.py:38
msgid "Waning Crescent"
msgstr ""

#: _kosmorro/i18n/strings.py:29
msgid "Unknown phase"
msgstr ""

#: _kosmorro/i18n/strings.py:34
#: _kosmorro/i18n/strings.py:49
msgid "Sun"
msgstr ""

#: _kosmorro/i18n/strings.py:35
#: _kosmorro/i18n/strings.py:50
msgid "Moon"
msgstr ""

#: _kosmorro/i18n/strings.py:36
#: _kosmorro/i18n/strings.py:51
msgid "Mercury"
msgstr ""

#: _kosmorro/i18n/strings.py:37
#: _kosmorro/i18n/strings.py:52
msgid "Venus"
msgstr ""

#: _kosmorro/i18n/strings.py:38
#: _kosmorro/i18n/strings.py:53
msgid "Mars"
msgstr ""

#: _kosmorro/i18n/strings.py:39
#: _kosmorro/i18n/strings.py:54
msgid "Jupiter"
msgstr ""

#: _kosmorro/i18n/strings.py:40
#: _kosmorro/i18n/strings.py:55
msgid "Saturn"
msgstr ""

#: _kosmorro/i18n/strings.py:41
#: _kosmorro/i18n/strings.py:56
msgid "Uranus"
msgstr ""

#: _kosmorro/i18n/strings.py:42
#: _kosmorro/i18n/strings.py:57
msgid "Neptune"
msgstr ""

#: _kosmorro/i18n/strings.py:43
#: _kosmorro/i18n/strings.py:58
msgid "Pluto"
msgstr ""

#: _kosmorro/i18n/strings.py:44
msgid "Unknown object"
msgstr ""

#: _kosmorro/i18n/utils.py:27
msgid "{day_of_week} {month} {day_number}, {year}"
msgstr ""


Loading…
Cancel
Save