From 496307eb5c1bef0ec5924946f831d9f6f7b9d9ad Mon Sep 17 00:00:00 2001 From: nicfb Date: Wed, 1 Dec 2021 22:34:09 -0600 Subject: [PATCH] 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 --- _kosmorro/environment.py | 1 + _kosmorro/locales/messages.pot | 63 ++++++++++++++++++++-------------- _kosmorro/main.py | 4 ++- manpage/kosmorro.1.md | 3 ++ 4 files changed, 44 insertions(+), 27 deletions(-) diff --git a/_kosmorro/environment.py b/_kosmorro/environment.py index 18542c3..be3dac2 100644 --- a/_kosmorro/environment.py +++ b/_kosmorro/environment.py @@ -21,6 +21,7 @@ import re from pathlib import Path CACHE_FOLDER = str(Path.home()) + "/.kosmorro-cache" +NO_COLOR = "NO_COLOR" in os.environ class Environment: diff --git a/_kosmorro/locales/messages.pot b/_kosmorro/locales/messages.pot index 52eae63..de0dc56 100644 --- a/_kosmorro/locales/messages.pot +++ b/_kosmorro/locales/messages.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: kosmorro 0.10.7\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" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -116,98 +116,109 @@ msgstr "" msgid "The date must be between {minimum_date} and {maximum_date}" 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 "" "Save the planet and paper!\n" "Consider printing your PDF document only if really necessary, and use the" " other side of the sheet." msgstr "" -#: _kosmorro/main.py:71 +#: _kosmorro/main.py:82 msgid "" "PDF output will not contain the ephemerides, because you didn't provide " "the observation coordinates." msgstr "" -#: _kosmorro/main.py:116 +#: _kosmorro/main.py:134 msgid "The file could not be saved in \"{path}\": {error}" msgstr "" -#: _kosmorro/main.py:130 +#: _kosmorro/main.py:148 msgid "Please provide a file path to export in this format (--output)." msgstr "" -#: _kosmorro/main.py:163 +#: _kosmorro/main.py:181 msgid "Moon phase can only be displayed between {min_date} and {max_date}" msgstr "" -#: _kosmorro/main.py:202 +#: _kosmorro/main.py:230 msgid "Running on Python {python_version} with Kosmorrolib v{kosmorrolib_version}" msgstr "" -#: _kosmorro/main.py:215 +#: _kosmorro/main.py:243 msgid "" "Compute the ephemerides and the events for a given date and a given " "position on Earth." msgstr "" -#: _kosmorro/main.py:218 +#: _kosmorro/main.py:246 msgid "" "By default, only the events will be computed for today ({date}).\n" "To compute also the ephemerides, latitude and longitude arguments are " "needed." msgstr "" -#: _kosmorro/main.py:232 +#: _kosmorro/main.py:260 msgid "Show the program version" msgstr "" -#: _kosmorro/main.py:240 -msgid "The format to output the information to" -msgstr "" - -#: _kosmorro/main.py:247 +#: _kosmorro/main.py:268 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 "" -#: _kosmorro/main.py:257 +#: _kosmorro/main.py:278 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 "" -#: _kosmorro/main.py:267 +#: _kosmorro/main.py:288 msgid "" "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," " and D numbers). Defaults to today ({default_date})." msgstr "" -#: _kosmorro/main.py:278 +#: _kosmorro/main.py:299 msgid "" "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." msgstr "" -#: _kosmorro/main.py:287 +#: _kosmorro/main.py:308 msgid "Disable the colors in the console." msgstr "" -#: _kosmorro/main.py:294 +#: _kosmorro/main.py:315 msgid "" "A file to export the output to. If not given, the standard output is " "used. This argument is needed for PDF format." msgstr "" -#: _kosmorro/main.py:303 +#: _kosmorro/main.py:324 msgid "" "Do not generate a graph to represent the rise and set times in the PDF " "format." msgstr "" -#: _kosmorro/main.py:311 +#: _kosmorro/main.py:332 msgid "Show debugging messages" msgstr "" diff --git a/_kosmorro/main.py b/_kosmorro/main.py index eca3632..ef1f566 100644 --- a/_kosmorro/main.py +++ b/_kosmorro/main.py @@ -95,12 +95,14 @@ def main(): timezone = 0 try: + use_colors = not environment.NO_COLOR and args.colors + output = get_information( compute_date, position, timezone, output_format, - args.colors, + use_colors, args.show_graph, ) except InvalidOutputFormatError as error: diff --git a/manpage/kosmorro.1.md b/manpage/kosmorro.1.md index 445fca2..a1fc157 100644 --- a/manpage/kosmorro.1.md +++ b/manpage/kosmorro.1.md @@ -51,6 +51,9 @@ Available environment variables are: `KOSMORRO_TIMEZONE` the observer's timezone (alternative to `--timezone`) +`NO_COLOR` + disable colored console output (alternative to `--no-colors`) + ## EXAMPLES Compute the events only for the current date: