Browse Source

feat: replace latitude and longitude with one argument alone: --position (#191)

* feat: replace latitude and longitude with one argument alone: --position

* feat: add support for Plus Code

From Wikipedia: “The Open Location Code is a geocode system for
identifying an area anywhere on the Earth.”
A Plus Code has a the form of small alphanumerical codes like: `9F25J3H5+M8`

* docs: update the manpage
pull/196/head
Jérôme Deuchnord 2 years ago
committed by GitHub
parent
commit
5cab68ee92
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 249 additions and 189 deletions
  1. +22
    -9
      .scripts/tests-e2e.sh
  2. +1
    -0
      Pipfile
  3. +134
    -120
      Pipfile.lock
  4. +48
    -0
      _kosmorro/geolocation.py
  5. +32
    -29
      _kosmorro/locales/messages.pot
  6. +7
    -21
      _kosmorro/main.py
  7. +4
    -10
      manpage/kosmorro.1.md
  8. +1
    -0
      setup.py

+ 22
- 9
.scripts/tests-e2e.sh View File

@@ -82,6 +82,7 @@ KOSMORRO_COMMAND="kosmorro --debug"

assertSuccess "$KOSMORRO_COMMAND"
assertSuccess "$KOSMORRO_COMMAND -h"

assertSuccess "$KOSMORRO_COMMAND -d 2020-01-27"
assertFailure "$KOSMORRO_COMMAND -d yolo-yo-lo"
assertFailure "$KOSMORRO_COMMAND -d 2020-13-32"
@@ -91,28 +92,40 @@ assertSuccess "$KOSMORRO_COMMAND --date='+3y 5m3d'"
assertSuccess "$KOSMORRO_COMMAND --date='-1y3d'"
assertFailure "$KOSMORRO_COMMAND --date='+3d4m"
assertFailure "$KOSMORRO_COMMAND -date='3y'"
assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624"
assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27"
assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --timezone=1"
assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --timezone=-1"
assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=json"
assertFailure "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf"

assertFailure "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624"

assertSuccess "$KOSMORRO_COMMAND --position=\"9F25J3H5+M8\""
assertFailure "$KOSMORRO_COMMAND --position=\"J3H5+M8\""

assertSuccess "$KOSMORRO_COMMAND --position=\"50.5876,3.0624\""
assertSuccess "$KOSMORRO_COMMAND --position=\"50.5876;-3.0624\""
assertSuccess "$KOSMORRO_COMMAND --position=\"-50.5876;-3.0624\""
assertSuccess "$KOSMORRO_COMMAND --position=\"50.5876,-3.0624\""
assertSuccess "$KOSMORRO_COMMAND --position=\"-50.5876,-3.0624\""
assertSuccess "$KOSMORRO_COMMAND --position=\"\""
assertSuccess "$KOSMORRO_COMMAND --position=\"50.5876;3.0624\" -d 2020-01-27"

assertSuccess "$KOSMORRO_COMMAND --position=\"50.5876;3.0624\" -d 2020-01-27 --timezone=1"
assertSuccess "$KOSMORRO_COMMAND --position=\"50.5876;3.0624\" -d 2020-01-27 --timezone=-1"
assertSuccess "$KOSMORRO_COMMAND --position=\"50.5876;3.0624\" -d 2020-01-27 --format=json"
assertFailure "$KOSMORRO_COMMAND --position=\"50.5876;3.0624\" -d 2020-01-27 --format=pdf"

# Environment variables
assertSuccess "LATITUDE=50.5876 LONGITUDE=3.0624 TIMEZONE=1 kosmorro -d 2020-01-27"
assertSuccess "LATITUDE=50.5876 LONGITUDE=3.0624 TIMEZONE=-1 kosmorro -d 2020-01-27"

# Missing dependencies, should fail
assertFailure "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf -o $HOME/kosmorro/export/document.pdf"
assertFailure "$KOSMORRO_COMMAND --position=\"50.5876;3.0624\" -d 2020-01-27 --format=pdf -o $HOME/kosmorro/export/document.pdf"
assertFailure "ls $HOME/kosmorro/export/document.pdf"

assertSuccess "sudo apt-get install -y texlive texlive-latex-extra" "CI"

# Dependencies installed, should not fail
assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf -o $HOME/kosmorro/export/document.pdf"
assertSuccess "$KOSMORRO_COMMAND --position=\"50.5876;3.0624\" -d 2020-01-27 --format=pdf -o $HOME/kosmorro/export/document.pdf"
assertSuccess "ls $HOME/kosmorro/export/document.pdf"

assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf -o $HOME/kosmorro/export/document-no-graph.pdf --no-graph"
assertSuccess "$KOSMORRO_COMMAND --position=\"50.5876;3.0624\" -d 2020-01-27 --format=pdf -o $HOME/kosmorro/export/document-no-graph.pdf --no-graph"
assertSuccess "ls $HOME/kosmorro/export/document-no-graph.pdf"

# man page


+ 1
- 0
Pipfile View File

@@ -12,6 +12,7 @@ tabulate = "*"
termcolor = "*"
kosmorrolib = ">=0.11.0,<0.12.0"
python-dateutil = "*"
openlocationcode = ">=1.0.0,<2.0.0"

[requires]
python_version = "3"


+ 134
- 120
Pipfile.lock View File

@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "7ca2ce1c14eec2a7542613e3f502550e9facb550e09cd2430e2d73ac4fe2fa10"
"sha256": "c0f10aa43311aa11cb405e4ea09d56e767df4289654ca5eac7e8ad5d280f43e6"
},
"pipfile-spec": 6,
"requires": {
@@ -25,9 +25,9 @@
},
"jplephem": {
"hashes": [
"sha256:e0017de1a45015b247faa8d15ebf35d2014abe949135f3703a3252adb96e43b1"
"sha256:abb1dce2f5a2d8862a19866639397b230d0ca114cfcf613b2d4e49eeb5dd71f7"
],
"version": "==2.15"
"version": "==2.16"
},
"kosmorrolib": {
"hashes": [
@@ -39,81 +39,93 @@
},
"numpy": {
"hashes": [
"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"
"sha256:1a784e8ff7ea2a32e393cc53eb0003eca1597c7ca628227e34ce34eb11645a0e",
"sha256:2ba579dde0563f47021dcd652253103d6fd66165b18011dce1a0609215b2791e",
"sha256:3537b967b350ad17633b35c2f4b1a1bbd258c018910b518c30b48c8e41272717",
"sha256:3c40e6b860220ed862e8097b8f81c9af6d7405b723f4a7af24a267b46f90e461",
"sha256:598fe100b2948465cf3ed64b1a326424b5e4be2670552066e17dfaa67246011d",
"sha256:620732f42259eb2c4642761bd324462a01cdd13dd111740ce3d344992dd8492f",
"sha256:709884863def34d72b183d074d8ba5cfe042bc3ff8898f1ffad0209161caaa99",
"sha256:75579acbadbf74e3afd1153da6177f846212ea2a0cc77de53523ae02c9256513",
"sha256:7c55407f739f0bfcec67d0df49103f9333edc870061358ac8a8c9e37ea02fcd2",
"sha256:a1f2fb2da242568af0271455b89aee0f71e4e032086ee2b4c5098945d0e11cf6",
"sha256:a290989cd671cd0605e9c91a70e6df660f73ae87484218e8285c6522d29f6e38",
"sha256:ac4fd578322842dbda8d968e3962e9f22e862b6ec6e3378e7415625915e2da4d",
"sha256:ad09f55cc95ed8d80d8ab2052f78cc21cb231764de73e229140d81ff49d8145e",
"sha256:b9205711e5440954f861ceeea8f1b415d7dd15214add2e878b4d1cf2bcb1a914",
"sha256:bba474a87496d96e61461f7306fba2ebba127bed7836212c360f144d1e72ac54",
"sha256:bebab3eaf0641bba26039fb0b2c5bf9b99407924b53b1ea86e03c32c64ef5aef",
"sha256:cc367c86eb87e5b7c9592935620f22d13b090c609f1b27e49600cd033b529f54",
"sha256:ccc6c650f8700ce1e3a77668bb7c43e45c20ac06ae00d22bdf6760b38958c883",
"sha256:cf680682ad0a3bef56dae200dbcbac2d57294a73e5b0f9864955e7dd7c2c2491",
"sha256:d2910d0a075caed95de1a605df00ee03b599de5419d0b95d55342e9a33ad1fb3",
"sha256:d5caa946a9f55511e76446e170bdad1d12d6b54e17a2afe7b189112ed4412bb8",
"sha256:d89b0dc7f005090e32bb4f9bf796e1dcca6b52243caf1803fdd2b748d8561f63",
"sha256:d95d16204cd51ff1a1c8d5f9958ce90ae190be81d348b514f9be39f878b8044a",
"sha256:e4d5a86a5257843a18fb1220c5f1c199532bc5d24e849ed4b0289fb59fbd4d8f",
"sha256:e58ddb53a7b4959932f5582ac455ff90dcb05fac3f8dcc8079498d43afbbde6c",
"sha256:e80fe25cba41c124d04c662f33f6364909b985f2eb5998aaa5ae4b9587242cce",
"sha256:eda2829af498946c59d8585a9fd74da3f810866e05f8df03a86f70079c7531dd",
"sha256:fd0a359c1c17f00cb37de2969984a74320970e0ceef4808c32e00773b06649d9"
],
"markers": "python_version >= '3.7'",
"version": "==1.21.0"
},
"openlocationcode": {
"hashes": [
"sha256:6fc0108a8214b65d74964105bd69645a8a7529237f0de6aadcfa83cc3373b359"
],
"index": "pypi",
"version": "==1.0.1"
},
"python-dateutil": {
"hashes": [
"sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c",
"sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a"
"sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",
"sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"
],
"index": "pypi",
"version": "==2.8.1"
"version": "==2.8.2"
},
"sgp4": {
"hashes": [
"sha256:0e9d5764a60fa92a1f58fd5d5bc24f44a36e48e34723967951f6ca15330bc984",
"sha256:11a1d84c940462127a651368aced98e25f8cddf3ee6f3fff086c88549e3afb50",
"sha256:12bf193480bb734233b67c32dbead214a292cd451062eeb48cda5fe3a6b1bc44",
"sha256:15aa5c2fc22fa8995e3ddaaae3da65283c8e6d7c3c2c784a0b2ed2cb60ba0efe",
"sha256:16ed70a83dc5249b41d1dc2a5d129216fb8ccbda67ce4ea6d8aea47b1cae46cf",
"sha256:2274a7a2b88905c0de12fcff0ffc51a24a8e2e936d4f02313f9c2816273ebbb9",
"sha256:2a045b230f7b7afa095b2df434f3d84cf23235134a31e183c2a94ab6cf6bf644",
"sha256:2f2f54948b04b6bd472926b7fcb64f07c535a85bd7395006e766528bd47dc077",
"sha256:3755a35cefb6d9884223ebcab8453264f03d9cde5287a72d7109c9e832e13095",
"sha256:50e89196e610022f9ff2766a3cb31aae3bb7c98e79db0bf3352376ff2e2e3ea8",
"sha256:549ceaba69e8426a072d95498c60d81b5803c962ff78e35a7696ab1634d9b55d",
"sha256:5774221bcf1cbb21bee9bbaede05d4696651e1050e050b6ca5fb46a3b7cda83a",
"sha256:584f0b6acd53f523340af98b746c595befbb939426ddc6d604c2ea2b006822a5",
"sha256:9166d85f34e26ae66e828ca6748dbfc28ef45cd2be6478e418ccf24e6cdbd333",
"sha256:972322e6ef456ca15ae857339585612b27843ca3afc25cc8ee93ee97efce1e94",
"sha256:981b6977ec0136eb733ffe0fb852ce34dd1994dbae01f53f7d9b8fba13b18e85",
"sha256:a172ca0d65439ff9ca2824d6e4e12d9587b0226e3511204298b11cdbe280b72a",
"sha256:ae35b79bb3837044e81af6ab6cfa74e2e0293d1a471d60c295fac6747c5b2ac9",
"sha256:b2dcfcc2e41c229669caa101740bd7f37f8539b16a138f9683593e7de0dee3d6",
"sha256:b68ffc1a08bc4b7270e0d34c40efd35010cc49a5c1cf0904097e17591ee4e922",
"sha256:c9b7a85e3ce83908247ca6e5633d37543973562cbed2f076d667874f0c7396d9",
"sha256:cfa86f71cc394ad6b555edaee9cccb16e48a253c99038a63124b86476645f491",
"sha256:d4d95f789785319771782d06aa6fcdef0cf4fb749995b50c82156ea7a9713ed6",
"sha256:de8f77ddc146a0b6bc6ccf7b0355990b3c0928fc1a16a63fd8121d410d717a42",
"sha256:e64f985c99286467a2f84de8cc6e99832af6819eb52ad4e6106a4df5af7bc02d",
"sha256:eab7a12baa13057db6456ce031d98a58ca62daa59b5988612ad70c33309f35c0",
"sha256:f31ed36be5d8950f759b344a52d1ed6926cc1e93061cb2a9c4096ed34c74fa94",
"sha256:ffad58b31bf1316829fa432f6f63fbdff80c1b2d9012926ae4e1f294a8772087"
],
"version": "==2.19"
"sha256:05f22b4fd91861ee2e0e03a528c1aef11a8b263a60ab5f723d32cdb65dac3eaa",
"sha256:06586caf071e3427bc4e5a5c84a806045532040dc2c35ca0ff12f34cab2ecb5c",
"sha256:1af727dfe02ef32babd124644e96b8cc109b22142efb44e37d0e3aaf4c38a1ab",
"sha256:1d3b5abc07266203f4b453e7c1ca8403ef2d7b8d1779c14c9a4177e4b1558ba5",
"sha256:24477da85936b864fd765911f808a4d113c81189c2a0ecd5992bcdf9aecbf5ef",
"sha256:2a89fc1debacfa10cf55ae1d40472037a57687b1ae3b66e7196e5af53fb96a56",
"sha256:2b449e6cab15748608c6083f86b0059d26093f76fa227010df09d8f0954b3bbd",
"sha256:3e3eb29c308d30d010316832606af184d243d5aab8ccc5d589f3cb85d74471f7",
"sha256:43c2c6d464144bb80987b2e66f3992add58c65e095abe2b9d567650fdb877a9d",
"sha256:4d5eb2aff4f645f5020ac869ec453dcd807836b3eb8b459d569eda40c358cd76",
"sha256:642bae76c6e55b72feda3c5ca3721e837f2702816a120805349b06e40f85faea",
"sha256:67f99f534fdc5650d8efe516e77dd9b43e4cb8ab9b38f2b66484085c0ff75077",
"sha256:6c906973dc2966cba8065f359c3eaa18505280be8f625b54ebb98f5ddeb8d205",
"sha256:7d848698ae2bf5bb9ea2082640b0417175a6b2e6e8d580114ebe04265cd1bfb4",
"sha256:80f9b2f1c2ac53c7b8cbf1a08e5a39a56c1b7c18d3e0de922078758a784b0b20",
"sha256:876b82d41a859c9ff65d3bdb7f6a3cecfc63bea529b4dc751b06eefbd6c3f1e0",
"sha256:8c2f4f99ab360a93768bf88ad6a9fdf83edfa6292e0a0ac8924c85fde11b2055",
"sha256:9fde328872f484eb644dabe32122ba617570ff61b548b7200a9d63629ac3097c",
"sha256:b2169cd536355fc67e3870acea34c4fc22b2ccecab2c0bf45a01edfe646fe3d0",
"sha256:cf4d5ac32b5e84c7b420109a09ea3c3741844fa92776f79d1c852cc67e2c1364",
"sha256:d42a3dcdfd394c5059b99bbf8b35311e03e87d21fbfb6ba2d5c5d2dfad15d4d7",
"sha256:dbfffe1ff2c223804e2ebdeb568baad46f40342943c4a74169fd75dc5dddda57",
"sha256:dfc5214b65ad8229c499f0da3f5042a18239f12f4318e90d892a79dcbf27282f",
"sha256:e73680b3b7b8b977766ae91eadd92988a0c3e36248dcac5d8263a957bec34a04",
"sha256:e8ecc01fdffe81f11ca94bb255024379e62c92f73e2baec2bdf5a3c3108221ff",
"sha256:ea37423d4317ec5351a4e3b6a3947a6053978e5290549d77ba375459527f7ccb",
"sha256:ee329571c1a25ce4f1e2b01d6f923791d16c5a7a3a75219317073bc50a7d25fe",
"sha256:ee3688ae409a201107927b24be10db2a61efdd5a919737b4900c57ee8b3a22d6",
"sha256:f5d2830f2896cecc4af0729cd328994ae823f277f481d4fc992383eb79f3742a"
],
"version": "==2.20"
},
"six": {
"hashes": [
"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,17 +168,18 @@
},
"black": {
"hashes": [
"sha256:1fc0e0a2c8ae7d269dfcf0c60a89afa299664f3e811395d40b1922dff8f854b5",
"sha256:e5cf21ebdffc7a9b29d73912b6a6a9a4df4ce70220d523c21647da2eae0751ef"
"sha256:1c7aa6ada8ee864db745b22790a32f94b2795c253a75d6d9b5e439ff10d23116",
"sha256:c8373c6491de9362e39271630b65b964607bc5c79c83783547d76c839b3aa219"
],
"index": "pypi",
"version": "==21.5b2"
"version": "==21.7b0"
},
"click": {
"hashes": [
"sha256:8c04c11192119b1ef78ea049e0a6f0463e4c48ef00a30160c704337586f3ad7a",
"sha256:fba402a4a47334742d782209a7c79bc448911afe1149d07bdabdf480b3e2f4b6"
],
"markers": "python_version >= '3.6'",
"version": "==8.0.1"
},
"mypy-extensions": {
@@ -178,10 +191,10 @@
},
"pathspec": {
"hashes": [
"sha256:86379d6b86d75816baba717e64b1a3a3469deb93bb76d613c9ce79edc5cb68fd",
"sha256:aa0cb481c4041bf52ffa7b0d8fa6cd3e88a2ca4879c533c9153882ee2556790d"
"sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a",
"sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"
],
"version": "==0.8.1"
"version": "==0.9.0"
},
"pytz": {
"hashes": [
@@ -192,56 +205,57 @@
},
"regex": {
"hashes": [
"sha256:01afaf2ec48e196ba91b37451aa353cb7eda77efe518e481707e0515025f0cd5",
"sha256:11d773d75fa650cd36f68d7ca936e3c7afaae41b863b8c387a22aaa78d3c5c79",
"sha256:18c071c3eb09c30a264879f0d310d37fe5d3a3111662438889ae2eb6fc570c31",
"sha256:1e1c20e29358165242928c2de1482fb2cf4ea54a6a6dea2bd7a0e0d8ee321500",
"sha256:281d2fd05555079448537fe108d79eb031b403dac622621c78944c235f3fcf11",
"sha256:314d66636c494ed9c148a42731b3834496cc9a2c4251b1661e40936814542b14",
"sha256:32e65442138b7b76dd8173ffa2cf67356b7bc1768851dded39a7a13bf9223da3",
"sha256:339456e7d8c06dd36a22e451d58ef72cef293112b559010db3d054d5560ef439",
"sha256:3916d08be28a1149fb97f7728fca1f7c15d309a9f9682d89d79db75d5e52091c",
"sha256:3a9cd17e6e5c7eb328517969e0cb0c3d31fd329298dd0c04af99ebf42e904f82",
"sha256:47bf5bf60cf04d72bf6055ae5927a0bd9016096bf3d742fa50d9bf9f45aa0711",
"sha256:4c46e22a0933dd783467cf32b3516299fb98cfebd895817d685130cc50cd1093",
"sha256:4c557a7b470908b1712fe27fb1ef20772b78079808c87d20a90d051660b1d69a",
"sha256:52ba3d3f9b942c49d7e4bc105bb28551c44065f139a65062ab7912bef10c9afb",
"sha256:563085e55b0d4fb8f746f6a335893bda5c2cef43b2f0258fe1020ab1dd874df8",
"sha256:598585c9f0af8374c28edd609eb291b5726d7cbce16be6a8b95aa074d252ee17",
"sha256:619d71c59a78b84d7f18891fe914446d07edd48dc8328c8e149cbe0929b4e000",
"sha256:67bdb9702427ceddc6ef3dc382455e90f785af4c13d495f9626861763ee13f9d",
"sha256:6d1b01031dedf2503631d0903cb563743f397ccaf6607a5e3b19a3d76fc10480",
"sha256:741a9647fcf2e45f3a1cf0e24f5e17febf3efe8d4ba1281dcc3aa0459ef424dc",
"sha256:7c2a1af393fcc09e898beba5dd59196edaa3116191cc7257f9224beaed3e1aa0",
"sha256:7d9884d86dd4dd489e981d94a65cd30d6f07203d90e98f6f657f05170f6324c9",
"sha256:90f11ff637fe8798933fb29f5ae1148c978cccb0452005bf4c69e13db951e765",
"sha256:919859aa909429fb5aa9cf8807f6045592c85ef56fdd30a9a3747e513db2536e",
"sha256:96fcd1888ab4d03adfc9303a7b3c0bd78c5412b2bfbe76db5b56d9eae004907a",
"sha256:97f29f57d5b84e73fbaf99ab3e26134e6687348e95ef6b48cfd2c06807005a07",
"sha256:980d7be47c84979d9136328d882f67ec5e50008681d94ecc8afa8a65ed1f4a6f",
"sha256:a91aa8619b23b79bcbeb37abe286f2f408d2f2d6f29a17237afda55bb54e7aac",
"sha256:ade17eb5d643b7fead300a1641e9f45401c98eee23763e9ed66a43f92f20b4a7",
"sha256:b9c3db21af35e3b3c05764461b262d6f05bbca08a71a7849fd79d47ba7bc33ed",
"sha256:bd28bc2e3a772acbb07787c6308e00d9626ff89e3bfcdebe87fa5afbfdedf968",
"sha256:bf5824bfac591ddb2c1f0a5f4ab72da28994548c708d2191e3b87dd207eb3ad7",
"sha256:c0502c0fadef0d23b128605d69b58edb2c681c25d44574fc673b0e52dce71ee2",
"sha256:c38c71df845e2aabb7fb0b920d11a1b5ac8526005e533a8920aea97efb8ec6a4",
"sha256:ce15b6d103daff8e9fee13cf7f0add05245a05d866e73926c358e871221eae87",
"sha256:d3029c340cfbb3ac0a71798100ccc13b97dddf373a4ae56b6a72cf70dfd53bc8",
"sha256:e512d8ef5ad7b898cdb2d8ee1cb09a8339e4f8be706d27eaa180c2f177248a10",
"sha256:e8e5b509d5c2ff12f8418006d5a90e9436766133b564db0abaec92fd27fcee29",
"sha256:ee54ff27bf0afaf4c3b3a62bcd016c12c3fdb4ec4f413391a90bd38bc3624605",
"sha256:fa4537fb4a98fe8fde99626e4681cc644bdcf2a795038533f9f711513a862ae6",
"sha256:fd45ff9293d9274c5008a2054ecef86a9bfe819a67c7be1afb65e69b405b3042"
],
"version": "==2021.4.4"
},
"toml": {
"hashes": [
"sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b",
"sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"
],
"version": "==0.10.2"
"sha256:0eb2c6e0fcec5e0f1d3bcc1133556563222a2ffd2211945d7b1480c1b1a42a6f",
"sha256:15dddb19823f5147e7517bb12635b3c82e6f2a3a6b696cc3e321522e8b9308ad",
"sha256:173bc44ff95bc1e96398c38f3629d86fa72e539c79900283afa895694229fe6a",
"sha256:1c78780bf46d620ff4fff40728f98b8afd8b8e35c3efd638c7df67be2d5cddbf",
"sha256:2366fe0479ca0e9afa534174faa2beae87847d208d457d200183f28c74eaea59",
"sha256:2bceeb491b38225b1fee4517107b8491ba54fba77cf22a12e996d96a3c55613d",
"sha256:2ddeabc7652024803666ea09f32dd1ed40a0579b6fbb2a213eba590683025895",
"sha256:2fe5e71e11a54e3355fa272137d521a40aace5d937d08b494bed4529964c19c4",
"sha256:319eb2a8d0888fa6f1d9177705f341bc9455a2c8aca130016e52c7fe8d6c37a3",
"sha256:3f5716923d3d0bfb27048242a6e0f14eecdb2e2a7fac47eda1d055288595f222",
"sha256:422dec1e7cbb2efbbe50e3f1de36b82906def93ed48da12d1714cabcd993d7f0",
"sha256:4c9c3155fe74269f61e27617529b7f09552fbb12e44b1189cebbdb24294e6e1c",
"sha256:4f64fc59fd5b10557f6cd0937e1597af022ad9b27d454e182485f1db3008f417",
"sha256:564a4c8a29435d1f2256ba247a0315325ea63335508ad8ed938a4f14c4116a5d",
"sha256:59506c6e8bd9306cd8a41511e32d16d5d1194110b8cfe5a11d102d8b63cf945d",
"sha256:598c0a79b4b851b922f504f9f39a863d83ebdfff787261a5ed061c21e67dd761",
"sha256:59c00bb8dd8775473cbfb967925ad2c3ecc8886b3b2d0c90a8e2707e06c743f0",
"sha256:6110bab7eab6566492618540c70edd4d2a18f40ca1d51d704f1d81c52d245026",
"sha256:6afe6a627888c9a6cfbb603d1d017ce204cebd589d66e0703309b8048c3b0854",
"sha256:791aa1b300e5b6e5d597c37c346fb4d66422178566bbb426dd87eaae475053fb",
"sha256:8394e266005f2d8c6f0bc6780001f7afa3ef81a7a2111fa35058ded6fce79e4d",
"sha256:875c355360d0f8d3d827e462b29ea7682bf52327d500a4f837e934e9e4656068",
"sha256:89e5528803566af4df368df2d6f503c84fbfb8249e6631c7b025fe23e6bd0cde",
"sha256:99d8ab206a5270c1002bfcf25c51bf329ca951e5a169f3b43214fdda1f0b5f0d",
"sha256:9a854b916806c7e3b40e6616ac9e85d3cdb7649d9e6590653deb5b341a736cec",
"sha256:b85ac458354165405c8a84725de7bbd07b00d9f72c31a60ffbf96bb38d3e25fa",
"sha256:bc84fb254a875a9f66616ed4538542fb7965db6356f3df571d783f7c8d256edd",
"sha256:c92831dac113a6e0ab28bc98f33781383fe294df1a2c3dfd1e850114da35fd5b",
"sha256:cbe23b323988a04c3e5b0c387fe3f8f363bf06c0680daf775875d979e376bd26",
"sha256:ccb3d2190476d00414aab36cca453e4596e8f70a206e2aa8db3d495a109153d2",
"sha256:d8bbce0c96462dbceaa7ac4a7dfbbee92745b801b24bce10a98d2f2b1ea9432f",
"sha256:db2b7df831c3187a37f3bb80ec095f249fa276dbe09abd3d35297fc250385694",
"sha256:e586f448df2bbc37dfadccdb7ccd125c62b4348cb90c10840d695592aa1b29e0",
"sha256:e5983c19d0beb6af88cb4d47afb92d96751fb3fa1784d8785b1cdf14c6519407",
"sha256:e6a1e5ca97d411a461041d057348e578dc344ecd2add3555aedba3b408c9f874",
"sha256:eaf58b9e30e0e546cdc3ac06cf9165a1ca5b3de8221e9df679416ca667972035",
"sha256:ed693137a9187052fc46eedfafdcb74e09917166362af4cc4fddc3b31560e93d",
"sha256:edd1a68f79b89b0c57339bce297ad5d5ffcc6ae7e1afdb10f1947706ed066c9c",
"sha256:f080248b3e029d052bf74a897b9d74cfb7643537fbde97fe8225a6467fb559b5",
"sha256:f9392a4555f3e4cb45310a65b403d86b589adc773898c25a39184b1ba4db8985",
"sha256:f98dc35ab9a749276f1a4a38ab3e0e2ba1662ce710f6530f5b0a6656f1c32b58"
],
"version": "==2021.7.6"
},
"tomli": {
"hashes": [
"sha256:0713b16ff91df8638a6a694e295c8159ab35ba93e3424a626dd5226d386057be",
"sha256:be670d0d8d7570fd0ea0113bd7bb1ba3ac6706b4de062cc4c952769355c9c268"
],
"markers": "python_version >= '3.6'",
"version": "==1.0.4"
}
}
}

+ 48
- 0
_kosmorro/geolocation.py View File

@@ -0,0 +1,48 @@
#!/usr/bin/env python3

import re
from typing import Union

from kosmorrolib import Position
from openlocationcode import openlocationcode

from .i18n.utils import _


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(";")
if len(latitude_longitude) == 1:
latitude_longitude = from_str.split(",")

return Position(float(latitude_longitude[0]), float(latitude_longitude[1]))


def _parse_plus_code(from_str: str) -> Union[None, Position]:
if not openlocationcode.isValid(from_str):
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."
)
)

pos = openlocationcode.decode(from_str)

return Position(
latitude=(pos.latitudeLo + pos.latitudeHi) / 2,
longitude=(pos.longitudeLo + pos.longitudeHi) / 2,
)


def get_position(from_str: str) -> Position:
pos = _parse_plus_code(from_str)

if pos is not None:
return pos

return _parse_latitude_longitude(from_str)

+ 32
- 29
_kosmorro/locales/messages.pot View File

@@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 ""



+ 7
- 21
_kosmorro/main.py View File

@@ -13,6 +13,7 @@ from termcolor import colored

from . import dumper, environment, debug
from .date import parse_date
from .geolocation import get_position
from .__version__ import __version__ as kosmorro_version
from .exceptions import UnavailableFeatureError, OutOfRangeDateError as DateRangeError
from _kosmorro.i18n.utils import _, SHORT_DATE_FORMAT
@@ -34,12 +35,7 @@ def main():
print(colored(error.args[0], color="red", attrs=["bold"]))
return -1

position = None

if args.latitude is not None or args.longitude is not None:
position = Position(args.latitude, args.longitude)
elif env_vars.latitude is not None and env_vars.longitude is not None:
position = Position(float(env_vars.latitude), float(env_vars.longitude))
position = get_position(args.position) if args.position not in [None, ""] else None

if output_format == "pdf":
print(
@@ -247,23 +243,13 @@ def get_args(output_formats: [str]):
help=_("The format to output the information to"),
)
parser.add_argument(
"--latitude",
"-lat",
type=float,
default=None,
help=_(
"The observer's latitude on Earth. Can also be set in the KOSMORRO_LATITUDE environment "
"variable."
),
)
parser.add_argument(
"--longitude",
"-lon",
type=float,
"--position",
"-p",
type=str,
default=None,
help=_(
"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."
),
)
parser.add_argument(


+ 4
- 10
manpage/kosmorro.1.md View File

@@ -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`)


+ 1
- 0
setup.py View File

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


Loading…
Cancel
Save