diff --git a/_kosmorro/geolocation.py b/_kosmorro/geolocation.py index 5a649b9..7e06988 100644 --- a/_kosmorro/geolocation.py +++ b/_kosmorro/geolocation.py @@ -13,9 +13,9 @@ def _parse_latitude_longitude(from_str: str) -> Position: if not re.search(r"^([\d.-]+)[,;]([\d.-]+)$", from_str): raise ValueError(_("The given position (%s) is not valid." % from_str)) - latitude_longitude = from_str.split(';') + latitude_longitude = from_str.split(";") if len(latitude_longitude) == 1: - latitude_longitude = from_str.split(',') + latitude_longitude = from_str.split(",") return Position(float(latitude_longitude[0]), float(latitude_longitude[1])) @@ -25,13 +25,17 @@ def _parse_plus_code(from_str: str) -> Union[None, Position]: return None if not openlocationcode.isFull(from_str): - raise ValueError(_('The given Plus Code seems to be a short code, please provide a full code.')) + raise ValueError( + _( + "The given Plus Code seems to be a short code, please provide a full code." + ) + ) pos = openlocationcode.decode(from_str) return Position( latitude=(pos.latitudeLo + pos.latitudeHi) / 2, - longitude=(pos.longitudeLo + pos.longitudeHi) / 2 + longitude=(pos.longitudeLo + pos.longitudeHi) / 2, ) diff --git a/_kosmorro/locales/messages.pot b/_kosmorro/locales/messages.pot index 031ef18..b8656b7 100644 --- a/_kosmorro/locales/messages.pot +++ b/_kosmorro/locales/messages.pot @@ -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-06-20 16:49+0200\n" +"POT-Creation-Date: 2021-07-18 17:45+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -116,110 +116,113 @@ msgstr "" msgid "The date must be between {minimum_date} and {maximum_date}" msgstr "" -#: _kosmorro/main.py:46 +#: _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:42 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:55 +#: _kosmorro/main.py:51 msgid "" "PDF output will not contain the ephemerides, because you didn't provide " "the observation coordinates." msgstr "" -#: _kosmorro/main.py:100 +#: _kosmorro/main.py:96 msgid "The file could not be saved in \"{path}\": {error}" msgstr "" -#: _kosmorro/main.py:114 +#: _kosmorro/main.py:110 msgid "Please provide a file path to export in this format (--output)." msgstr "" -#: _kosmorro/main.py:147 +#: _kosmorro/main.py:143 msgid "Moon phase can only be displayed between {min_date} and {max_date}" msgstr "" -#: _kosmorro/main.py:186 +#: _kosmorro/main.py:182 msgid "Running on Python {python_version} with Kosmorrolib v{kosmorrolib_version}" msgstr "" -#: _kosmorro/main.py:196 +#: _kosmorro/main.py:192 msgid "Do you really want to clear Kosmorro's cache? [yN] " msgstr "" -#: _kosmorro/main.py:204 +#: _kosmorro/main.py:200 msgid "Incorrect answer, cache not cleared." msgstr "" -#: _kosmorro/main.py:214 +#: _kosmorro/main.py:210 msgid "" "Compute the ephemerides and the events for a given date and a given " "position on Earth." msgstr "" -#: _kosmorro/main.py:217 +#: _kosmorro/main.py:213 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:231 +#: _kosmorro/main.py:227 msgid "Show the program version" msgstr "" -#: _kosmorro/main.py:239 +#: _kosmorro/main.py:235 msgid "Delete all the files from Kosmorro's cache." msgstr "" -#: _kosmorro/main.py:247 +#: _kosmorro/main.py:243 msgid "The format to output the information to" msgstr "" -#: _kosmorro/main.py:254 -msgid "" -"The observer's latitude on Earth. Can also be set in the " -"KOSMORRO_LATITUDE environment variable." -msgstr "" - -#: _kosmorro/main.py:264 +#: _kosmorro/main.py:250 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:274 +#: _kosmorro/main.py:260 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:285 +#: _kosmorro/main.py:271 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:294 +#: _kosmorro/main.py:280 msgid "Disable the colors in the console." msgstr "" -#: _kosmorro/main.py:301 +#: _kosmorro/main.py:287 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:310 +#: _kosmorro/main.py:296 msgid "" "Do not generate a graph to represent the rise and set times in the PDF " "format." msgstr "" -#: _kosmorro/main.py:318 +#: _kosmorro/main.py:304 msgid "Show debugging messages" msgstr "" diff --git a/_kosmorro/main.py b/_kosmorro/main.py index 234acc8..4c28146 100644 --- a/_kosmorro/main.py +++ b/_kosmorro/main.py @@ -35,7 +35,7 @@ def main(): print(colored(error.args[0], color="red", attrs=["bold"])) return -1 - position = get_position(args.position) if args.position is not None else None + position = get_position(args.position) if args.position not in [None, ""] else None if output_format == "pdf": print( @@ -248,7 +248,7 @@ def get_args(output_formats: [str]): type=str, default=None, help=_( - "The observer's position on Earth, in the \"{latitude},{longitude}\" format." + 'The observer\'s position on Earth, in the "{latitude},{longitude}" format.' "Can also be set in the KOSMORRO_POSITION environment variable." ), ) diff --git a/manpage/kosmorro.1.md b/manpage/kosmorro.1.md index e46662d..c27738f 100644 --- a/manpage/kosmorro.1.md +++ b/manpage/kosmorro.1.md @@ -16,11 +16,8 @@ `--clear-cache` delete all the files Kosmorro stored in the cache -`--latitude=`_LATITUDE_, `-lat` _LATITUDE_ - the observer's latitude on Earth - -`--longitude=`_LONGITUDE_, `-lon` _LONGITUDE_ - the observer's longitude on Earth +`--position=`"_LATITUDE_,_LONGITUDE_", `-p` "_LATITUDE_,_LONGITUDE" + the observer's position on Earth `--date=`_DATE_, `-d` _DATE_ The date for which the ephemerides must be computed, either in the YYYY-MM-DD format or as an interval in the "[+-]YyMmDd" format (with Y, M, and D numbers); defaults to the current date @@ -48,11 +45,8 @@ As a consequence, any option that would be given to `kosmorro` will override its Available environment variables are: -`KOSMORRO_LATITUDE` - the observer's latitude on Earth (alternative to `--latitude`) - -`KOSMORRO_LONGITUDE` - the observer's longitude on Earth (alternative to `--longitude`) +`KOSMORRO_POSITION` + the observer's position on Earth (alternative to `--position`) `KOSMORRO_TIMEZONE` the observer's timezone (alternative to `--timezone`) diff --git a/setup.py b/setup.py index 25d2468..522247e 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,7 @@ setup( "tabulate", "termcolor", "python-dateutil", + "openlocationcode", ], classifiers=[ "Development Status :: 3 - Alpha",