From 0b12e71da8ba5ef9079a86a5eb401ae3f32beba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Deuchnord?= Date: Thu, 21 Jan 2021 12:15:24 +0100 Subject: [PATCH] ci(compatibility): test on more Python versions and on macOS (#131) BREAKING CHANGE: on Ubuntu 20.04+, the `texlive-latex-extra` package is needed to generate the PDF output --- .coveragerc | 1 + .editorconfig | 3 + .github/workflows/commitlint.yml | 15 +- .github/workflows/e2e.yml | 25 ++- .github/workflows/i18n.yml | 8 +- .github/workflows/pylint.yml | 13 +- .github/workflows/unit-tests.yml | 25 ++- .pylintrc | 4 +- .scripts/tests-e2e.sh | 3 +- Makefile | 2 + Pipfile | 2 - Pipfile.lock | 325 ++++++++++++++++--------------- README.md | 37 ++-- config-comlipy.yml | 5 +- kosmorrolib/core.py | 3 +- kosmorrolib/dumper.py | 46 +++-- kosmorrolib/ephemerides.py | 4 +- kosmorrolib/events.py | 2 +- kosmorrolib/exceptions.py | 10 +- kosmorrolib/locales/messages.pot | 88 +++++---- kosmorrolib/main.py | 9 +- 21 files changed, 358 insertions(+), 272 deletions(-) diff --git a/.coveragerc b/.coveragerc index d5ae331..9a36afd 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,4 +3,5 @@ branch = true source = kosmorrolib omit = + kosmorrolib/main.py test/* diff --git a/.editorconfig b/.editorconfig index d2f9538..d6c1200 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,5 +12,8 @@ trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false +[*.yml] +indent_size = 2 + [Makefile] indent_style = tab diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index a83a7c1..efd9b87 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -1,9 +1,13 @@ name: Commit lint -on: [push, pull_request] +on: + push: + branches: [master, features] + pull_request: + branches: [master, features] jobs: - build: + commitlint: runs-on: ubuntu-latest steps: @@ -11,14 +15,13 @@ jobs: - name: Set up Python uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: 3.9 - name: Install dependencies run: | - pip install --upgrade pip pipenv - pipenv sync -d + pip install --upgrade pip comlipy - name: Lint run: | message="$(git log --format=%B -n 1 HEAD)" echo $message - pipenv run comlipy -c config-comlipy.yml "$message" + comlipy -c config-comlipy.yml "$message" diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index fc82123..8733d25 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,18 +1,33 @@ name: E2E tests -on: [push, pull_request] +on: + push: + branches: [master, features] + pull_request: + branches: [master, features] jobs: - build: - runs-on: ubuntu-latest - + e2e-tests: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-18.04 + - ubuntu-20.04 + python-version: + - '3.7' + - '3.8' + - '3.9' + + name: E2E tests (Python ${{ matrix.python-version }} on ${{ matrix.os }}) steps: - uses: actions/checkout@v1 - name: Set up Python uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: ${{ matrix.python-version }} - name: Prepare tests run: | diff --git a/.github/workflows/i18n.yml b/.github/workflows/i18n.yml index c4a2f41..2ddd167 100644 --- a/.github/workflows/i18n.yml +++ b/.github/workflows/i18n.yml @@ -1,9 +1,13 @@ name: Internationalization check -on: [push, pull_request] +on: + push: + branches: [master, features] + pull_request: + branches: [master, features] jobs: - build: + internationalization: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 4cbb641..7151b2b 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -1,17 +1,22 @@ -name: PyLint +name: Python Lint -on: [push, pull_request] +on: + push: + branches: [master, features] + pull_request: + branches: [master, features] jobs: - build: + pylint: runs-on: ubuntu-latest + name: PyLint steps: - uses: actions/checkout@v1 - name: Set up Python uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: 3.9 - name: Install dependencies run: | pip install --upgrade pip pipenv diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 24bc50b..e57034b 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -1,17 +1,34 @@ name: Unit tests -on: [push, pull_request] +on: + push: + branches: [master, features] + pull_request: + branches: [master, features] jobs: - build: - runs-on: ubuntu-latest + unit-tests: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-18.04 + - ubuntu-20.04 + - macos-10.15 + - macos-11.0 + python-version: + - '3.7' + - '3.8' + - '3.9' + name: Unit tests (Python ${{ matrix.python-version }} on ${{ matrix.os }}) steps: - uses: actions/checkout@v1 - name: Set up Python uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: ${{ matrix.python-version }} - name: Install dependencies run: | pip install --upgrade pip pipenv diff --git a/.pylintrc b/.pylintrc index 3632123..202bd12 100644 --- a/.pylintrc +++ b/.pylintrc @@ -147,7 +147,9 @@ disable=print-statement, too-few-public-methods, protected-access, unnecessary-comprehension, - too-many-arguments + too-many-arguments, + unsubscriptable-object, + too-many-return-statements # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option diff --git a/.scripts/tests-e2e.sh b/.scripts/tests-e2e.sh index 3c35f9f..35363ac 100755 --- a/.scripts/tests-e2e.sh +++ b/.scripts/tests-e2e.sh @@ -101,8 +101,7 @@ assertSuccess "LATITUDE=50.5876 LONGITUDE=3.0624 TIMEZONE=-1 kosmorro -d 2020-01 # Missing dependencies, should fail assertFailure "kosmorro --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf -o /tmp/document.pdf" -assertSuccess "sudo apt-get install -y texlive" "CI" -assertSuccess "$PIP_BIN install latex" "CI" +assertSuccess "sudo apt-get install -y texlive texlive-latex-extra" "CI" # Dependencies installed, should not fail assertSuccess "kosmorro --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf -o /tmp/document.pdf" diff --git a/Makefile b/Makefile index f484f00..4e1892f 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ .PHONY: test test: + export LC_ALL=C.UTF-8; \ + export LANG=C.UTF-8; \ unset KOSMORRO_LATITUDE; \ unset KOSMORRO_LONGITUDE; \ unset KOSMORRO_TIMEZONE; \ diff --git a/Pipfile b/Pipfile index f04be1f..2808ca8 100644 --- a/Pipfile +++ b/Pipfile @@ -9,14 +9,12 @@ pylint = "*" babel = "*" unittest-data-provider = "*" coveralls = "*" -comlipy = "*" [packages] skyfield = ">=1.32.0,<2.0.0" tabulate = "*" numpy = ">=1.17.0,<2.0.0" termcolor = "*" -latex = "*" python-dateutil = "*" [requires] diff --git a/Pipfile.lock b/Pipfile.lock index c975fd2..b17540e 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "4d15bacd4af8bef236d7323e49b1f426715f0c34b0f083bb78a71062f4b64dd4" + "sha256": "a46d9bde2c8471c29d689d748afa6c04b5f8b96fddaa4eff5406658dc2af3765" }, "pipfile-spec": 6, "requires": { @@ -18,10 +18,10 @@ "default": { "certifi": { "hashes": [ - "sha256:1f422849db327d534e3d0c5f02a263458c3955ec0aae4ff09b95f195c59f4edd", - "sha256:f05def092c44fbf25834a51509ef6e631dc19765ab8a57b4e7ab85531f0a9cf4" + "sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c", + "sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830" ], - "version": "==2020.11.8" + "version": "==2020.12.5" }, "data": { "hashes": [ @@ -60,40 +60,47 @@ "hashes": [ "sha256:bf10c3fe27e9f3adccebc12e90ec239c86dcba101b89221f6775918211482a79" ], - "index": "pypi", - "version": "==0.7.0" + "version": "==2.15" }, "numpy": { "hashes": [ - "sha256:082f8d4dd69b6b688f64f509b91d482362124986d98dc7dc5f5e9f9b9c3bb983", - "sha256:1bc0145999e8cb8aed9d4e65dd8b139adf1919e521177f198529687dbf613065", - "sha256:309cbcfaa103fc9a33ec16d2d62569d541b79f828c382556ff072442226d1968", - "sha256:3673c8b2b29077f1b7b3a848794f8e11f401ba0b71c49fbd26fb40b71788b132", - "sha256:480fdd4dbda4dd6b638d3863da3be82873bba6d32d1fc12ea1b8486ac7b8d129", - "sha256:56ef7f56470c24bb67fb43dae442e946a6ce172f97c69f8d067ff8550cf782ff", - "sha256:5a936fd51049541d86ccdeef2833cc89a18e4d3808fe58a8abeb802665c5af93", - "sha256:5b6885c12784a27e957294b60f97e8b5b4174c7504665333c5e94fbf41ae5d6a", - "sha256:667c07063940e934287993366ad5f56766bc009017b4a0fe91dbd07960d0aba7", - "sha256:7ed448ff4eaffeb01094959b19cbaf998ecdee9ef9932381420d514e446601cd", - "sha256:8343bf67c72e09cfabfab55ad4a43ce3f6bf6e6ced7acf70f45ded9ebb425055", - "sha256:92feb989b47f83ebef246adabc7ff3b9a59ac30601c3f6819f8913458610bdcc", - "sha256:935c27ae2760c21cd7354402546f6be21d3d0c806fffe967f745d5f2de5005a7", - "sha256:aaf42a04b472d12515debc621c31cf16c215e332242e7a9f56403d814c744624", - "sha256:b12e639378c741add21fbffd16ba5ad25c0a1a17cf2b6fe4288feeb65144f35b", - "sha256:b1cca51512299841bf69add3b75361779962f9cee7d9ee3bb446d5982e925b69", - "sha256:b8456987b637232602ceb4d663cb34106f7eb780e247d51a260b84760fd8f491", - "sha256:b9792b0ac0130b277536ab8944e7b754c69560dac0415dd4b2dbd16b902c8954", - "sha256:c9591886fc9cbe5532d5df85cb8e0cc3b44ba8ce4367bd4cf1b93dc19713da72", - "sha256:cf1347450c0b7644ea142712619533553f02ef23f92f781312f6a3553d031fc7", - "sha256:de8b4a9b56255797cbddb93281ed92acbc510fb7b15df3f01bd28f46ebc4edae", - "sha256:e1b1dc0372f530f26a03578ac75d5e51b3868b9b76cd2facba4c9ee0eb252ab1", - "sha256:e45f8e981a0ab47103181773cc0a54e650b2aef8c7b6cd07405d0fa8d869444a", - "sha256:e4f6d3c53911a9d103d8ec9518190e52a8b945bab021745af4939cfc7c0d4a9e", - "sha256:ed8a311493cf5480a2ebc597d1e177231984c818a86875126cfd004241a73c3e", - "sha256:ef71a1d4fd4858596ae80ad1ec76404ad29701f8ca7cdcebc50300178db14dfc" + "sha256:012426a41bc9ab63bb158635aecccc7610e3eff5d31d1eb43bc099debc979d94", + "sha256:06fab248a088e439402141ea04f0fffb203723148f6ee791e9c75b3e9e82f080", + "sha256:0eef32ca3132a48e43f6a0f5a82cb508f22ce5a3d6f67a8329c81c8e226d3f6e", + "sha256:1ded4fce9cfaaf24e7a0ab51b7a87be9038ea1ace7f34b841fe3b6894c721d1c", + "sha256:2e55195bc1c6b705bfd8ad6f288b38b11b1af32f3c8289d6c50d47f950c12e76", + "sha256:2ea52bd92ab9f768cc64a4c3ef8f4b2580a17af0a5436f6126b08efbd1838371", + "sha256:36674959eed6957e61f11c912f71e78857a8d0604171dfd9ce9ad5cbf41c511c", + "sha256:384ec0463d1c2671170901994aeb6dce126de0a95ccc3976c43b0038a37329c2", + "sha256:39b70c19ec771805081578cc936bbe95336798b7edf4732ed102e7a43ec5c07a", + "sha256:400580cbd3cff6ffa6293df2278c75aef2d58d8d93d3c5614cd67981dae68ceb", + "sha256:43d4c81d5ffdff6bae58d66a3cd7f54a7acd9a0e7b18d97abb255defc09e3140", + "sha256:50a4a0ad0111cc1b71fa32dedd05fa239f7fb5a43a40663269bb5dc7877cfd28", + "sha256:603aa0706be710eea8884af807b1b3bc9fb2e49b9f4da439e76000f3b3c6ff0f", + "sha256:6149a185cece5ee78d1d196938b2a8f9d09f5a5ebfbba66969302a778d5ddd1d", + "sha256:759e4095edc3c1b3ac031f34d9459fa781777a93ccc633a472a5468587a190ff", + "sha256:7fb43004bce0ca31d8f13a6eb5e943fa73371381e53f7074ed21a4cb786c32f8", + "sha256:811daee36a58dc79cf3d8bdd4a490e4277d0e4b7d103a001a4e73ddb48e7e6aa", + "sha256:8b5e972b43c8fc27d56550b4120fe6257fdc15f9301914380b27f74856299fea", + "sha256:99abf4f353c3d1a0c7a5f27699482c987cf663b1eac20db59b8c7b061eabd7fc", + "sha256:a0d53e51a6cb6f0d9082decb7a4cb6dfb33055308c4c44f53103c073f649af73", + "sha256:a12ff4c8ddfee61f90a1633a4c4afd3f7bcb32b11c52026c92a12e1325922d0d", + "sha256:a4646724fba402aa7504cd48b4b50e783296b5e10a524c7a6da62e4a8ac9698d", + "sha256:a76f502430dd98d7546e1ea2250a7360c065a5fdea52b2dffe8ae7180909b6f4", + "sha256:a9d17f2be3b427fbb2bce61e596cf555d6f8a56c222bd2ca148baeeb5e5c783c", + "sha256:ab83f24d5c52d60dbc8cd0528759532736b56db58adaa7b5f1f76ad551416a1e", + "sha256:aeb9ed923be74e659984e321f609b9ba54a48354bfd168d21a2b072ed1e833ea", + "sha256:c843b3f50d1ab7361ca4f0b3639bf691569493a56808a0b0c54a051d260b7dbd", + "sha256:cae865b1cae1ec2663d8ea56ef6ff185bad091a5e33ebbadd98de2cfa3fa668f", + "sha256:cc6bd4fd593cb261332568485e20a0712883cf631f6f5e8e86a52caa8b2b50ff", + "sha256:cf2402002d3d9f91c8b01e66fbb436a4ed01c6498fffed0e4c7566da1d40ee1e", + "sha256:d051ec1c64b85ecc69531e1137bb9751c6830772ee5c1c426dbcfe98ef5788d7", + "sha256:d6631f2e867676b13026e2846180e2c13c1e11289d67da08d71cacb2cd93d4aa", + "sha256:dbd18bcf4889b720ba13a27ec2f2aac1981bd41203b3a3b27ba7a33f88ae4827", + "sha256:df609c82f18c5b9f6cb97271f03315ff0dbe481a2a02e56aeb1b1a985ce38e60" ], "index": "pypi", - "version": "==1.19.1" + "version": "==1.19.5" }, "python-dateutil": { "hashes": [ @@ -105,38 +112,49 @@ }, "sgp4": { "hashes": [ - "sha256:005f8517fcbde7af42229f1e0effde7f797d96eb210e471c474791c3aaf5aadf", - "sha256:047757aa85357b2deec06a00bd098806639dac4bd16a10a2ea406cc9bc9a8f7e", - "sha256:0847397cf8a563b9cc4625d96365301225f52fcfb2ce889a30f95113ad6a010a", - "sha256:0a43ce0451c0f1a8023848f672b56d7b02b0c9747d73031b55c26f67500a70e7", - "sha256:10e64adf473f1f4c72ea6dc7f6817364545a6163388e72bb8f63ddd9ff7a911b", - "sha256:1e91f64a9d0f42855082b028419d06e8e20a857e0d3eeb64a138b74f394321f5", - "sha256:1ef02cbb37100c67b0b8b156613fd09ce1a97d2b5361c201f6b157ec954569e0", - "sha256:1fa7b3f55c9e00f2526b30ff2293526c353856bfb157c71332ec70db536906ba", - "sha256:28f3c51eec209518d502bb5f3b0de5306efd0cd40e48321c036692c6041ea496", - "sha256:2bfbb35d2216b36b6b1b5c6e15630839b9eea5c15b26893f05f27f51fbc92360", - "sha256:3acdbbb5de380b587c66fc59e26e635668c74661da1b731007aece8506d1e279", - "sha256:43720e8e20dcbf3ac60cda41171d6fcc7692d685bd6374d171f7849299d03c52", - "sha256:46b3457db278faf85c4fce58de690a88370d5fd5d701406082f4041c2fc94221", - "sha256:5d9683f28f8d5d8a1856e985aa9fdde017aa7a2b2f29e24d9726d59d23b4f351", - "sha256:6267c27560f09a20913abde97d945d3334591436e8130bbb21ae02e0d4758b98", - "sha256:8471b183198d649266d22f61704840fea0ad499b38fd95228c38438faf9584d2", - "sha256:8b3ced831b321cd5a018bb134e4d4ba2b10fc73c20a48c74b006c0a73eb91622", - "sha256:8db7be3b810907bbdeaa57c84824fe0fda0090be42b40ab149665cfdb625919a", - "sha256:950489e6287b8d3fd8fa47446455fcb3c6a231eec15e49ff06467b9ce61454b9", - "sha256:a96282c862bbd746e9395f80430488f5283cc3179c1b697fdc014d786fd97e06", - "sha256:b49360be32bae8afb30bce4153f80d290bcf0975a3bf41991c3e473a949971a6", - "sha256:b5d814dee570bb2bf6938dd511019245dc8d3e3bcb58488461ce2efd747f578d", - "sha256:bb371f39e72472f48f24061198bb6523d3d796e140d7bbc5ccae049afd5cc66f", - "sha256:c9346b69e9ee1ec53222d32557da8ad422a394f7a3675773c850aa22df60995e", - "sha256:cd3bdbc10df1a914b3c015fd4212923357a8a0691d448fb1339d6b97d439ecc6", - "sha256:d46bc7f38ae7d13982875d5cf44c8f343f56538b49b0ab9c038e9d24365e80dd", - "sha256:e2b2321df9f3465acf50ea67e8c6559c97b26762682469308564a631ee454f9a", - "sha256:e549dbf6cb9b328358deca1390e65dbdb07b69d80a06323162921975ee90ec00", - "sha256:edd3b77630e2bc52ba203c7d578837b9ed353d8d5b8d716c776a37fd0dfcc08b", - "sha256:f35f01d2fbb4bf07da35c44057ca334b014d728893b233afec8149341307ce35" - ], - "version": "==2.13" + "sha256:05519625ff4da7c2b60075e0489af2f3b08247fc4c24d83aa02e86d49095a632", + "sha256:064b8188d305247b674698837cb320685cbc897ab5da724468f267fc1281c3e9", + "sha256:0ee6a97a23a0f63882935d6082cc761bdf4a9fc2fe1a2989e6849efb46ee13fe", + "sha256:1788b54cce2308ee4360a1f15693d2d26adb44420b358b151162a2ceabfa0560", + "sha256:1c5b2b2aa1da6bbf7f9d3d19955d070d01ca935b43314ebeb10fce79fd35c5c5", + "sha256:2419ab6bbf7dd4edf26b114d22c3d46f77f3de27e2269079700519fb8ec0dccb", + "sha256:2b7dd490ac58dc9ef259e82e5b162eb8eacac03c817eae5744354e52372da509", + "sha256:360c700228b02d1afe6cc1b217c5f5f7b9624b2fc3ea65feeba51d8d7dd6f3f7", + "sha256:3d8ce6d67b349c3222586c861b8a1b42ee126af8464aeaccc521433fa4cdf5ca", + "sha256:3f21d31e18c7fbdb046eecebb67cd9d61549177e3e428df0dc2d56a85aeef43d", + "sha256:47f4a8879da46c4ebbce9021951a3c4e050bd2647fb53a943acc86a4828aed5a", + "sha256:4a3750337d6f44969447ec10385adca6f79e2bb0f41f774e5cae7e3b2c6cc6c1", + "sha256:4a42ca7f37d53eeb32359a056fc0ded0737cbee8b0948e93d12881afe80e585a", + "sha256:53f5c7d08f0bcf0b4954b2a82d35521162ebe4f44c8a2281b011334cafd8ed51", + "sha256:591c28d56031a82f5caa7403eada012273bdd0db43406bc5887819776e5cea49", + "sha256:6540aa58118405da6e3389b23998cf17c51c262933a9f627f7bf0c0e1e68e98a", + "sha256:6c1106a78a5d383ac0f0cfa3bb724dfc53e0096009e7cbd25bfc6e816f02d773", + "sha256:705fdcabd2f8417822644b8b84a6bbe440491b52487ec567d87f88645f455ae7", + "sha256:70855f34f05e9d66a5709297f2a704af9ffd5a28d8f13994e869a1c9e3554ed0", + "sha256:747bf84cc67109f6e074460eabc1a1beddbaf2eef84f4609628366e607f83321", + "sha256:756adf7e8635b10a8fe12ca83ff4633709223c9c72fad717b5f6ad1df991a185", + "sha256:7648211d7faaf1a847c01200e9a223597718e61d116e7be4da1be1a70a30fd4d", + "sha256:8c49130253308d0b508ec5f5b6686a1922a7ddc83b137114e3077627b20db920", + "sha256:905e25a64da2c09c82f2f29380db6bfc04662d46732e530f14a518a880825878", + "sha256:93121b4e31f0e6d5e17db14aebe5cfa773a8be13edc795e09864d50455d5edc5", + "sha256:95306df48334c9db6a9e8ceae3724d7c2d7e51e6da8eb5a677e03f505b4ceead", + "sha256:98a8f4c25a851b5c1bb2cb1f800df7212eb0916cc9f5e918cfad2e95261bb5c8", + "sha256:9dee4e1a01ca531ab1f402006a090dce44e9f493ccf6876ad4b71cf6a3a644fc", + "sha256:9e2487e45ea3d0bb7a707f0ccd6cfbc8e72cee96d20a06df04c293c33f7d34ac", + "sha256:9ee8bbbc622d3a5e33bf7f04a4cb6c9f18686bd017658d3f3072a8110ba9c5cc", + "sha256:ab8cc9c74cb5520bfc34656ec67896c2d1a00c9888436b703c99c4d65f098778", + "sha256:b18cf7facd51b3b9d5eb24298570ef7e6a34289ce8696286fcaa01011045bd33", + "sha256:b78fcb349f942b060733501a6aab4daa56918bd116c107827d5f20da9131d242", + "sha256:bb31bca50eae97a132860afbd70435ec4d7745108a79c791dcaab73765c69982", + "sha256:bf7bc6c46f2d0ec0eb7fc7cd26d626d6e452709402a831461e9c708caf157bf2", + "sha256:d5bfb2cb2d71882baf68042777b75b65853c37917ffbb64945c2427221120730", + "sha256:dab2a3939fc1922bfc3b8a6841aeaafe138677d302a6043686b1ebefff350121", + "sha256:dea9499cdfa23ba357496a4980429dab13d3b274232a96deb41261aad5f484cf", + "sha256:e3073da63069a74438de4c29585bcbd4dbfe8ddc9f64f7f9271f09249fb10523", + "sha256:ef7d2b1be26bd3b7f0cf81ad8210c987539e61f822b7aaab10c7420dc95b2953", + "sha256:f9c0bda7b129179b6b0046a4aa807902ecd4be5464eeb626efb2a7a34beafaff" + ], + "version": "==2.14" }, "shutilwhich": { "hashes": [ @@ -154,10 +172,10 @@ }, "skyfield": { "hashes": [ - "sha256:68316a9e151b32d9664fc0073436a2fbdeff1b12d5d81a4a2108480f1788ce35" + "sha256:a5b229bb9cd96ad42be1744d9f4ff1a56cc7ff755742f56d784a0bb84cb6c1b9" ], "index": "pypi", - "version": "==1.31" + "version": "==1.35" }, "tabulate": { "hashes": [ @@ -192,80 +210,81 @@ }, "babel": { "hashes": [ - "sha256:1aac2ae2d0d8ea368fa90906567f5c08463d98ade155c0c4bfedd6a0f7160e38", - "sha256:d670ea0b10f8b723672d3a6abeb87b565b244da220d76b4dba1b66269ec152d4" + "sha256:9d35c22fcc79893c3ecc85ac4a56cde1ecf3f19c540bba0922308a6c06ca6fa5", + "sha256:da031ab54472314f210b0adcff1588ee5d1d1d0ba4dbd07b94dba82bde791e05" ], "index": "pypi", - "version": "==2.8.0" + "version": "==2.9.0" }, "certifi": { "hashes": [ - "sha256:1f422849db327d534e3d0c5f02a263458c3955ec0aae4ff09b95f195c59f4edd", - "sha256:f05def092c44fbf25834a51509ef6e631dc19765ab8a57b4e7ab85531f0a9cf4" + "sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c", + "sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830" ], - "version": "==2020.11.8" + "version": "==2020.12.5" }, "chardet": { "hashes": [ - "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", - "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" - ], - "version": "==3.0.4" - }, - "click": { - "hashes": [ - "sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13", - "sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7" + "sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa", + "sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==7.0" - }, - "comlipy": { - "hashes": [ - "sha256:aa836b8ff7184661727f987def812f3d084e1599cbdd8076613d0dafc5264996", - "sha256:cc5253dd55f002f958cfab56dec7af714d42b8cfb0171a591157b1440c4d6878" - ], - "index": "pypi", - "version": "==1.2.1" + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", + "version": "==4.0.0" }, "coverage": { "hashes": [ - "sha256:0203acd33d2298e19b57451ebb0bed0ab0c602e5cf5a818591b4918b1f97d516", - "sha256:0f313707cdecd5cd3e217fc68c78a960b616604b559e9ea60cc16795c4304259", - "sha256:1c6703094c81fa55b816f5ae542c6ffc625fec769f22b053adb42ad712d086c9", - "sha256:1d44bb3a652fed01f1f2c10d5477956116e9b391320c94d36c6bf13b088a1097", - "sha256:280baa8ec489c4f542f8940f9c4c2181f0306a8ee1a54eceba071a449fb870a0", - "sha256:29a6272fec10623fcbe158fdf9abc7a5fa032048ac1d8631f14b50fbfc10d17f", - "sha256:2b31f46bf7b31e6aa690d4c7a3d51bb262438c6dcb0d528adde446531d0d3bb7", - "sha256:2d43af2be93ffbad25dd959899b5b809618a496926146ce98ee0b23683f8c51c", - "sha256:381ead10b9b9af5f64646cd27107fb27b614ee7040bb1226f9c07ba96625cbb5", - "sha256:47a11bdbd8ada9b7ee628596f9d97fbd3851bd9999d398e9436bd67376dbece7", - "sha256:4d6a42744139a7fa5b46a264874a781e8694bb32f1d76d8137b68138686f1729", - "sha256:50691e744714856f03a86df3e2bff847c2acede4c191f9a1da38f088df342978", - "sha256:530cc8aaf11cc2ac7430f3614b04645662ef20c348dce4167c22d99bec3480e9", - "sha256:582ddfbe712025448206a5bc45855d16c2e491c2dd102ee9a2841418ac1c629f", - "sha256:63808c30b41f3bbf65e29f7280bf793c79f54fb807057de7e5238ffc7cc4d7b9", - "sha256:71b69bd716698fa62cd97137d6f2fdf49f534decb23a2c6fc80813e8b7be6822", - "sha256:7858847f2d84bf6e64c7f66498e851c54de8ea06a6f96a32a1d192d846734418", - "sha256:78e93cc3571fd928a39c0b26767c986188a4118edc67bc0695bc7a284da22e82", - "sha256:7f43286f13d91a34fadf61ae252a51a130223c52bfefb50310d5b2deb062cf0f", - "sha256:86e9f8cd4b0cdd57b4ae71a9c186717daa4c5a99f3238a8723f416256e0b064d", - "sha256:8f264ba2701b8c9f815b272ad568d555ef98dfe1576802ab3149c3629a9f2221", - "sha256:9342dd70a1e151684727c9c91ea003b2fb33523bf19385d4554f7897ca0141d4", - "sha256:9361de40701666b034c59ad9e317bae95c973b9ff92513dd0eced11c6adf2e21", - "sha256:9669179786254a2e7e57f0ecf224e978471491d660aaca833f845b72a2df3709", - "sha256:aac1ba0a253e17889550ddb1b60a2063f7474155465577caa2a3b131224cfd54", - "sha256:aef72eae10b5e3116bac6957de1df4d75909fc76d1499a53fb6387434b6bcd8d", - "sha256:bd3166bb3b111e76a4f8e2980fa1addf2920a4ca9b2b8ca36a3bc3dedc618270", - "sha256:c1b78fb9700fc961f53386ad2fd86d87091e06ede5d118b8a50dea285a071c24", - "sha256:c3888a051226e676e383de03bf49eb633cd39fc829516e5334e69b8d81aae751", - "sha256:c5f17ad25d2c1286436761b462e22b5020d83316f8e8fcb5deb2b3151f8f1d3a", - "sha256:c851b35fc078389bc16b915a0a7c1d5923e12e2c5aeec58c52f4aa8085ac8237", - "sha256:cb7df71de0af56000115eafd000b867d1261f786b5eebd88a0ca6360cccfaca7", - "sha256:cedb2f9e1f990918ea061f28a0f0077a07702e3819602d3507e2ff98c8d20636", - "sha256:e8caf961e1b1a945db76f1b5fa9c91498d15f545ac0ababbe575cfab185d3bd8" - ], - "version": "==5.1" + "sha256:08b3ba72bd981531fd557f67beee376d6700fba183b167857038997ba30dd297", + "sha256:2757fa64e11ec12220968f65d086b7a29b6583d16e9a544c889b22ba98555ef1", + "sha256:3102bb2c206700a7d28181dbe04d66b30780cde1d1c02c5f3c165cf3d2489497", + "sha256:3498b27d8236057def41de3585f317abae235dd3a11d33e01736ffedb2ef8606", + "sha256:378ac77af41350a8c6b8801a66021b52da8a05fd77e578b7380e876c0ce4f528", + "sha256:38f16b1317b8dd82df67ed5daa5f5e7c959e46579840d77a67a4ceb9cef0a50b", + "sha256:3911c2ef96e5ddc748a3c8b4702c61986628bb719b8378bf1e4a6184bbd48fe4", + "sha256:3a3c3f8863255f3c31db3889f8055989527173ef6192a283eb6f4db3c579d830", + "sha256:3b14b1da110ea50c8bcbadc3b82c3933974dbeea1832e814aab93ca1163cd4c1", + "sha256:535dc1e6e68fad5355f9984d5637c33badbdc987b0c0d303ee95a6c979c9516f", + "sha256:6f61319e33222591f885c598e3e24f6a4be3533c1d70c19e0dc59e83a71ce27d", + "sha256:723d22d324e7997a651478e9c5a3120a0ecbc9a7e94071f7e1954562a8806cf3", + "sha256:76b2775dda7e78680d688daabcb485dc87cf5e3184a0b3e012e1d40e38527cc8", + "sha256:782a5c7df9f91979a7a21792e09b34a658058896628217ae6362088b123c8500", + "sha256:7e4d159021c2029b958b2363abec4a11db0ce8cd43abb0d9ce44284cb97217e7", + "sha256:8dacc4073c359f40fcf73aede8428c35f84639baad7e1b46fce5ab7a8a7be4bb", + "sha256:8f33d1156241c43755137288dea619105477961cfa7e47f48dbf96bc2c30720b", + "sha256:8ffd4b204d7de77b5dd558cdff986a8274796a1e57813ed005b33fd97e29f059", + "sha256:93a280c9eb736a0dcca19296f3c30c720cb41a71b1f9e617f341f0a8e791a69b", + "sha256:9a4f66259bdd6964d8cf26142733c81fb562252db74ea367d9beb4f815478e72", + "sha256:9a9d4ff06804920388aab69c5ea8a77525cf165356db70131616acd269e19b36", + "sha256:a2070c5affdb3a5e751f24208c5c4f3d5f008fa04d28731416e023c93b275277", + "sha256:a4857f7e2bc6921dbd487c5c88b84f5633de3e7d416c4dc0bb70256775551a6c", + "sha256:a607ae05b6c96057ba86c811d9c43423f35e03874ffb03fbdcd45e0637e8b631", + "sha256:a66ca3bdf21c653e47f726ca57f46ba7fc1f260ad99ba783acc3e58e3ebdb9ff", + "sha256:ab110c48bc3d97b4d19af41865e14531f300b482da21783fdaacd159251890e8", + "sha256:b239711e774c8eb910e9b1ac719f02f5ae4bf35fa0420f438cdc3a7e4e7dd6ec", + "sha256:be0416074d7f253865bb67630cf7210cbc14eb05f4099cc0f82430135aaa7a3b", + "sha256:c46643970dff9f5c976c6512fd35768c4a3819f01f61169d8cdac3f9290903b7", + "sha256:c5ec71fd4a43b6d84ddb88c1df94572479d9a26ef3f150cef3dacefecf888105", + "sha256:c6e5174f8ca585755988bc278c8bb5d02d9dc2e971591ef4a1baabdf2d99589b", + "sha256:c89b558f8a9a5a6f2cfc923c304d49f0ce629c3bd85cb442ca258ec20366394c", + "sha256:cc44e3545d908ecf3e5773266c487ad1877be718d9dc65fc7eb6e7d14960985b", + "sha256:cc6f8246e74dd210d7e2b56c76ceaba1cc52b025cd75dbe96eb48791e0250e98", + "sha256:cd556c79ad665faeae28020a0ab3bda6cd47d94bec48e36970719b0b86e4dcf4", + "sha256:ce6f3a147b4b1a8b09aae48517ae91139b1b010c5f36423fa2b866a8b23df879", + "sha256:ceb499d2b3d1d7b7ba23abe8bf26df5f06ba8c71127f188333dddcf356b4b63f", + "sha256:cef06fb382557f66d81d804230c11ab292d94b840b3cb7bf4450778377b592f4", + "sha256:e448f56cfeae7b1b3b5bcd99bb377cde7c4eb1970a525c770720a352bc4c8044", + "sha256:e52d3d95df81c8f6b2a1685aabffadf2d2d9ad97203a40f8d61e51b70f191e4e", + "sha256:ee2f1d1c223c3d2c24e3afbb2dd38be3f03b1a8d6a83ee3d9eb8c36a52bee899", + "sha256:f2c6888eada180814b8583c3e793f3f343a692fc802546eed45f40a001b1169f", + "sha256:f51dbba78d68a44e99d484ca8c8f604f17e957c1ca09c3ebc2c7e3bbd9ba0448", + "sha256:f54de00baf200b4539a5a092a759f000b5f45fd226d6d25a76b0dff71177a714", + "sha256:fa10fee7e32213f5c7b0d6428ea92e3a3fdd6d725590238a3f92c0de1c78b9d2", + "sha256:fabeeb121735d47d8eab8671b6b031ce08514c86b7ad8f7d5490a7b6dcd6267d", + "sha256:fac3c432851038b3e6afe086f777732bcf7f6ebbfd90951fa04ee53db6d0bcdd", + "sha256:fda29412a66099af6d6de0baa6bd7c52674de177ec2ad2630ca264142d69c6c7", + "sha256:ff1330e8bc996570221b450e2d539134baa9465f5cb98aff0e0f73f34172e0ae" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4.0'", + "version": "==5.3.1" }, "coveralls": { "hashes": [ @@ -291,11 +310,11 @@ }, "isort": { "hashes": [ - "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1", - "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd" + "sha256:c729845434366216d320e936b8ad6f9d681aab72dc7cbc2d51bedc3582f3ad1e", + "sha256:fff4f0c04e1825522ce6949973e83110a6e907750cd92d128b0d14aaaadbffdc" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==4.3.21" + "markers": "python_version >= '3.6' and python_version < '4.0'", + "version": "==5.7.0" }, "lazy-object-proxy": { "hashes": [ @@ -333,49 +352,33 @@ }, "pylint": { "hashes": [ - "sha256:7dd78437f2d8d019717dbf287772d0b2dbdfd13fc016aa7faa08d67bccc46adc", - "sha256:d0ece7d223fe422088b0e8f13fa0a1e8eb745ebffcb8ed53d3e95394b6101a1c" + "sha256:bb4a908c9dadbc3aac18860550e870f58e1a02c9f2c204fdf5693d73be061210", + "sha256:bfe68f020f8a0fece830a22dd4d5dddb4ecc6137db04face4c3420a46a52239f" ], "index": "pypi", - "version": "==2.5.3" + "version": "==2.6.0" }, "pylintfileheader": { "hashes": [ - "sha256:1e404d21142ef1f38610b57f8bbdae3856442880212f189a8a296cff02793087", - "sha256:dbcd7c504afea2a909a0bf3a5dfff1931645297de27c032296b432f5347bd7f5" + "sha256:7871193691484210268d467dc12d88ac5b3ba7eb7dec6239e24075797185a3b2", + "sha256:a23f143b0fb4d65f984ffd824731d6e41f2840e26a5752a90df93f4454b5ccd1" ], "index": "pypi", - "version": "==0.1.0" + "version": "==0.3.0" }, "pytz": { "hashes": [ - "sha256:3e6b7dd2d1e0a59084bcee14a17af60c5c562cdc16d828e8eba2e683d3a7e268", - "sha256:5c55e189b682d420be27c6995ba6edce0c0a77dd67bfbe2ae6607134d5851ffd" + "sha256:16962c5fb8db4a8f63a26646d8886e9d769b6c511543557bc84e9569fb9a9cb4", + "sha256:180befebb1927b16f6b57101720075a984c019ac16b1b7575673bea42c6c3da5" ], - "version": "==2020.4" - }, - "pyyaml": { - "hashes": [ - "sha256:059b2ee3194d718896c0ad077dd8c043e5e909d9180f387ce42012662a4946d6", - "sha256:1cf708e2ac57f3aabc87405f04b86354f66799c8e62c28c5fc5f88b5521b2dbf", - "sha256:24521fa2890642614558b492b473bee0ac1f8057a7263156b02e8b14c88ce6f5", - "sha256:4fee71aa5bc6ed9d5f116327c04273e25ae31a3020386916905767ec4fc5317e", - "sha256:70024e02197337533eef7b85b068212420f950319cc8c580261963aefc75f811", - "sha256:74782fbd4d4f87ff04159e986886931456a1894c61229be9eaf4de6f6e44b99e", - "sha256:940532b111b1952befd7db542c370887a8611660d2b9becff75d39355303d82d", - "sha256:cb1f2f5e426dc9f07a7681419fe39cee823bb74f723f36f70399123f439e9b20", - "sha256:dbbb2379c19ed6042e8f11f2a2c66d39cceb8aeace421bfc29d085d93eda3689", - "sha256:e3a057b7a64f1222b56e47bcff5e4b94c4f61faac04c7c4ecb1985e18caa3994", - "sha256:e9f45bd5b92c7974e59bcd2dcc8631a6b6cc380a904725fce7bc08872e691615" - ], - "version": "==5.3" + "version": "==2020.5" }, "requests": { "hashes": [ - "sha256:7f1a0b932f4a60a1a65caa4263921bb7d9ee911957e0ae4a23a6dd08185ad5f8", - "sha256:e786fa28d8c9154e6a4de5d46a1d921b8749f8b74e28bde23768e5e16eece998" + "sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804", + "sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e" ], - "version": "==2.25.0" + "version": "==2.25.1" }, "six": { "hashes": [ @@ -390,6 +393,7 @@ "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" }, "unittest-data-provider": { @@ -404,6 +408,7 @@ "sha256:19188f96923873c92ccb987120ec4acaa12f0461fa9ce5d3d0772bc965a39e08", "sha256:d8ff90d979214d7b4f8ce956e80f4028fc6860e4431f731ea4a8c08f23f99473" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4.0'", "version": "==1.26.2" }, "wrapt": { diff --git a/README.md b/README.md index ea908e6..0a7bf3d 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,10 @@ # ![Kosmorro](kosmorrolib/assets/png/kosmorro-logo.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) -## About the project - -Kosmorro is a software that allows you to compute the ephemeris for a date, a month or a year. +A program that calculates your astronomical ephemerides! ## Installation -### Requirements - -Kosmorro requires the following software to work: - -- Python ≥ 3.5.0 -- PIP - ### Production environment Keep in mind that Kosmorro is still in alpha development stage and is not considered as stable. @@ -32,7 +23,7 @@ First, install `python-pip` on your system and invoke the following command: `pi #### macOS Currently, macOS does not provide Python 3, so you will first have to install it. -If you don't have it, first install [HomeBrew](https://formulae.brew.sh), then install Python 3: `brew install python`. +If you don't have it, install [HomeBrew](https://formulae.brew.sh), then install Python 3: `brew install python`. This will install Python 3 and its PIP on your system. Note that their executables are called `python3` and `pip3`. Now, you can install Kosmorro with your PIP: `pip3 install kosmorro`. @@ -43,7 +34,11 @@ Kosmorro being at an early-stage development, Windows is not supported officiall ### Development environment -First, install [Pipenv](https://pypi.org/project/pipenv/). +Before you run Kosmorro in your development environment, check you have installed these programs on your system: + +- Python ≥ 3.7.0 (needed run Kosmorro) +- PIP3 (needed for package management, usually installed among with Python 3) +- [Pipenv](https://pypi.org/project/pipenv/) (needed to manage the virtual environment) Clone this repository and run `pipenv sync` to install all the dependencies. Then, run Kosmorro by invoking `pipenv run python kosmorro`. @@ -63,17 +58,13 @@ 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, please check these packages are installed: +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: -- **A LaTeX distribution:** - - Linux: install TeXLive through your packages manager. Kosmorro just needs the minimal installation, you don't need any extension. - - macOS: install [MacTeX](https://www.tug.org/mactex/), the basic version will suffice: - - from the official website, choose the _smaller download_ - - with Brew: `brew install basictex` -- **The `latex` Python library:** - - Arch Linux: the library is available [on the AUR](https://aur.archlinux.org/packages/python-latex) - - Any other systems: install it through PyPI: `pip install latex` +- **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. -The first time you ask Kosmorro to create a PDF, it may be a little verbose. You can ignore its blahblah. - diff --git a/config-comlipy.yml b/config-comlipy.yml index 90a1a44..f58b18c 100644 --- a/config-comlipy.yml +++ b/config-comlipy.yml @@ -6,7 +6,7 @@ rules: applicable: always value: 0 level: 1 - header-max-length: + header-max-length: applicable: always value: 120 level: 2 @@ -14,4 +14,5 @@ rules: value: lower-case scope-empty: level: 0 - + subject-case: + level: 0 diff --git a/kosmorrolib/core.py b/kosmorrolib/core.py index 517d919..36989b5 100644 --- a/kosmorrolib/core.py +++ b/kosmorrolib/core.py @@ -98,7 +98,8 @@ def get_date(date_arg: str) -> date: try: return date.fromisoformat(date_arg) except ValueError as error: - raise ValueError(_('The date {date} is not valid: {error}').format(date=date_arg, error=error.args[0])) + raise ValueError(_('The date {date} is not valid: {error}').format(date=date_arg, + error=error.args[0])) from error elif re.match(r'^([+-])(([0-9]+)y)?[ ]?(([0-9]+)m)?[ ]?(([0-9]+)d)?$', date_arg): def get_offset(date_arg: str, signifier: str): if re.search(r'([0-9]+)' + signifier, date_arg): diff --git a/kosmorrolib/dumper.py b/kosmorrolib/dumper.py index e64822d..e12d558 100644 --- a/kosmorrolib/dumper.py +++ b/kosmorrolib/dumper.py @@ -20,6 +20,9 @@ from abc import ABC, abstractmethod import datetime import json import os +import tempfile +import subprocess +import shutil from pathlib import Path from tabulate import tabulate from termcolor import colored @@ -27,11 +30,7 @@ from termcolor import colored from .data import ASTERS, AsterEphemerides, MoonPhase, Event from .i18n import _, FULL_DATE_FORMAT, SHORT_DATETIME_FORMAT, TIME_FORMAT from .version import VERSION -from .exceptions import UnavailableFeatureError -try: - from latex import build_pdf -except ImportError: - build_pdf = None +from .exceptions import UnavailableFeatureError, CompileError class Dumper(ABC): @@ -346,10 +345,12 @@ class PdfDumper(Dumper): date=self.date, timezone=self.timezone, with_colors=self.with_colors, show_graph=self.show_graph) return self._compile(latex_dumper.to_string()) - except RuntimeError: + except CompileError as error: + raise UnavailableFeatureError from error + except RuntimeError as error: raise UnavailableFeatureError(_("Building PDFs was not possible, because some dependencies are not" " installed.\nPlease look at the documentation at http://kosmorro.space " - "for more information.")) + "for more information.")) from error @staticmethod def is_file_output_needed() -> bool: @@ -357,9 +358,28 @@ class PdfDumper(Dumper): @staticmethod def _compile(latex_input) -> bytes: - if build_pdf is None: - raise RuntimeError('Python latex module not found') - - package = str(Path(__file__).parent.absolute()) + '/assets/pdf/' - - return bytes(build_pdf(latex_input, [package])) + package = str(Path(__file__).parent.absolute()) + '/assets/pdf/kosmorro.sty' + + with tempfile.TemporaryDirectory() as tempdir: + timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S') + shutil.copy(package, tempdir) + + with open('%s/%s.tex' % (tempdir, timestamp), 'w') as texfile: + texfile.write(latex_input) + + os.chdir(tempdir) + 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) + + raise CompileError(_('An error occured 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 + + with open('%s.pdf' % timestamp, 'rb') as pdffile: + return bytes(pdffile.read()) diff --git a/kosmorrolib/ephemerides.py b/kosmorrolib/ephemerides.py index b8dd213..2ddc578 100644 --- a/kosmorrolib/ephemerides.py +++ b/kosmorrolib/ephemerides.py @@ -97,7 +97,7 @@ def get_moon_phase(compute_date: datetime.date, timezone: int = 0) -> MoonPhase: start = datetime.date(start.year, start.month, start.day) + datetime.timedelta(days=12) end = datetime.date(end.year, end.month, end.day) - datetime.timedelta(days=12) - raise OutOfRangeDateError(start, end) + raise OutOfRangeDateError(start, end) from error return _get_skyfield_to_moon_phase(times, phase, today) @@ -158,6 +158,6 @@ def get_ephemerides(date: datetime.date, position: Position, timezone: int = 0) start = datetime.date(start.year, start.month, start.day + 1) end = datetime.date(end.year, end.month, end.day - 1) - raise OutOfRangeDateError(start, end) + raise OutOfRangeDateError(start, end) from error return ephemerides diff --git a/kosmorrolib/events.py b/kosmorrolib/events.py index 9bbd23f..661246f 100644 --- a/kosmorrolib/events.py +++ b/kosmorrolib/events.py @@ -196,4 +196,4 @@ def search_events(date: date_type, timezone: int = 0) -> [Event]: start_date = date_type(start_date.year, start_date.month, start_date.day) end_date = date_type(end_date.year, end_date.month, end_date.day) - raise OutOfRangeDateError(start_date, end_date) + raise OutOfRangeDateError(start_date, end_date) from error diff --git a/kosmorrolib/exceptions.py b/kosmorrolib/exceptions.py index 9467d38..de64af2 100644 --- a/kosmorrolib/exceptions.py +++ b/kosmorrolib/exceptions.py @@ -22,15 +22,21 @@ from .i18n import _, SHORT_DATE_FORMAT class UnavailableFeatureError(RuntimeError): def __init__(self, msg: str): - super(UnavailableFeatureError, self).__init__() + super().__init__() self.msg = msg class OutOfRangeDateError(RuntimeError): def __init__(self, min_date: date, max_date: date): - super(OutOfRangeDateError, self).__init__() + super().__init__() self.min_date = min_date self.max_date = max_date self.msg = _('The date must be between {minimum_date}' ' and {maximum_date}').format(minimum_date=min_date.strftime(SHORT_DATE_FORMAT), maximum_date=max_date.strftime(SHORT_DATE_FORMAT)) + + +class CompileError(RuntimeError): + def __init__(self, msg): + super().__init__() + self.msg = msg diff --git a/kosmorrolib/locales/messages.pot b/kosmorrolib/locales/messages.pot index 8858aac..2024237 100644 --- a/kosmorrolib/locales/messages.pot +++ b/kosmorrolib/locales/messages.pot @@ -1,27 +1,27 @@ # Translations template for kosmorro. -# Copyright (C) 2020 ORGANIZATION +# Copyright (C) 2021 ORGANIZATION # This file is distributed under the same license as the kosmorro project. -# FIRST AUTHOR , 2020. +# FIRST AUTHOR , 2021. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: kosmorro 0.8.1\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2020-12-02 10:22+0100\n" +"POT-Creation-Date: 2021-01-15 10:36+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.8.0\n" +"Generated-By: Babel 2.9.0\n" #: kosmorrolib/core.py:101 msgid "The date {date} is not valid: {error}" msgstr "" -#: kosmorrolib/core.py:117 +#: kosmorrolib/core.py:118 msgid "" "The date {date} does not match the required YYYY-MM-DD format or the " "offset format." @@ -67,76 +67,76 @@ msgstr "" msgid "Pluto" msgstr "" -#: kosmorrolib/dumper.py:88 +#: kosmorrolib/dumper.py:87 msgid "Expected events:" msgstr "" -#: kosmorrolib/dumper.py:92 +#: kosmorrolib/dumper.py:91 msgid "Note: All the hours are given in UTC." msgstr "" -#: kosmorrolib/dumper.py:97 +#: kosmorrolib/dumper.py:96 msgid "Note: All the hours are given in the UTC{offset} timezone." msgstr "" -#: kosmorrolib/dumper.py:143 kosmorrolib/dumper.py:227 +#: kosmorrolib/dumper.py:142 kosmorrolib/dumper.py:226 msgid "Object" msgstr "" -#: kosmorrolib/dumper.py:144 kosmorrolib/dumper.py:228 +#: kosmorrolib/dumper.py:143 kosmorrolib/dumper.py:227 msgid "Rise time" msgstr "" -#: kosmorrolib/dumper.py:145 kosmorrolib/dumper.py:229 +#: kosmorrolib/dumper.py:144 kosmorrolib/dumper.py:228 msgid "Culmination time" msgstr "" -#: kosmorrolib/dumper.py:146 kosmorrolib/dumper.py:230 +#: kosmorrolib/dumper.py:145 kosmorrolib/dumper.py:229 msgid "Set time" msgstr "" -#: kosmorrolib/dumper.py:161 +#: kosmorrolib/dumper.py:160 msgid "Moon phase is unavailable for this date." msgstr "" -#: kosmorrolib/dumper.py:163 kosmorrolib/dumper.py:234 +#: kosmorrolib/dumper.py:162 kosmorrolib/dumper.py:233 msgid "Moon phase:" msgstr "" -#: kosmorrolib/dumper.py:164 +#: kosmorrolib/dumper.py:163 msgid "{next_moon_phase} on {next_moon_phase_date} at {next_moon_phase_time}" msgstr "" -#: kosmorrolib/dumper.py:214 +#: kosmorrolib/dumper.py:213 msgid "A Summary of your Sky" msgstr "" -#: kosmorrolib/dumper.py:218 +#: kosmorrolib/dumper.py:217 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 "" -#: kosmorrolib/dumper.py:224 +#: kosmorrolib/dumper.py:223 msgid "" "Don't forget to check the weather forecast before you go out with your " "equipment." msgstr "" -#: kosmorrolib/dumper.py:226 +#: kosmorrolib/dumper.py:225 msgid "Ephemerides of the day" msgstr "" -#: kosmorrolib/dumper.py:232 +#: kosmorrolib/dumper.py:231 msgid "hours" msgstr "" -#: kosmorrolib/dumper.py:236 +#: kosmorrolib/dumper.py:235 msgid "Expected events" msgstr "" -#: kosmorrolib/dumper.py:350 +#: kosmorrolib/dumper.py:351 msgid "" "Building PDFs was not possible, because some dependencies are not " "installed.\n" @@ -144,6 +144,14 @@ msgid "" "information." msgstr "" +#: kosmorrolib/dumper.py:380 +#, python-format +msgid "" +"An error occured 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" +msgstr "" + #: kosmorrolib/enum.py:24 msgid "New Moon" msgstr "" @@ -239,91 +247,91 @@ msgid "" "the observation coordinate." msgstr "" -#: kosmorrolib/main.py:90 +#: kosmorrolib/main.py:93 msgid "Could not save the output in \"{path}\": {error}" msgstr "" -#: kosmorrolib/main.py:95 +#: kosmorrolib/main.py:100 msgid "Selected output format needs an output file (--output)." msgstr "" -#: kosmorrolib/main.py:112 +#: kosmorrolib/main.py:117 msgid "Moon phase can only be displayed between {min_date} and {max_date}" msgstr "" -#: kosmorrolib/main.py:134 +#: kosmorrolib/main.py:139 msgid "Running on Python {python_version}" msgstr "" -#: kosmorrolib/main.py:140 +#: kosmorrolib/main.py:145 msgid "Do you really want to clear Kosmorro's cache? [yN] " msgstr "" -#: kosmorrolib/main.py:147 +#: kosmorrolib/main.py:152 msgid "Answer did not match expected options, cache not cleared." msgstr "" -#: kosmorrolib/main.py:156 +#: kosmorrolib/main.py:161 msgid "" "Compute the ephemerides and the events for a given date, at a given " "position on Earth." msgstr "" -#: kosmorrolib/main.py:158 +#: kosmorrolib/main.py:163 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 "" -#: kosmorrolib/main.py:163 +#: kosmorrolib/main.py:168 msgid "Show the program version" msgstr "" -#: kosmorrolib/main.py:165 +#: kosmorrolib/main.py:170 msgid "Delete all the files Kosmorro stored in the cache." msgstr "" -#: kosmorrolib/main.py:167 +#: kosmorrolib/main.py:172 msgid "The format under which the information have to be output" msgstr "" -#: kosmorrolib/main.py:169 +#: kosmorrolib/main.py:174 msgid "" "The observer's latitude on Earth. Can also be set in the " "KOSMORRO_LATITUDE environment variable." msgstr "" -#: kosmorrolib/main.py:172 +#: kosmorrolib/main.py:177 msgid "" "The observer's longitude on Earth. Can also be set in the " "KOSMORRO_LONGITUDE environment variable." msgstr "" -#: kosmorrolib/main.py:175 +#: kosmorrolib/main.py:180 msgid "" "The date for which the ephemerides must be computed (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 ({default_date})" msgstr "" -#: kosmorrolib/main.py:180 +#: kosmorrolib/main.py:185 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 "" -#: kosmorrolib/main.py:183 +#: kosmorrolib/main.py:188 msgid "Disable the colors in the console." msgstr "" -#: kosmorrolib/main.py:185 +#: kosmorrolib/main.py:190 msgid "" "A file to export the output to. If not given, the standard output is " "used. This argument is needed for PDF format." msgstr "" -#: kosmorrolib/main.py:188 +#: kosmorrolib/main.py:193 msgid "" "Do not generate a graph to represent the rise and set times in the PDF " "format." diff --git a/kosmorrolib/main.py b/kosmorrolib/main.py index 5cfa960..c971ffe 100644 --- a/kosmorrolib/main.py +++ b/kosmorrolib/main.py @@ -86,9 +86,14 @@ def main(): try: with open(args.output, 'wb') as output_file: output_file.write(output.to_string()) + except UnavailableFeatureError as error: + print(colored(error.msg, 'red')) + return 2 except OSError as error: - print(_('Could not save the output in "{path}": {error}').format(path=args.output, - error=error.strerror)) + print(colored(_('Could not save the output in "{path}": {error}').format(path=args.output, + error=error.strerror), + 'red')) + return 3 elif not output.is_file_output_needed(): print(output) else: