From 781832568110c8d52e5ca8cfb0b81d4b53016554 Mon Sep 17 00:00:00 2001 From: Nora-Olivia-Ammann <103038637+Nora-Olivia-Ammann@users.noreply.github.com> Date: Tue, 19 Mar 2024 10:52:18 +0100 Subject: [PATCH] feat: save warnings and errors in second file with loguru (DEV-3406) (#883) --- .gitignore | 1 + poetry.lock | 183 +++++++++++------- pyproject.toml | 1 + src/dsp_tools/cli/call_action.py | 5 +- src/dsp_tools/cli/entry_point.py | 8 +- .../commands/excel2xml/excel2xml_cli.py | 3 +- src/dsp_tools/commands/id2iri.py | 4 +- .../ingest_xmlupload/apply_ingest_id.py | 4 +- .../commands/ingest_xmlupload/upload_xml.py | 4 +- .../commands/project/create/project_create.py | 48 +++-- .../project/create/project_create_lists.py | 11 +- .../resume_xmlupload/resume_xmlupload.py | 4 +- src/dsp_tools/commands/start_stack.py | 4 +- src/dsp_tools/commands/xmlupload/ark2iri.py | 3 - .../commands/xmlupload/list_client.py | 5 +- .../commands/xmlupload/ontology_client.py | 3 - .../commands/xmlupload/project_client.py | 3 - .../xmlupload/read_validate_xml_file.py | 4 +- .../xmlupload/resource_create_client.py | 5 +- .../commands/xmlupload/resource_multimedia.py | 7 +- .../stash/stash_circular_references.py | 3 - .../stash/upload_stashed_resptr_props.py | 7 +- .../stash/upload_stashed_xml_texts.py | 9 +- .../commands/xmlupload/upload_config.py | 5 +- .../xmlupload/write_diagnostic_info.py | 5 +- src/dsp_tools/commands/xmlupload/xmlupload.py | 21 +- src/dsp_tools/utils/connection_live.py | 14 +- src/dsp_tools/utils/create_logger.py | 83 -------- src/dsp_tools/utils/logger_config.py | 42 ++++ src/dsp_tools/utils/shared.py | 3 - src/dsp_tools/utils/xml_utils.py | 6 +- src/dsp_tools/utils/xml_validation.py | 6 +- 32 files changed, 233 insertions(+), 281 deletions(-) delete mode 100644 src/dsp_tools/utils/create_logger.py create mode 100644 src/dsp_tools/utils/logger_config.py diff --git a/.gitignore b/.gitignore index 7c0f4e581..6357ce035 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,4 @@ testdata/preprocessed_files/ testdata/bitstreams/nested processing_result_*.pkl processed_files.txt +/warnings-*.log diff --git a/poetry.lock b/poetry.lock index 46e54e5c2..0004ed00f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -380,6 +380,24 @@ files = [ [package.dependencies] referencing = ">=0.31.0" +[[package]] +name = "loguru" +version = "0.7.2" +description = "Python logging made (stupidly) simple" +optional = false +python-versions = ">=3.5" +files = [ + {file = "loguru-0.7.2-py3-none-any.whl", hash = "sha256:003d71e3d3ed35f0f8984898359d65b79e5b21943f78af86aa5491210429b8eb"}, + {file = "loguru-0.7.2.tar.gz", hash = "sha256:e671a53522515f34fd406340ee968cb9ecafbc4b36c679da03c18fd8d0bd51ac"}, +] + +[package.dependencies] +colorama = {version = ">=0.3.4", markers = "sys_platform == \"win32\""} +win32-setctime = {version = ">=1.0.0", markers = "sys_platform == \"win32\""} + +[package.extras] +dev = ["Sphinx (==7.2.5)", "colorama (==0.4.5)", "colorama (==0.4.6)", "exceptiongroup (==1.1.3)", "freezegun (==1.1.0)", "freezegun (==1.2.2)", "mypy (==v0.910)", "mypy (==v0.971)", "mypy (==v1.4.1)", "mypy (==v1.5.1)", "pre-commit (==3.4.0)", "pytest (==6.1.2)", "pytest (==7.4.0)", "pytest-cov (==2.12.1)", "pytest-cov (==4.1.0)", "pytest-mypy-plugins (==1.9.3)", "pytest-mypy-plugins (==3.0.0)", "sphinx-autobuild (==2021.3.14)", "sphinx-rtd-theme (==1.3.0)", "tox (==3.27.1)", "tox (==4.11.0)"] + [[package]] name = "lxml" version = "5.1.0" @@ -475,13 +493,13 @@ source = ["Cython (>=3.0.7)"] [[package]] name = "markdown" -version = "3.5.2" +version = "3.6" description = "Python implementation of John Gruber's Markdown." optional = false python-versions = ">=3.8" files = [ - {file = "Markdown-3.5.2-py3-none-any.whl", hash = "sha256:d43323865d89fc0cb9b20c75fc8ad313af307cc087e84b657d9eec768eddeadd"}, - {file = "Markdown-3.5.2.tar.gz", hash = "sha256:e1ac7b3dc550ee80e602e71c1d168002f062e49f1b11e26a36264dafd4df2ef8"}, + {file = "Markdown-3.6-py3-none-any.whl", hash = "sha256:48f276f4d8cfb8ce6527c8f79e2ee29708508bf4d40aa410fbc3b4ee832c850f"}, + {file = "Markdown-3.6.tar.gz", hash = "sha256:ed4f41f6daecbeeb96e576ce414c41d2d876daa9a16cb35fa8ed8c2ddfad0224"}, ] [package.extras] @@ -1224,6 +1242,7 @@ files = [ {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, + {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, @@ -1231,8 +1250,16 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, + {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, + {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, + {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, + {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, @@ -1249,6 +1276,7 @@ files = [ {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, + {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, @@ -1256,6 +1284,7 @@ files = [ {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, + {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, @@ -1549,72 +1578,72 @@ files = [ [[package]] name = "rustworkx" -version = "0.14.1" +version = "0.14.2" description = "A python graph library implemented in Rust" optional = false python-versions = ">=3.8" files = [ - {file = "rustworkx-0.14.1-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:c612b9723f8d5236f6b88eba3f5cfeea45accc1f57436ed065a8251c25e4169b"}, - {file = "rustworkx-0.14.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:13c88ad0ecb7f697642125a10d9296430bddf45827e0b81e964d8417a8e1d568"}, - {file = "rustworkx-0.14.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:3b2f7cb51358a3fcba93a44e5a4416902875cbadc710fb644c27367b452f883a"}, - {file = "rustworkx-0.14.1-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c46d3033055c6f61444341513832b639e5d371eb98f4ea4364e877f349f68698"}, - {file = "rustworkx-0.14.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:525552c4ca807b6bdeea10c4dd95791081bb8df859f48c2798925f270f565d8e"}, - {file = "rustworkx-0.14.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:841c351f8cc40d9fb15120292132f034d4aaadfdb5be1c9e856876a2731099b8"}, - {file = "rustworkx-0.14.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f071abf97ac01f5fddf6a63eff7b2ba1ed0b3f645798e8fc9ddb0544212f3b45"}, - {file = "rustworkx-0.14.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:461a02f7e72a344ab8f8bddf7f8b25262380cd333bb9fa6bbc237cbc1fa7f6eb"}, - {file = "rustworkx-0.14.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:7c4a6980a6134662982b54d1e97556487f1d56f8a3c6afd3c51efb17e4547182"}, - {file = "rustworkx-0.14.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:1a693567af0eeb6b8e43d15b0d069e29651cfb57fb5acca6e89bbf92b5fd20b8"}, - {file = "rustworkx-0.14.1-cp310-cp310-win32.whl", hash = "sha256:2327f3ca16bdab015675b805e22ef20b8db164269052f928038cd15b5e013001"}, - {file = "rustworkx-0.14.1-cp310-cp310-win_amd64.whl", hash = "sha256:72bd0421fbfb7fe58794f5753cc99906c7dddda9d44682ad25854ee831ecb55e"}, - {file = "rustworkx-0.14.1-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:d675bf6ce684fab98415768f19a20f62bfa8ba84ec8e84eca53976e910413cde"}, - {file = "rustworkx-0.14.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:7abcd7756c25f9e4090534ac5ce29737c827d4fba5f86e854458aed730616d97"}, - {file = "rustworkx-0.14.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3c68458d0604efef18dbde527da76f4628db8d5dfb2986aa8f96913f7ab366e4"}, - {file = "rustworkx-0.14.1-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7429a1887aba1a51975a9729c4bbdef217501a4418666ab5128249140c0ac33b"}, - {file = "rustworkx-0.14.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4fb3b55cd6a811359714aaba34a0850aaf5c51ac9343becb3d160b6ec6e9b714"}, - {file = "rustworkx-0.14.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dc131a5d4c73e72d477b66536e549e1bb4ffb9420a3afbf439179e18b61a7629"}, - {file = "rustworkx-0.14.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:99a714500d20c8712656b05f34b536d9a63670688a56c0ae2536a11d105cc892"}, - {file = "rustworkx-0.14.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ca330be994f131cb5f1a36ca01b4a57e9e65cbd393b9bccfb1aabe2949fe1524"}, - {file = "rustworkx-0.14.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e9e6150ab9eacae34aa61eafdb5cc5428d74026cdb2a1748c96ab9a4f66dc436"}, - {file = "rustworkx-0.14.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:f6f2eadc381d56c9e18f4fdb4ac743d63314d806355bc51b19785ca82470f285"}, - {file = "rustworkx-0.14.1-cp311-cp311-win32.whl", hash = "sha256:016097662f3ead6bf97be2cbabf0a9a61f92fd84192cbb37ca730728ad35bb9f"}, - {file = "rustworkx-0.14.1-cp311-cp311-win_amd64.whl", hash = "sha256:463220b6faf9c57f1bf8e39ad60c3163d10c3266392b5540d6a0199dad9e998a"}, - {file = "rustworkx-0.14.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:eede1ef7cb9d317dc6cdabeeee8d7f9c3ff332729849ee7fb47a58983c8918f6"}, - {file = "rustworkx-0.14.1-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:3063815f41de85a1579b1e26fd75ad37d42c922bdf37d77bfae2959ad1b3cb79"}, - {file = "rustworkx-0.14.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:7dd896472795c1a434fe2a474e0e2c5c2b7eca4c59b743c87302c125e6b26e8a"}, - {file = "rustworkx-0.14.1-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0001476d9c8ee82aceecb4f6e827ed9c91e3f0e3c3abf42bf1adb97ecd79f9bb"}, - {file = "rustworkx-0.14.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c9b04bae32cfb73c2c047c662b0b074de8c59657be9c1fa2c512384d912cd3bd"}, - {file = "rustworkx-0.14.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0ec2cf5ac6878e0594df765e51e5e756abc0192870aac23bebf43b71eca3b1c1"}, - {file = "rustworkx-0.14.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:21b7feccf87c3662c253fa26ad0159a8d1c33eb8f569297bf47f446b07644c7c"}, - {file = "rustworkx-0.14.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4921898e256e34a2a00e99d8d35dcadf08f10146a41e9c3e28977f45bd7a7131"}, - {file = "rustworkx-0.14.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:90b996e5372316f77377949763718e6343c7dd772144d31903fec06ebd4f038f"}, - {file = "rustworkx-0.14.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:5f5383da6a216374bffcfbab4321074d5db7cf6821d39bec33a5404a132b6e56"}, - {file = "rustworkx-0.14.1-cp312-cp312-win32.whl", hash = "sha256:faddf084e8dab5bb7c8c500b09d9d2c8fd411508a24af7a49dc9a79257c59619"}, - {file = "rustworkx-0.14.1-cp312-cp312-win_amd64.whl", hash = "sha256:97b18bbeb64664ffb92cd28121f6fb5e790f0ef0569d50cd6599f215d4e03cb0"}, - {file = "rustworkx-0.14.1-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:5c3d1ebc60f63f786e3b800453dbcd0e6b3f49fe9a26e9396e3e3328ee420025"}, - {file = "rustworkx-0.14.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:b87dce71da23fe6df27932d73f12498c6c090de9f658a494cefb921dfea61f75"}, - {file = "rustworkx-0.14.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:3a421c769ca90478f337869f9709d98c098f5183a62cc32ac66ec868f4e1d107"}, - {file = "rustworkx-0.14.1-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d2d93e5bd3a610ae66f8b822b5f05d2958aeb0b0b24005a96d5864448bce9ab9"}, - {file = "rustworkx-0.14.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:46678bf5a3550bfa592ff7c43cac367842448c62b71c3beaa7f294ba290a42ad"}, - {file = "rustworkx-0.14.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4c0666dcc22aba46d0738f781d53cb7fd7373dab4d2d1bee610c95e5b13a23a3"}, - {file = "rustworkx-0.14.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:63415718c6691656bb0f2adefffaa5637d9dfcd1745989eb151601cf2587ec25"}, - {file = "rustworkx-0.14.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:43b6df7fa92df2b9803f003c409dde3b71ae4063dadb862eee40e021643ec6b1"}, - {file = "rustworkx-0.14.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:c445013855a7f3da20a44a5af5fc7b49444168327d2bc2355a25addfe70b46ed"}, - {file = "rustworkx-0.14.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:f4cca1c345e1b15debffe13ad0ee266a9303b0f59b133e1836a4baea4da1457c"}, - {file = "rustworkx-0.14.1-cp38-cp38-win32.whl", hash = "sha256:6b8cab7e63ee476299c3f63a866e11a5f92a7b2883f9887ac4ef782f0f2ead54"}, - {file = "rustworkx-0.14.1-cp38-cp38-win_amd64.whl", hash = "sha256:218d53f9b457d7735591242c3a625c32fd95584f20dc994bf080068f4ebe5e57"}, - {file = "rustworkx-0.14.1-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:51e4cfc2ee4294a425acab4b1eea64b167ccd17134198180e2caa3c935fa6ede"}, - {file = "rustworkx-0.14.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:efcfd529f86cdb7258c589febb054be0cfc6f68f1f8a5111254d5f3f1ae6109a"}, - {file = "rustworkx-0.14.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:8d97de574cb34a06c6b418b0433712b8cf35e0561edae629fdcaca38896dd937"}, - {file = "rustworkx-0.14.1-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f90399650364d56f66545aa56fce1870150b7967c530355512a849422a4fbd6b"}, - {file = "rustworkx-0.14.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f1d2489e0d323732fec7e5437ea6fb35e9b022e043e1180529f91991d52a494f"}, - {file = "rustworkx-0.14.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:75c4b2acc629d953c2720ca8e44bed2103228150cca3313d4563174bb8f90c49"}, - {file = "rustworkx-0.14.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0c1f10df1c820d41b5e893c749362099986919f484d00efc17af60369312de62"}, - {file = "rustworkx-0.14.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f1f43182cf1340149dc96397fd72e0061ca2cd6d9181f9b9926f58b685343438"}, - {file = "rustworkx-0.14.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:d6c414bd3b8231e6b56a51c15df36513e0b26d11ebb25fd043280bd3cc9393cf"}, - {file = "rustworkx-0.14.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:09c1797222e7941b0a5eed293b344fd4d0d83baf0ab0f4482fb551f58724a439"}, - {file = "rustworkx-0.14.1-cp39-cp39-win32.whl", hash = "sha256:1dd5d0744ba5004b59d7184b2a60feb85c4060a513158523728beede76f2f37c"}, - {file = "rustworkx-0.14.1-cp39-cp39-win_amd64.whl", hash = "sha256:480b967d6eba90ecb53a84e21154b948b884c5dde742ca7391d2192b60f5ff96"}, - {file = "rustworkx-0.14.1.tar.gz", hash = "sha256:62104ecb0b3d4c2cfdb8b45dc38646bd45760c43fabc70ded9112712d01ea1c9"}, + {file = "rustworkx-0.14.2-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:a28a972dc7e0faf03f9f90c5be89328af8a71e609f311840e1a6abc6385edb79"}, + {file = "rustworkx-0.14.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:50e682b8fd2f11f9e99c309a01f7ed88a09ad32cda35b92c49835b1c9536ec65"}, + {file = "rustworkx-0.14.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6e1c3cf3d265835429074a1ecaa8f9bff327b188e1496a120bf8be8260a46453"}, + {file = "rustworkx-0.14.2-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0a22c02f74bf391b48ae92f633083d068055f3ed85050e35fe6cda967ff8a825"}, + {file = "rustworkx-0.14.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:996bad21eacbe124dd1e6abca47dd69ade9db0d4df5dd29197694f5d8e0a8258"}, + {file = "rustworkx-0.14.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:95c4647461f05fd9f99bae52002a929e8628d4e5a2e732dbfd7abd00ae5257b7"}, + {file = "rustworkx-0.14.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:829444876bba1940fa3109998f3b6c9184256d91eea5f0e09d9e9f8f26bb4704"}, + {file = "rustworkx-0.14.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:987b430dce1351a0c761bd6eedb8f6999f48983c9d4b06bf4b0b9dc45d08be8d"}, + {file = "rustworkx-0.14.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:18ef16f9b6b4f1c0d458fde3f213b78436ac810d61cae60385696b411aa80e1d"}, + {file = "rustworkx-0.14.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:fe30f1e22e69cbab4182d0017e21c345bf75f142a7b66a828227dd3c654d524c"}, + {file = "rustworkx-0.14.2-cp310-cp310-win32.whl", hash = "sha256:c1fe9f9ed18e270074d3632f6c70cc75c461535d9e76db39d1c0ab712bf64a7a"}, + {file = "rustworkx-0.14.2-cp310-cp310-win_amd64.whl", hash = "sha256:271b36412421d622e9e8cd27e2c6e1bd356e452f979edd41bb32d308df936f47"}, + {file = "rustworkx-0.14.2-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:c52e34ff4b08d1eaedd2ec906bca4317f4f852b36e4615d372b1ff2bb435ff26"}, + {file = "rustworkx-0.14.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:c97dc0cf7efef033ce50fa570887f97896b0f449c841ec3b127ecb70b3c16c84"}, + {file = "rustworkx-0.14.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:114bec1606ae31c089ecf52aa511551c545c6ce0746d3e8766082ad450377a2c"}, + {file = "rustworkx-0.14.2-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:950fa4ffc1691081587c87c4e869a8f5c7d0672d35ce1ba7c69f758f90bfe8c0"}, + {file = "rustworkx-0.14.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2134aa9c2065ab6c934017b6909e224e860003eb5dbaa5d2c4e87fff1187459a"}, + {file = "rustworkx-0.14.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bec8f1f1a6fed3ffbf5348a2b9d700f0b840fed2faa6a5198838d0fa9674a781"}, + {file = "rustworkx-0.14.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b8046991499df7aa984b3d9092e4f013597901c919aaf6fa43147e8550685734"}, + {file = "rustworkx-0.14.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:acb4256fba2c4f5c4ec009f383623b6a7c0a2dbeed1b529d22a193113927364a"}, + {file = "rustworkx-0.14.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:be7be125f9313b58829f7202a66dc166b61bf3c4bbe0c509b8d6902ed0d2da45"}, + {file = "rustworkx-0.14.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5d00f87fce0e48c6d7af4b63ee635188178e91462b52ac900d36ec3184ce92fc"}, + {file = "rustworkx-0.14.2-cp311-cp311-win32.whl", hash = "sha256:521e0f432a94ac9a4c92f30a746b971f7e49476fd128d83d94d4b15a2c17245d"}, + {file = "rustworkx-0.14.2-cp311-cp311-win_amd64.whl", hash = "sha256:8fd20776c0f543340ef96450ba5d9d670b8d74396315f7191303a392844271e0"}, + {file = "rustworkx-0.14.2-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:7bb37e877653ae4b4d505fc7e5f7847ae06e6822b91cec56e9e851941a6a0ae7"}, + {file = "rustworkx-0.14.2-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:230808e3878236464ac00001d8b440382aa6230f0073554ec627580863e380cc"}, + {file = "rustworkx-0.14.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:9a7cb7103ba88e12e3dd8e3b28365cbe971a8c158c1ee770646b2f3fd5cedab0"}, + {file = "rustworkx-0.14.2-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2637d0e496f34bac45f926b0aa12fb2e143581208f29a424cfb0eb5a7b5c3bfa"}, + {file = "rustworkx-0.14.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:692f78ee7f7a60d9c7082a5a26b4eefb697526f195172798389d7009510d84f3"}, + {file = "rustworkx-0.14.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:91d5513e93b7c10fbce954771a74fc86d551eb33b9eb318eaa35d7668f9929da"}, + {file = "rustworkx-0.14.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:26076523a1c43e903c633f2375afac28fdbb83b9668bee00fae24d8c672bf6c9"}, + {file = "rustworkx-0.14.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6de5e2df15c415dfb6e5cb7175239d0862568cb10d028f451d358d101be5d8bf"}, + {file = "rustworkx-0.14.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:21c86c240628abc2123d7d1317647073a738bdfe143c55728261b66bc32806e2"}, + {file = "rustworkx-0.14.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:0aa0277b931ca3fdfae07f8999b6a63dc9b89622b2fab820fa6bd95dd1e2e2eb"}, + {file = "rustworkx-0.14.2-cp312-cp312-win32.whl", hash = "sha256:fdc632673d4cd7f1cffe8ce13ea17dc361cf9d0d9f37dfa0888d94bdd5e6c159"}, + {file = "rustworkx-0.14.2-cp312-cp312-win_amd64.whl", hash = "sha256:47768f985f32ac1cd807af816fbd5f6e2433889793afdd838891ae516a95c8a6"}, + {file = "rustworkx-0.14.2-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:bfeee5a5be9eb71635a7897a6d2c034b1c01bf876fd15007b8bd4c6eaa8921e2"}, + {file = "rustworkx-0.14.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:4a20434c77f3daab043ab2f96386b5da871ebf15a5495f9ad5b916c3edf03e5c"}, + {file = "rustworkx-0.14.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:d856549e874e064af136f2ce304eb896d32d8865c3e98f8d9e83b577f4c57f1d"}, + {file = "rustworkx-0.14.2-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2521a223fb5aab2a14351205456d02bd851e0ec6b0c028f5598fe14f292e881b"}, + {file = "rustworkx-0.14.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dc9e7718eee8295cd5c11a5cf1c0fc7772e9c1dcc3d110edba4c77aad47e7f07"}, + {file = "rustworkx-0.14.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8c23ef82b1d373e07c280b8b6927dbad3953597e34c752e14843ac3df722a621"}, + {file = "rustworkx-0.14.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a46e0d1398138a75fb909369ffe6dfdcec6bab4d21794e80a9abf45fd2823f68"}, + {file = "rustworkx-0.14.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c16fb941e8f48aea96ee38471a1ae770ec68623864a9b0e4760aabf82c41fc2b"}, + {file = "rustworkx-0.14.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:fa92a97e5d35c6901553a812f31ca18305922c0ef06c2d7a9d20fbcc0769b4d1"}, + {file = "rustworkx-0.14.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:2e14b2956f2d06f5bb196bcd95f73008245eb6ffa9ee08f86ec369acf0cc04be"}, + {file = "rustworkx-0.14.2-cp38-cp38-win32.whl", hash = "sha256:816d33f69f4189376e1bb8132dea1deef1cd019b25bd281f01b7f394fcadbdad"}, + {file = "rustworkx-0.14.2-cp38-cp38-win_amd64.whl", hash = "sha256:4163f9c2c2d2158e053b30a39f74b0382b4c5a8a43f192c13b736e200b5e2025"}, + {file = "rustworkx-0.14.2-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:a9b55a8f97799b159da96087176a0e97679dca0b6b5a14b3140aeda7e1050777"}, + {file = "rustworkx-0.14.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:edb2d67870e41d5a1e16288bca0758580fb6961e8b4dfc337557bdaab81ff016"}, + {file = "rustworkx-0.14.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f058bdb50c5b0be731b96ffd789c6cec2a99e7f757a57763b2cc56004ed95af6"}, + {file = "rustworkx-0.14.2-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ff900cb6ae2d4028ffe5a3075cfefa21b14929270844b172595e6de0d2f183eb"}, + {file = "rustworkx-0.14.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:630177a80c68823fb2dd94733298377bd52c2ce3f66758ea0a63966fc2d7c08f"}, + {file = "rustworkx-0.14.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6a79c177a9e4f1c623554e01319fcb7b2a062ae26def7b85dc1f0539b7cdd874"}, + {file = "rustworkx-0.14.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d5ff956ee6c8224b8225478bb72103d4fc6dd4a247c066da30927776e1b05690"}, + {file = "rustworkx-0.14.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ae61a4c58186b4e428947b92ac2aa0557bcd5071fe8102a542c4337f64091766"}, + {file = "rustworkx-0.14.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:5a96b6f96e1bb4e8ee337618d8af0a1aec16c2eda6ffd9968e16d161850d1e77"}, + {file = "rustworkx-0.14.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:49bc143729e0d64a51b0ec6d745665f067116db78ce958d5cbe0389e69c6e73c"}, + {file = "rustworkx-0.14.2-cp39-cp39-win32.whl", hash = "sha256:f11e858a1804d5e276d18d6fc197f797adf5da82cd3382550abeef50196c5a7e"}, + {file = "rustworkx-0.14.2-cp39-cp39-win_amd64.whl", hash = "sha256:b55e75ea35a225d6b0afbdd449665e3b907684347be6a38648bdbfd50e177bf0"}, + {file = "rustworkx-0.14.2.tar.gz", hash = "sha256:bd649322c0649b71fa18cc70a9af027b549560415fa860d6894736029c277b13"}, ] [package.dependencies] @@ -1627,18 +1656,18 @@ mpl = ["matplotlib (>=3.0)"] [[package]] name = "setuptools" -version = "69.1.1" +version = "69.2.0" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "setuptools-69.1.1-py3-none-any.whl", hash = "sha256:02fa291a0471b3a18b2b2481ed902af520c69e8ae0919c13da936542754b4c56"}, - {file = "setuptools-69.1.1.tar.gz", hash = "sha256:5c0806c7d9af348e6dd3777b4f4dbb42c7ad85b190104837488eab9a7c945cf8"}, + {file = "setuptools-69.2.0-py3-none-any.whl", hash = "sha256:c21c49fb1042386df081cb5d86759792ab89efca84cf114889191cd09aacc80c"}, + {file = "setuptools-69.2.0.tar.gz", hash = "sha256:0ff4183f8f42cd8fa3acea16c45205521a4ef28f73c6391d8a25e92893134f2e"}, ] [package.extras] docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] -testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.2)", "pip (>=19.1)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff (>=0.2.1)", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "importlib-metadata", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "mypy (==1.9)", "packaging (>=23.2)", "pip (>=19.1)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff (>=0.2.1)", "pytest-timeout", "pytest-xdist (>=3)", "tomli", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.2)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] [[package]] @@ -1933,6 +1962,20 @@ files = [ [package.dependencies] bracex = ">=2.1.1" +[[package]] +name = "win32-setctime" +version = "1.1.0" +description = "A small Python utility to set file creation time on Windows" +optional = false +python-versions = ">=3.5" +files = [ + {file = "win32_setctime-1.1.0-py3-none-any.whl", hash = "sha256:231db239e959c2fe7eb1d7dc129f11172354f98361c4fa2d6d2d7e278baa8aad"}, + {file = "win32_setctime-1.1.0.tar.gz", hash = "sha256:15cf5750465118d6929ae4de4eb46e8edae9a5634350c01ba582df868e932cb2"}, +] + +[package.extras] +dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"] + [[package]] name = "xlrd" version = "2.0.1" @@ -1963,4 +2006,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "852b3e8756ad246e567583fb43619ae922a2213b212e81dbdef69aa6c378cea4" +content-hash = "7a5ba3f4447af652256e4bb22f85831c975ca11a5934283b792e9f588006717f" diff --git a/pyproject.toml b/pyproject.toml index 4039272f9..9746ad14d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ pyyaml = "^6.0.1" rustworkx = "^0.14.0" termcolor = "^2.4.0" packaging = "^23.2" +loguru = "^0.7.2" [tool.poetry.group.dev.dependencies] diff --git a/src/dsp_tools/cli/call_action.py b/src/dsp_tools/cli/call_action.py index 816e3f6aa..4c3ea5d1b 100644 --- a/src/dsp_tools/cli/call_action.py +++ b/src/dsp_tools/cli/call_action.py @@ -1,6 +1,8 @@ import argparse from pathlib import Path +from loguru import logger + from dsp_tools.commands.excel2json.lists import excel2lists from dsp_tools.commands.excel2json.lists import validate_lists_section_with_schema from dsp_tools.commands.excel2json.project import excel2json @@ -20,11 +22,8 @@ from dsp_tools.commands.template import generate_template_repo from dsp_tools.commands.xmlupload.upload_config import UploadConfig from dsp_tools.commands.xmlupload.xmlupload import xmlupload -from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.xml_validation import validate_xml -logger = get_logger(__name__) - def call_requested_action(args: argparse.Namespace) -> bool: """ diff --git a/src/dsp_tools/cli/entry_point.py b/src/dsp_tools/cli/entry_point.py index 735fd221f..0459c53c9 100644 --- a/src/dsp_tools/cli/entry_point.py +++ b/src/dsp_tools/cli/entry_point.py @@ -9,6 +9,7 @@ import regex import requests +from loguru import logger from packaging.version import parse from termcolor import colored @@ -17,15 +18,14 @@ from dsp_tools.models.exceptions import BaseError from dsp_tools.models.exceptions import InternalError from dsp_tools.models.exceptions import UserError -from dsp_tools.utils.create_logger import get_logger - -logger = get_logger(__name__) +from dsp_tools.utils.logger_config import logger_config def main() -> None: """ Main entry point of the program as referenced in pyproject.toml """ + logger_config() run(sys.argv[1:]) @@ -71,7 +71,7 @@ def run(args: list[str]) -> None: print("\nThe process was terminated because of an Error:") print(err.message) sys.exit(1) - except Exception as err: + except Exception as err: # noqa: BLE001 (blind-except) logger.exception(err) print(InternalError()) sys.exit(1) diff --git a/src/dsp_tools/commands/excel2xml/excel2xml_cli.py b/src/dsp_tools/commands/excel2xml/excel2xml_cli.py index 42406b0ec..9ddebdaa9 100644 --- a/src/dsp_tools/commands/excel2xml/excel2xml_cli.py +++ b/src/dsp_tools/commands/excel2xml/excel2xml_cli.py @@ -515,8 +515,7 @@ def excel2xml( dataframe=dataframe, max_num_of_props=max_num_of_props, ) - for resource in resources: - root.append(resource) + root.extend(resources) write_xml(root, output_file) if len(catched_warnings) > 0: success = False diff --git a/src/dsp_tools/commands/id2iri.py b/src/dsp_tools/commands/id2iri.py index 78195b488..394cc67c3 100644 --- a/src/dsp_tools/commands/id2iri.py +++ b/src/dsp_tools/commands/id2iri.py @@ -5,14 +5,12 @@ from pathlib import Path import regex +from loguru import logger from lxml import etree from dsp_tools.models.exceptions import UserError -from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.xml_utils import parse_and_clean_xml_file -logger = get_logger(__name__) - def _check_input_parameters( xml_file: str, diff --git a/src/dsp_tools/commands/ingest_xmlupload/apply_ingest_id.py b/src/dsp_tools/commands/ingest_xmlupload/apply_ingest_id.py index 1f3860abe..dd592979b 100644 --- a/src/dsp_tools/commands/ingest_xmlupload/apply_ingest_id.py +++ b/src/dsp_tools/commands/ingest_xmlupload/apply_ingest_id.py @@ -5,13 +5,11 @@ from typing import cast import pandas as pd +from loguru import logger from lxml import etree from dsp_tools.commands.ingest_xmlupload.user_information import IngestInformation from dsp_tools.models.exceptions import InputError -from dsp_tools.utils.create_logger import get_logger - -logger = get_logger(__name__) def get_mapping_dict_from_file(shortcode: str) -> dict[str, str]: diff --git a/src/dsp_tools/commands/ingest_xmlupload/upload_xml.py b/src/dsp_tools/commands/ingest_xmlupload/upload_xml.py index a4ec40a77..6401f624c 100644 --- a/src/dsp_tools/commands/ingest_xmlupload/upload_xml.py +++ b/src/dsp_tools/commands/ingest_xmlupload/upload_xml.py @@ -2,6 +2,7 @@ from pathlib import Path +from loguru import logger from lxml import etree from dsp_tools.commands.ingest_xmlupload.apply_ingest_id import get_mapping_dict_from_file @@ -9,11 +10,8 @@ from dsp_tools.commands.xmlupload.upload_config import UploadConfig from dsp_tools.commands.xmlupload.xmlupload import xmlupload from dsp_tools.models.exceptions import InputError -from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.xml_utils import remove_comments_from_element_tree -logger = get_logger(__name__) - def ingest_xmlupload( xml_file: Path, diff --git a/src/dsp_tools/commands/project/create/project_create.py b/src/dsp_tools/commands/project/create/project_create.py index c407c9686..cd5525481 100644 --- a/src/dsp_tools/commands/project/create/project_create.py +++ b/src/dsp_tools/commands/project/create/project_create.py @@ -8,6 +8,7 @@ from typing import cast import regex +from loguru import logger from dsp_tools.commands.excel2json.lists import expand_lists_from_excel from dsp_tools.commands.project.create.project_create_lists import create_lists_on_server @@ -27,11 +28,8 @@ from dsp_tools.models.langstring import LangString from dsp_tools.utils.connection import Connection from dsp_tools.utils.connection_live import ConnectionLive -from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.shared import parse_json_input -logger = get_logger(__name__) - def _create_project_on_server( project_definition: ProjectDefinition, @@ -79,7 +77,7 @@ def _create_project_on_server( f"Cannot create project '{project_definition.shortname}' " f"({project_definition.shortcode}) on DSP server." ) - logger.error(err_msg, exc_info=True) + logger.opt(exception=True).error(err_msg) raise UserError(err_msg) from None print(f" Created project '{project_remote.shortname}' ({project_remote.shortcode}).") logger.info(f"Created project '{project_remote.shortname}' ({project_remote.shortcode}).") @@ -119,7 +117,7 @@ def _create_groups( "not possible to retrieve the remote groups from the DSP server." ) print(f"WARNING: {err_msg}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) remote_groups = [] overall_success = False @@ -131,7 +129,7 @@ def _create_groups( current_project_groups[group_name] = remotely_existing_group[0] err_msg = f"Group name '{group_name}' already exists on the DSP server. Skipping..." print(f" WARNING: {err_msg}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) overall_success = False continue @@ -149,7 +147,7 @@ def _create_groups( except BaseError: err_msg = "Unable to create group '{group_name}'." print(f" WARNING: {err_msg}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) overall_success = False continue @@ -198,7 +196,7 @@ def _get_group_iris_for_user( ) if ":" not in full_group_name and full_group_name != "SystemAdmin": print(f" WARNING: {inexisting_group_msg}") - logger.warning(inexisting_group_msg, exc_info=True) + logger.opt(exception=True).warning(inexisting_group_msg) success = False continue @@ -215,7 +213,7 @@ def _get_group_iris_for_user( # full_group_name refers to a group inside the same project if group_name not in current_project_groups: print(f" WARNING: {inexisting_group_msg}") - logger.warning(inexisting_group_msg, exc_info=True) + logger.opt(exception=True).warning(inexisting_group_msg) success = False continue group = current_project_groups[group_name] @@ -230,13 +228,13 @@ def _get_group_iris_for_user( f"exists on the DSP server, but no groups could be retrieved from the DSP server." ) print(f" WARNING: {err_msg}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) success = False continue existing_group = [g for g in remote_groups if g.project == current_project.iri and g.name == group_name] if not existing_group: print(f" WARNING: {inexisting_group_msg}") - logger.warning(inexisting_group_msg, exc_info=True) + logger.opt(exception=True).warning(inexisting_group_msg) success = False continue group = existing_group[0] @@ -278,7 +276,7 @@ def _get_projects_where_user_is_admin( if ":" not in full_project_name: err_msg = "Provided project '{full_project_name}' for user '{username}' is not valid. Skipping..." print(f" WARNING: {err_msg}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) success = False continue @@ -297,14 +295,14 @@ def _get_projects_where_user_is_admin( f"because the projects cannot be retrieved from the DSP server." ) print(f" WARNING: {err_msg}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) success = False continue in_project_list = [p for p in remote_projects if p.shortname == project_name] if not in_project_list: msg = f"Provided project '{full_project_name}' for user '{username}' is not valid. Skipping..." print(f" WARNING: {msg}") - logger.warning(msg, exc_info=True) + logger.opt(exception=True).warning(msg) success = False continue in_project = in_project_list[0] @@ -349,7 +347,7 @@ def _create_users( if json_user_definition["email"] in [user.email for user in all_users]: err_msg = f"User '{username}' already exists on the DSP server. Skipping..." print(f" WARNING: {err_msg}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) overall_success = False continue # add user to the group(s) @@ -391,7 +389,7 @@ def _create_users( user_local.create() except BaseError: print(f" WARNING: Unable to create user '{username}'.") - logger.warning(f"Unable to create user '{username}'.", exc_info=True) + logger.opt(exception=True).warning(f"Unable to create user '{username}'.") overall_success = False continue print(f" Created user '{username}'.") @@ -506,7 +504,7 @@ def _create_ontology( if onto_name in [onto.name for onto in project_ontologies]: err_msg = f"Ontology '{onto_name}' already exists on the DSP server. Skipping..." print(f" WARNING: {err_msg}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) return None print(f"Create ontology '{onto_name}'...") @@ -522,7 +520,7 @@ def _create_ontology( ontology_remote = ontology_local.create() except BaseError: # if ontology cannot be created, let the error escalate - logger.error(f"ERROR while trying to create ontology '{onto_name}'.", exc_info=True) + logger.opt(exception=True).error(f"ERROR while trying to create ontology '{onto_name}'.") raise UserError(f"ERROR while trying to create ontology '{onto_name}'.") from None if verbose: @@ -583,7 +581,7 @@ def _create_ontologies( except BaseError: err_msg = "Unable to retrieve remote ontologies. Cannot check if your ontology already exists." print("WARNING: {err_msg}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) project_ontologies = [] for ontology_definition in ontology_definitions: @@ -698,7 +696,7 @@ def _add_resource_classes_to_remote_ontology( except BaseError: err_msg = f"Unable to create resource class '{res_class['name']}'." print(f"WARNING: {err_msg}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) overall_success = False return last_modification_date, new_res_classes, overall_success @@ -794,7 +792,7 @@ def _add_property_classes_to_remote_ontology( except BaseError: err_msg = f"Unable to create property class '{prop_class['name']}'." print(f"WARNING: {err_msg}") - logger.warning(f"Unable to create property class '{prop_class['name']}'.", exc_info=True) + logger.opt(exception=True).warning(f"Unable to create property class '{prop_class['name']}'.") overall_success = False return last_modification_date, overall_success @@ -842,7 +840,7 @@ def _add_cardinalities_to_resource_classes( f"This class doesn't exist on the DSP server." ) print(f"WARNINIG: {msg}") - logger.warning(msg, exc_info=True) + logger.opt(exception=True).warning(msg) overall_success = False continue for card_info in res_class.get("cardinalities", []): @@ -865,7 +863,7 @@ def _add_cardinalities_to_resource_classes( except BaseError: err_msg = f"Unable to add cardinality '{qualified_propname}' to resource class {res_class['name']}." print(f"WARNING: {err_msg}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) overall_success = False ontology_remote.lastModificationDate = last_modification_date @@ -918,7 +916,7 @@ def _rectify_hlist_of_properties( f"which is not a valid list name. " f"Assuming that you meant '{deduced_list_name}' instead." ) - logger.warning(msg, exc_info=True) + logger.opt(exception=True).warning(msg) print(msg) else: msg = f"Property '{prop['name']}' references an unknown list: '{prop['gui_attributes']['hlist']}'" @@ -1062,7 +1060,7 @@ def create_project( f"but during the creation process, some problems occurred. Please carefully check the console output." ) print(f"========================================================\nWARNING: {msg}") - logger.warning(msg, exc_info=True) + logger.opt(exception=True).warning(msg) return overall_success diff --git a/src/dsp_tools/commands/project/create/project_create_lists.py b/src/dsp_tools/commands/project/create/project_create_lists.py index af89f9937..4a45a2a7d 100644 --- a/src/dsp_tools/commands/project/create/project_create_lists.py +++ b/src/dsp_tools/commands/project/create/project_create_lists.py @@ -2,6 +2,8 @@ from typing import Optional from typing import Union +from loguru import logger + from dsp_tools.commands.excel2json.lists import expand_lists_from_excel from dsp_tools.commands.project.create.project_validate import validate_project from dsp_tools.commands.project.models.listnode import ListNode @@ -10,11 +12,8 @@ from dsp_tools.models.exceptions import UserError from dsp_tools.utils.connection import Connection from dsp_tools.utils.connection_live import ConnectionLive -from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.shared import parse_json_input -logger = get_logger(__name__) - def _create_list_node( con: Connection, @@ -55,7 +54,7 @@ def _create_list_node( new_node = new_node.create() except BaseError: print(f"WARNING: Cannot create list node '{node['name']}'.") - logger.warning("Cannot create list node '{node['name']}'.", exc_info=True) + logger.opt(exception=True).warning("Cannot create list node '{node['name']}'.") return {}, False # if node has child nodes, call the method recursively @@ -106,7 +105,7 @@ def create_lists_on_server( except BaseError: err_msg = "Unable to retrieve existing lists on DSP server. Cannot check if your lists are already existing." print(f"WARNING: {err_msg}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) existing_lists = [] overall_success = False @@ -195,7 +194,7 @@ def create_lists( project_remote = project_local.read() except BaseError: err_msg = f"Unable to create the lists: The project {shortcode} cannot be found on the DSP server." - logger.error(err_msg, exc_info=True) + logger.opt(exception=True).error(err_msg) raise UserError(err_msg) from None # create new lists diff --git a/src/dsp_tools/commands/resume_xmlupload/resume_xmlupload.py b/src/dsp_tools/commands/resume_xmlupload/resume_xmlupload.py index 48d0b0893..6b5f008f4 100644 --- a/src/dsp_tools/commands/resume_xmlupload/resume_xmlupload.py +++ b/src/dsp_tools/commands/resume_xmlupload/resume_xmlupload.py @@ -3,6 +3,7 @@ from copy import deepcopy from dataclasses import replace +from loguru import logger from termcolor import colored from dsp_tools.commands.xmlupload.iri_resolver import IriResolver @@ -16,9 +17,6 @@ from dsp_tools.commands.xmlupload.xmlupload import cleanup_upload from dsp_tools.commands.xmlupload.xmlupload import upload_resources from dsp_tools.utils.connection_live import ConnectionLive -from dsp_tools.utils.create_logger import get_logger - -logger = get_logger(__name__) def resume_xmlupload(server: str, user: str, password: str, sipi: str, skip_first_resource: bool = False) -> bool: diff --git a/src/dsp_tools/commands/start_stack.py b/src/dsp_tools/commands/start_stack.py index a56e97517..cd160d1a2 100644 --- a/src/dsp_tools/commands/start_stack.py +++ b/src/dsp_tools/commands/start_stack.py @@ -9,11 +9,9 @@ import regex import requests import yaml +from loguru import logger from dsp_tools.models.exceptions import UserError -from dsp_tools.utils.create_logger import get_logger - -logger = get_logger(__name__) @dataclass(frozen=True) diff --git a/src/dsp_tools/commands/xmlupload/ark2iri.py b/src/dsp_tools/commands/xmlupload/ark2iri.py index bd8dfe412..88787286a 100644 --- a/src/dsp_tools/commands/xmlupload/ark2iri.py +++ b/src/dsp_tools/commands/xmlupload/ark2iri.py @@ -6,9 +6,6 @@ import regex from dsp_tools.models.exceptions import BaseError -from dsp_tools.utils.create_logger import get_logger - -logger = get_logger(__name__) def convert_ark_v0_to_resource_iri(ark: str) -> str: diff --git a/src/dsp_tools/commands/xmlupload/list_client.py b/src/dsp_tools/commands/xmlupload/list_client.py index 82b644715..02d9c4894 100644 --- a/src/dsp_tools/commands/xmlupload/list_client.py +++ b/src/dsp_tools/commands/xmlupload/list_client.py @@ -7,10 +7,9 @@ from typing import Protocol from urllib.parse import quote_plus -from dsp_tools.utils.connection import Connection -from dsp_tools.utils.create_logger import get_logger +from loguru import logger -logger = get_logger(__name__) +from dsp_tools.utils.connection import Connection @dataclass(frozen=True) diff --git a/src/dsp_tools/commands/xmlupload/ontology_client.py b/src/dsp_tools/commands/xmlupload/ontology_client.py index 5a9465e97..70b45f2cc 100644 --- a/src/dsp_tools/commands/xmlupload/ontology_client.py +++ b/src/dsp_tools/commands/xmlupload/ontology_client.py @@ -6,9 +6,6 @@ from dsp_tools.models.exceptions import BaseError from dsp_tools.models.exceptions import UserError from dsp_tools.utils.connection import Connection -from dsp_tools.utils.create_logger import get_logger - -logger = get_logger(__name__) @dataclass diff --git a/src/dsp_tools/commands/xmlupload/project_client.py b/src/dsp_tools/commands/xmlupload/project_client.py index e1a41da71..74854efd3 100644 --- a/src/dsp_tools/commands/xmlupload/project_client.py +++ b/src/dsp_tools/commands/xmlupload/project_client.py @@ -6,9 +6,6 @@ from dsp_tools.models.exceptions import BaseError from dsp_tools.models.exceptions import UserError from dsp_tools.utils.connection import Connection -from dsp_tools.utils.create_logger import get_logger - -logger = get_logger(__name__) @dataclass(frozen=True) diff --git a/src/dsp_tools/commands/xmlupload/read_validate_xml_file.py b/src/dsp_tools/commands/xmlupload/read_validate_xml_file.py index feaa37ba5..39e25aa64 100644 --- a/src/dsp_tools/commands/xmlupload/read_validate_xml_file.py +++ b/src/dsp_tools/commands/xmlupload/read_validate_xml_file.py @@ -5,16 +5,14 @@ from typing import Union import regex +from loguru import logger from lxml import etree from dsp_tools.models.exceptions import UserError -from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.iri_util import is_resource_iri from dsp_tools.utils.xml_utils import parse_and_clean_xml_file from dsp_tools.utils.xml_validation import validate_xml -logger = get_logger(__name__) - def validate_and_parse_xml_file( imgdir: str, diff --git a/src/dsp_tools/commands/xmlupload/resource_create_client.py b/src/dsp_tools/commands/xmlupload/resource_create_client.py index 1da9ff5a5..3a335bc7d 100644 --- a/src/dsp_tools/commands/xmlupload/resource_create_client.py +++ b/src/dsp_tools/commands/xmlupload/resource_create_client.py @@ -4,6 +4,8 @@ from typing import Any from typing import assert_never +from loguru import logger + from dsp_tools.commands.xmlupload.ark2iri import convert_ark_v0_to_resource_iri from dsp_tools.commands.xmlupload.iri_resolver import IriResolver from dsp_tools.commands.xmlupload.models.formatted_text_value import FormattedTextValue @@ -15,12 +17,9 @@ from dsp_tools.models.exceptions import BaseError from dsp_tools.models.exceptions import UserError from dsp_tools.utils.connection import Connection -from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.date_util import parse_date_string from dsp_tools.utils.iri_util import is_resource_iri -logger = get_logger(__name__) - @dataclass(frozen=True) class ResourceCreateClient: diff --git a/src/dsp_tools/commands/xmlupload/resource_multimedia.py b/src/dsp_tools/commands/xmlupload/resource_multimedia.py index 832f256b7..f528ff903 100644 --- a/src/dsp_tools/commands/xmlupload/resource_multimedia.py +++ b/src/dsp_tools/commands/xmlupload/resource_multimedia.py @@ -3,15 +3,14 @@ from datetime import datetime from pathlib import Path +from loguru import logger + from dsp_tools.commands.xmlupload.models.permission import Permissions from dsp_tools.commands.xmlupload.models.sipi import Sipi from dsp_tools.commands.xmlupload.models.xmlbitstream import XMLBitstream from dsp_tools.commands.xmlupload.models.xmlresource import BitstreamInfo from dsp_tools.commands.xmlupload.models.xmlresource import XMLResource from dsp_tools.models.exceptions import PermanentConnectionError -from dsp_tools.utils.create_logger import get_logger - -logger = get_logger(__name__) def handle_media_info( @@ -95,7 +94,7 @@ def _handle_media_upload( except PermanentConnectionError as err: msg = f"Unable to upload file '{bitstream.value}' of resource '{resource.label}' ({resource.res_id})" print(f"{datetime.now()}: WARNING: {msg}: {err.message}") - logger.warning(msg, exc_info=True) + logger.opt(exception=True).warning(msg) return None diff --git a/src/dsp_tools/commands/xmlupload/stash/stash_circular_references.py b/src/dsp_tools/commands/xmlupload/stash/stash_circular_references.py index a0d5ac30a..3b0d11c0d 100644 --- a/src/dsp_tools/commands/xmlupload/stash/stash_circular_references.py +++ b/src/dsp_tools/commands/xmlupload/stash/stash_circular_references.py @@ -17,9 +17,6 @@ from dsp_tools.commands.xmlupload.stash.stash_models import StandoffStash from dsp_tools.commands.xmlupload.stash.stash_models import StandoffStashItem from dsp_tools.commands.xmlupload.stash.stash_models import Stash -from dsp_tools.utils.create_logger import get_logger - -logger = get_logger(__name__) def _stash_standoff( diff --git a/src/dsp_tools/commands/xmlupload/stash/upload_stashed_resptr_props.py b/src/dsp_tools/commands/xmlupload/stash/upload_stashed_resptr_props.py index a23590aa1..4bdc37020 100644 --- a/src/dsp_tools/commands/xmlupload/stash/upload_stashed_resptr_props.py +++ b/src/dsp_tools/commands/xmlupload/stash/upload_stashed_resptr_props.py @@ -3,14 +3,13 @@ from datetime import datetime from typing import Any +from loguru import logger + from dsp_tools.commands.xmlupload.iri_resolver import IriResolver from dsp_tools.commands.xmlupload.stash.stash_models import LinkValueStash from dsp_tools.commands.xmlupload.stash.stash_models import LinkValueStashItem from dsp_tools.models.exceptions import BaseError from dsp_tools.utils.connection import Connection -from dsp_tools.utils.create_logger import get_logger - -logger = get_logger(__name__) def upload_stashed_resptr_props( @@ -90,7 +89,7 @@ def _upload_stash_item( def _log_unable_to_upload_link_value(msg: str, res_id: str, prop_name: str) -> None: err_msg = f"Unable to upload the resptr prop of '{prop_name}' of resource '{res_id}'." print(f"{datetime.now()}: WARNING: {err_msg} Original error message: {msg}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) def _create_resptr_prop_json_object_to_update( diff --git a/src/dsp_tools/commands/xmlupload/stash/upload_stashed_xml_texts.py b/src/dsp_tools/commands/xmlupload/stash/upload_stashed_xml_texts.py index e615eb083..9dbb02a29 100644 --- a/src/dsp_tools/commands/xmlupload/stash/upload_stashed_xml_texts.py +++ b/src/dsp_tools/commands/xmlupload/stash/upload_stashed_xml_texts.py @@ -4,15 +4,14 @@ from typing import Any from urllib.parse import quote_plus +from loguru import logger + from dsp_tools.commands.xmlupload.iri_resolver import IriResolver from dsp_tools.commands.xmlupload.models.formatted_text_value import FormattedTextValue from dsp_tools.commands.xmlupload.stash.stash_models import StandoffStash from dsp_tools.commands.xmlupload.stash.stash_models import StandoffStashItem from dsp_tools.models.exceptions import BaseError from dsp_tools.utils.connection import Connection -from dsp_tools.utils.create_logger import get_logger - -logger = get_logger(__name__) def _log_unable_to_retrieve_resource( @@ -34,7 +33,7 @@ def _log_unable_to_retrieve_resource( "because the resource cannot be retrieved from the DSP server." ) print(f"{datetime.now()}: WARNING: {err_msg} Original error message: {received_error.message}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) def _log_unable_to_upload_xml_resource( @@ -55,7 +54,7 @@ def _log_unable_to_upload_xml_resource( # this resource will remain in nonapplied_xml_texts, which will be handled by the caller err_msg = f"Unable to upload the xml text of '{prop_name}' of resource '{stashed_resource_id}'." print(f"{datetime.now()}: WARNING: {err_msg} Original error message: {received_error.message}") - logger.warning(err_msg, exc_info=True) + logger.opt(exception=True).warning(err_msg) def _create_XMLResource_json_object_to_update( diff --git a/src/dsp_tools/commands/xmlupload/upload_config.py b/src/dsp_tools/commands/xmlupload/upload_config.py index c00ba1a60..c6e0dae98 100644 --- a/src/dsp_tools/commands/xmlupload/upload_config.py +++ b/src/dsp_tools/commands/xmlupload/upload_config.py @@ -6,10 +6,7 @@ from pathlib import Path import regex - -from dsp_tools.utils.create_logger import get_logger - -logger = get_logger(__name__) +from loguru import logger def _transform_server_url_to_foldername(server: str) -> str: diff --git a/src/dsp_tools/commands/xmlupload/write_diagnostic_info.py b/src/dsp_tools/commands/xmlupload/write_diagnostic_info.py index dd7829564..77b95dbeb 100644 --- a/src/dsp_tools/commands/xmlupload/write_diagnostic_info.py +++ b/src/dsp_tools/commands/xmlupload/write_diagnostic_info.py @@ -3,10 +3,9 @@ import json from datetime import datetime -from dsp_tools.commands.xmlupload.upload_config import DiagnosticsConfig -from dsp_tools.utils.create_logger import get_logger +from loguru import logger -logger = get_logger(__name__) +from dsp_tools.commands.xmlupload.upload_config import DiagnosticsConfig def write_id2iri_mapping( diff --git a/src/dsp_tools/commands/xmlupload/xmlupload.py b/src/dsp_tools/commands/xmlupload/xmlupload.py index 91b46f822..890a964b6 100644 --- a/src/dsp_tools/commands/xmlupload/xmlupload.py +++ b/src/dsp_tools/commands/xmlupload/xmlupload.py @@ -6,6 +6,7 @@ from pathlib import Path from typing import Any +from loguru import logger from lxml import etree from dsp_tools.commands.xmlupload.check_consistency_with_ontology import do_xml_consistency_check_with_ontology @@ -38,11 +39,8 @@ from dsp_tools.models.projectContext import ProjectContext from dsp_tools.utils.connection import Connection from dsp_tools.utils.connection_live import ConnectionLive -from dsp_tools.utils.create_logger import get_log_filename_str -from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.json_ld_util import get_json_ld_context_for_project - -logger = get_logger(__name__) +from dsp_tools.utils.logger_config import logger_savepath def xmlupload( @@ -151,14 +149,13 @@ def cleanup_upload( logger.info("All resources have successfully been uploaded.") else: success = False - logfiles = get_log_filename_str(logger) if failed_uploads: print(f"\n{datetime.now()}: WARNING: Could not upload the following resources: {failed_uploads}\n") - print(f"For more information, see the log file: {logfiles}\n") + print(f"For more information, see the log file: {logger_savepath}\n") logger.warning(f"Could not upload the following resources: {failed_uploads}") if nonapplied_stash: print(f"\n{datetime.now()}: WARNING: Could not reapply the following stash items: {nonapplied_stash}\n") - print(f"For more information, see the log file: {logfiles}\n") + print(f"For more information, see the log file: {logger_savepath}\n") logger.warning(f"Could not reapply the following stash items: {nonapplied_stash}") config.diagnostics.save_location.unlink(missing_ok=True) @@ -329,10 +326,7 @@ def _get_project_context_from_server(connection: Connection) -> ProjectContext: try: proj_context = ProjectContext(con=connection) except BaseError: - logger.error( - "Unable to retrieve project context from DSP server", - exc_info=True, - ) + logger.opt(exception=True).error("Unable to retrieve project context from DSP server") raise UserError("Unable to retrieve project context from DSP server") from None return proj_context @@ -479,7 +473,7 @@ def _create_resource( # Because the calling function needs to know that this was a PermanentTimeOutError, we need to catch and # raise it here. raise err - except Exception as err: + except Exception as err: # noqa: BLE001 (blind-except) msg = f"{datetime.now()}: WARNING: Unable to create resource '{resource.label}' ({resource.res_id})" if isinstance(err, BaseError): msg = f"{msg}: {err.message}" @@ -525,12 +519,11 @@ def _handle_upload_error( msg = "\n==========================================\n" + err.message + "\n" exit_code = 0 else: - logfiles = get_log_filename_str(logger) msg = ( f"\n==========================================\n" f"{datetime.now()}: xmlupload must be aborted because of an error.\n" f"Error message: '{err}'\n" - f"For more information, see the log file: {logfiles}\n" + f"For more information, see the log file: {logger_savepath}\n" ) exit_code = 1 diff --git a/src/dsp_tools/utils/connection_live.py b/src/dsp_tools/utils/connection_live.py index 81f7d6d4d..6576e9439 100644 --- a/src/dsp_tools/utils/connection_live.py +++ b/src/dsp_tools/utils/connection_live.py @@ -12,6 +12,7 @@ from typing import cast import regex +from loguru import logger from requests import ReadTimeout from requests import RequestException from requests import Response @@ -22,16 +23,12 @@ from dsp_tools.models.exceptions import PermanentConnectionError from dsp_tools.models.exceptions import PermanentTimeOutError from dsp_tools.models.exceptions import UserError -from dsp_tools.utils.create_logger import get_log_filename_str -from dsp_tools.utils.create_logger import get_logger +from dsp_tools.utils.logger_config import logger_savepath from dsp_tools.utils.set_encoder import SetEncoder HTTP_OK = 200 HTTP_UNAUTHORIZED = 401 -logger = get_logger(__name__) -LOGFILES = get_log_filename_str(logger) - @dataclass class RequestParameters: @@ -298,7 +295,7 @@ def _handle_non_ok_responses(self, response: Response, request_url: str, retry_c msg = "Permanently unable to execute the network action. " if original_str := regex.search(r'{"knora-api:error":"dsp\.errors\.(.*)","@context', str(response.content)): msg += f"\n{' '*37}Original Message: {original_str.group(1)}\n" - msg += f"See logs for more details: {LOGFILES}" + msg += f"See logs for more details: {logger_savepath}" raise PermanentConnectionError(msg) def _renew_session(self) -> None: @@ -311,7 +308,10 @@ def _renew_session(self) -> None: def _log_and_sleep(self, reason: str, retry_counter: int, exc_info: bool) -> None: msg = f"{reason}: Try reconnecting to DSP server, next attempt in {2 ** retry_counter} seconds..." print(f"{datetime.now()}: {msg}") - logger.error(f"{msg} ({retry_counter=:})", exc_info=exc_info) + if exc_info: + logger.opt(exception=True).error(f"{msg} ({retry_counter=:})") + else: + logger.error(f"{msg} ({retry_counter=:})") time.sleep(2**retry_counter) def _log_and_raise_timeouts(self, error: TimeoutError | ReadTimeout) -> None: diff --git a/src/dsp_tools/utils/create_logger.py b/src/dsp_tools/utils/create_logger.py deleted file mode 100644 index 4d41f52e3..000000000 --- a/src/dsp_tools/utils/create_logger.py +++ /dev/null @@ -1,83 +0,0 @@ -import logging -import logging.handlers -from logging import FileHandler -from pathlib import Path - -# the handler must live on module level, so that it is created only once -_rotating_file_handler: logging.handlers.RotatingFileHandler | None = None - - -def _make_handler( - logfile_directory: Path, - filesize_mb: int, - backupcount: int, -) -> logging.handlers.RotatingFileHandler: - """ - Create a rotating file handler. - A RotatingFileHandler fills "filename" until it is "maxBytes" big, - then appends ".1" to it and starts with a new file "filename", - fills it until it is "maxBytes" big, - then appends ".1" to it (replacing the old ".1" file) - - Args: - logfile_directory: directory to store the logfiles in - filesize_mb: maximum size of a logfile in MB - backupcount: number of logfiles to keep - - Returns: - handler instance - """ - formatter = logging.Formatter(fmt="{asctime} {filename: <30} l. {lineno: >4} {levelname: <8} {message}", style="{") - formatter.default_time_format = "%Y-%m-%d %H:%M:%S" - formatter.default_msec_format = "%s.%03d" - - logfile_directory.mkdir(exist_ok=True) - handler = logging.handlers.RotatingFileHandler( - filename=logfile_directory / "logging.log", - mode="a", - maxBytes=filesize_mb * 1024 * 1024, - backupCount=backupcount, - ) - handler.setFormatter(formatter) - return handler - - -def get_logger( - name: str, - level: int = logging.DEBUG, -) -> logging.Logger: - """ - Create a logger instance, - and configure it to write to a file in the user's home directory. - - Args: - name: name of the logger - level: logging level, defaults to logging.DEBUG - - Returns: - the logger instance - """ - global _rotating_file_handler - if not _rotating_file_handler: - _rotating_file_handler = _make_handler( - Path.home() / Path(".dsp-tools"), - filesize_mb=100, - backupcount=30, - ) - logger = logging.getLogger(name) - logger.setLevel(level) - logger.addHandler(_rotating_file_handler) - return logger - - -def get_log_filename_str(logger: logging.Logger) -> str: - """ - This function returns a string, that lists the filenames of the loggers. - - Args: - logger: logger - - Returns: - Name(s) of the logger files - """ - return ", ".join([handler.baseFilename for handler in logger.handlers if isinstance(handler, FileHandler)]) diff --git a/src/dsp_tools/utils/logger_config.py b/src/dsp_tools/utils/logger_config.py new file mode 100644 index 000000000..e7049c7dc --- /dev/null +++ b/src/dsp_tools/utils/logger_config.py @@ -0,0 +1,42 @@ +from datetime import datetime +from pathlib import Path + +from loguru import logger + +logger_savepath = (Path.home() / ".dsp-tools" / "logging.log").absolute() + + +def logger_config() -> None: + """ + This function configures the log files. + Currently, there are three sinks: + - logger.log in the home directory for development purposes + - warnings.log in the cwd only with level warning and higher for the user (no stack-trace) + - print output on the terminal, formatted the same as the warnings.log + """ + # If this is not removed, the default formatting is also printed out on the terminal + logger.remove() + + text_format = "{time:YYYY-MM-DD HH:mm:ss.SSS} | {level: <8} | {message}" + rotation_size = "100 MB" + retention_number = 30 + timestamp_str = datetime.now().strftime("%Y%m%d-%H%M") + + logger.add( + sink=logger_savepath, + format=text_format, + backtrace=True, + diagnose=True, + rotation=rotation_size, + retention=retention_number, + ) + + logger.add( + sink=Path(f"warnings-{timestamp_str}.log"), + level="WARNING", + format=text_format, + backtrace=False, + diagnose=False, + rotation=rotation_size, + retention=10, + ) diff --git a/src/dsp_tools/utils/shared.py b/src/dsp_tools/utils/shared.py index 9dcf3acc5..da8ee0fde 100644 --- a/src/dsp_tools/utils/shared.py +++ b/src/dsp_tools/utils/shared.py @@ -13,9 +13,6 @@ from dsp_tools.commands.excel2xml.propertyelement import PropertyElement from dsp_tools.models.exceptions import BaseError -from dsp_tools.utils.create_logger import get_logger - -logger = get_logger(__name__) def prepare_dataframe( diff --git a/src/dsp_tools/utils/xml_utils.py b/src/dsp_tools/utils/xml_utils.py index cb25d1cae..a1989e684 100644 --- a/src/dsp_tools/utils/xml_utils.py +++ b/src/dsp_tools/utils/xml_utils.py @@ -5,12 +5,10 @@ from typing import Any from typing import Union +from loguru import logger from lxml import etree from dsp_tools.models.exceptions import InputError -from dsp_tools.utils.create_logger import get_logger - -logger = get_logger(__name__) def parse_and_clean_xml_file(input_file: Union[str, Path, etree._ElementTree[Any]]) -> etree._Element: @@ -129,7 +127,7 @@ def _parse_xml_file(input_file: Union[str, Path]) -> etree._ElementTree[etree._E try: return etree.parse(source=input_file, parser=parser) except etree.XMLSyntaxError as err: - logger.error(f"The XML file contains the following syntax error: {err.msg}", exc_info=True) + logger.opt(exception=True).error(f"The XML file contains the following syntax error: {err.msg}") raise InputError(f"The XML file contains the following syntax error: {err.msg}") from None diff --git a/src/dsp_tools/utils/xml_validation.py b/src/dsp_tools/utils/xml_validation.py index 7d0cf00d2..5b1b36a0e 100644 --- a/src/dsp_tools/utils/xml_validation.py +++ b/src/dsp_tools/utils/xml_validation.py @@ -7,17 +7,15 @@ from typing import Union import regex +from loguru import logger from lxml import etree from dsp_tools.models.exceptions import InputError -from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.xml_utils import parse_and_remove_comments_from_xml_file from dsp_tools.utils.xml_utils import remove_namespaces_from_xml from dsp_tools.utils.xml_validation_models import InconsistentTextValueEncodings from dsp_tools.utils.xml_validation_models import TextValueData -logger = get_logger(__name__) - separator = "\n " list_separator = "\n - " medium_separator = "\n----------------------------\n" @@ -57,7 +55,7 @@ def validate_xml(input_file: Union[str, Path, etree._ElementTree[Any]]) -> bool: if len(problems) > 0: err_msg = grand_separator.join(problems) - logger.error(err_msg, exc_info=True) + logger.opt(exception=True).error(err_msg) raise InputError(err_msg) logger.info("The XML file is syntactically correct and passed validation.")