Browse Source

feat: check environment variable for output color

update man pages

fix formatting

update man pages

add NO_COLOR constant

minor changes for PR

add missing import

update messages
pull/227/head
nicfb 3 years ago
committed by Jérôme Deuchnord
parent
commit
496307eb5c
4 changed files with 44 additions and 27 deletions
  1. +1
    -0
      _kosmorro/environment.py
  2. +37
    -26
      _kosmorro/locales/messages.pot
  3. +3
    -1
      _kosmorro/main.py
  4. +3
    -0
      manpage/kosmorro.1.md

+ 1
- 0
_kosmorro/environment.py View File

@@ -21,6 +21,7 @@ import re
from pathlib import Path from pathlib import Path


CACHE_FOLDER = str(Path.home()) + "/.kosmorro-cache" CACHE_FOLDER = str(Path.home()) + "/.kosmorro-cache"
NO_COLOR = "NO_COLOR" in os.environ




class Environment: class Environment:


+ 37
- 26
_kosmorro/locales/messages.pot View File

@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: kosmorro 0.10.7\n" "Project-Id-Version: kosmorro 0.10.7\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-12-04 11:58+0100\n"
"POT-Creation-Date: 2021-12-04 22:15-0600\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"
@@ -116,98 +116,109 @@ msgstr ""
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/exceptions.py:47
msgid ""
"Invalid output format: {output_format}. Output file must end with: "
"{accepted_extensions}"
msgstr ""

#: _kosmorro/geolocation.py:14
#, python-format
msgid "The given position (%s) is not valid."
msgstr ""

#: _kosmorro/geolocation.py:29
msgid "The given Plus Code seems to be a short code, please provide a full code."
msgstr ""

#: _kosmorro/main.py:73
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:82
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:134
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:148
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
#: _kosmorro/main.py:181
msgid "Moon phase can only be displayed between {min_date} and {max_date}" msgid "Moon phase can only be displayed between {min_date} and {max_date}"
msgstr "" msgstr ""


#: _kosmorro/main.py:202
#: _kosmorro/main.py:230
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:243
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:246
msgid "" msgid ""
"By default, only the events will be computed for today ({date}).\n" "By default, only the events will be computed for today ({date}).\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:232
#: _kosmorro/main.py:260
msgid "Show the program version" msgid "Show the program version"
msgstr "" msgstr ""


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

#: _kosmorro/main.py:247
#: _kosmorro/main.py:268
msgid "" msgid ""
"The observer's latitude on Earth. Can also be set in the "
"KOSMORRO_LATITUDE environment variable."
"The format to output the information to. If not provided, the output "
"format will be inferred from the file extension of the output file."
msgstr "" msgstr ""


#: _kosmorro/main.py:257
#: _kosmorro/main.py:278
msgid "" msgid ""
"The observer's longitude on Earth. Can also be set in the "
"KOSMORRO_LONGITUDE environment variable."
"The observer's position on Earth, in the \"{latitude},{longitude}\" "
"format.Can also be set in the KOSMORRO_POSITION environment variable."
msgstr "" msgstr ""


#: _kosmorro/main.py:267
#: _kosmorro/main.py:288
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 today ({default_date})." " and D numbers). Defaults to today ({default_date})."
msgstr "" msgstr ""


#: _kosmorro/main.py:278
#: _kosmorro/main.py:299
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:287
#: _kosmorro/main.py:308
msgid "Disable the colors in the console." msgid "Disable the colors in the console."
msgstr "" msgstr ""


#: _kosmorro/main.py:294
#: _kosmorro/main.py:315
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:303
#: _kosmorro/main.py:324
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:311
#: _kosmorro/main.py:332
msgid "Show debugging messages" msgid "Show debugging messages"
msgstr "" msgstr ""




+ 3
- 1
_kosmorro/main.py View File

@@ -95,12 +95,14 @@ def main():
timezone = 0 timezone = 0


try: try:
use_colors = not environment.NO_COLOR and args.colors

output = get_information( output = get_information(
compute_date, compute_date,
position, position,
timezone, timezone,
output_format, output_format,
args.colors,
use_colors,
args.show_graph, args.show_graph,
) )
except InvalidOutputFormatError as error: except InvalidOutputFormatError as error:


+ 3
- 0
manpage/kosmorro.1.md View File

@@ -51,6 +51,9 @@ Available environment variables are:
`KOSMORRO_TIMEZONE` `KOSMORRO_TIMEZONE`
the observer's timezone (alternative to `--timezone`) the observer's timezone (alternative to `--timezone`)


`NO_COLOR`
disable colored console output (alternative to `--no-colors`)

## EXAMPLES ## EXAMPLES


Compute the events only for the current date: Compute the events only for the current date:


Loading…
Cancel
Save