diff options
Diffstat (limited to 'dev-db/pgcli')
-rw-r--r-- | dev-db/pgcli/Manifest | 3 | ||||
-rw-r--r-- | dev-db/pgcli/files/pgcli-4.0.1-no-pendulum.patch | 112 | ||||
-rw-r--r-- | dev-db/pgcli/pgcli-4.0.1-r1.ebuild (renamed from dev-db/pgcli/pgcli-4.0.1.ebuild) | 24 |
3 files changed, 135 insertions, 4 deletions
diff --git a/dev-db/pgcli/Manifest b/dev-db/pgcli/Manifest index f4a79230485f..790beea33323 100644 --- a/dev-db/pgcli/Manifest +++ b/dev-db/pgcli/Manifest @@ -1,3 +1,4 @@ +AUX pgcli-4.0.1-no-pendulum.patch 3569 BLAKE2B 52379d64088803fd51d9535d7ac13bae34ea866c74e5a7c87a92f12f6bb8c25179b392f2bf9eb112770ccacad46d886f4bbfd39ff6ada1016301daf7123b1d0a SHA512 1d7fb9562b1e7bc4b4953e041d6e5620850b5f355ab8adaec7392579926a3b2a41661c6d1579b514d4763a171885d8d35df11b22ea03c576eb73cd987fbc89f2 DIST pgcli-4.0.1.tar.gz 646421 BLAKE2B ceb0537344d1fc4c22fc424b7d1df809515778e9d1e492aead517c904ed6274f8c330e1f9bd73da377543e0d078acc8c385951a6717784205dbff0ab427b2d49 SHA512 eba490b979d7b1120eda817c3fe2afc2f2a8e4608e67e41be9b73597dc51027fbe013d5f72f8a6f2853c85395fb51f622dcf6b30c8d2185e5d9a9c1aada378ba -EBUILD pgcli-4.0.1.ebuild 1043 BLAKE2B 76a3348d2fcc52f1f58e1ab764c1f9d0869025a5a602829f78c4b0cf00578cdf1fc3235abbd541a37d0a75bca89ab10e2d29706a966dfc4b9c8b459b9ce70d6d SHA512 f5c41a6ba246c7571f33b9a9e4640d35cd8f0dcd74d3f28ab1836663cb8b9681e654313be2c82e632588993cd30137101801f5494cd3b94398451a4bef03dbd9 +EBUILD pgcli-4.0.1-r1.ebuild 1366 BLAKE2B f6b68b1bc4dc44f2ba78960d74b2817c2a0d4f18b425fed6a590e0de92d44385d48e8082ad08da1555fae094000449780c35d8e904531f0d652d735f8b9e7c0d SHA512 55ba0a1344de3dafbe73b5d6c77ac7246770b95c93557ba2c5998fd6afe6e479433b11e9f8f424374d3df89d23d3080b61653508a3aebc5fbb3fb7b9fdbc35da MISC metadata.xml 359 BLAKE2B c8107f0af400492e5365311f645a91c0a56448f3f2983c470c8e8eb08126202f2b5895978971f5f77eec87bbe29e4f198d954dcd87b14b2cfa019fb98dbfe272 SHA512 bca1ac9cb841c4b17c07b6a581d54f860fe384ce139b9894fcdb442024f75ef7996ea55535be177472dc5149e1dd1cf4859181210bbcd637f6b82b8816334cc4 diff --git a/dev-db/pgcli/files/pgcli-4.0.1-no-pendulum.patch b/dev-db/pgcli/files/pgcli-4.0.1-no-pendulum.patch new file mode 100644 index 000000000000..b761f1c13634 --- /dev/null +++ b/dev-db/pgcli/files/pgcli-4.0.1-no-pendulum.patch @@ -0,0 +1,112 @@ +From da189aaa1852170cb852a7a435a20d8246e59c30 Mon Sep 17 00:00:00 2001 +From: Damien Baty <damien@damienbaty.com> +Date: Mon, 19 Feb 2024 09:36:46 +0100 +Subject: [PATCH] feat: Replace pendulum by home-made duration-to-words + function + +diff --git a/pgcli/main.py b/pgcli/main.py +index bbb1989d..cfa1c970 100644 +--- a/pgcli/main.py ++++ b/pgcli/main.py +@@ -11,7 +11,6 @@ + import threading + import shutil + import functools +-import pendulum + import datetime as dt + import itertools + import platform +@@ -800,9 +799,9 @@ def execute_command(self, text, handle_closed_connection=True): + "Time: %0.03fs (%s), executed in: %0.03fs (%s)" + % ( + query.total_time, +- pendulum.Duration(seconds=query.total_time).in_words(), ++ duration_in_words(query.total_time), + query.execution_time, +- pendulum.Duration(seconds=query.execution_time).in_words(), ++ duration_in_words(query.execution_time), + ) + ) + else: +@@ -1735,5 +1734,28 @@ def parse_service_info(service): + return service_conf, service_file + + ++def duration_in_words(duration_in_seconds: float) -> str: ++ if not duration_in_seconds: ++ return "0 seconds" ++ components = [] ++ hours, remainder = divmod(duration_in_seconds, 3600) ++ if hours > 1: ++ components.append(f"{hours} hours") ++ elif hours == 1: ++ components.append("1 hour") ++ minutes, seconds = divmod(remainder, 60) ++ if minutes > 1: ++ components.append(f"{minutes} minutes") ++ elif minutes == 1: ++ components.append("1 minute") ++ if seconds >= 2: ++ components.append(f"{int(seconds)} seconds") ++ elif seconds >= 1: ++ components.append("1 second") ++ elif seconds: ++ components.append(f"{round(seconds, 3)} second") ++ return " ".join(components) ++ ++ + if __name__ == "__main__": + cli() +diff --git a/setup.py b/setup.py +index f9dbc56a..640dca00 100644 +--- a/setup.py ++++ b/setup.py +@@ -16,7 +16,6 @@ + "psycopg-binary >= 3.0.14; sys_platform == 'win32'", + "sqlparse >=0.3.0,<0.5", + "configobj >= 5.0.6", +- "pendulum>=2.1.0", + "cli_helpers[styles] >= 2.2.1", + ] + +diff --git a/tests/test_main.py b/tests/test_main.py +index cbf20a6a..0aeba80e 100644 +--- a/tests/test_main.py ++++ b/tests/test_main.py +@@ -11,6 +11,7 @@ + + from pgcli.main import ( + obfuscate_process_password, ++ duration_in_words, + format_output, + PGCli, + OutputSettings, +@@ -488,3 +489,28 @@ def test_application_name_db_uri(tmpdir): + mock_pgexecute.assert_called_with( + "bar", "bar", "", "baz.com", "", "", application_name="cow" + ) ++ ++ ++@pytest.mark.parametrize( ++ "duration_in_seconds,words", ++ [ ++ (0, "0 seconds"), ++ (0.0009, "0.001 second"), ++ (0.0005, "0.001 second"), ++ (0.0004, "0.0 second"), # not perfect, but will do ++ (0.2, "0.2 second"), ++ (1, "1 second"), ++ (1.4, "1 second"), ++ (2, "2 seconds"), ++ (3.4, "3 seconds"), ++ (60, "1 minute"), ++ (61, "1 minute 1 second"), ++ (123, "2 minutes 3 seconds"), ++ (3600, "1 hour"), ++ (7235, "2 hours 35 seconds"), ++ (9005, "2 hours 30 minutes 5 seconds"), ++ (86401, "24 hours 1 second"), ++ ], ++) ++def test_duration_in_words(duration_in_seconds, words): ++ assert duration_in_words(duration_in_seconds) == words diff --git a/dev-db/pgcli/pgcli-4.0.1.ebuild b/dev-db/pgcli/pgcli-4.0.1-r1.ebuild index 111362fa7895..d168855385f8 100644 --- a/dev-db/pgcli/pgcli-4.0.1.ebuild +++ b/dev-db/pgcli/pgcli-4.0.1-r1.ebuild @@ -19,18 +19,36 @@ RDEPEND=" dev-python/click[${PYTHON_USEDEP}] >=dev-python/cli-helpers-2.2.1[${PYTHON_USEDEP}] dev-python/configobj[${PYTHON_USEDEP}] - dev-python/pendulum[${PYTHON_USEDEP}] dev-python/pgspecial[${PYTHON_USEDEP}] dev-python/prompt-toolkit[${PYTHON_USEDEP}] dev-python/psycopg:0[${PYTHON_USEDEP}] dev-python/pygments[${PYTHON_USEDEP}] dev-python/setproctitle[${PYTHON_USEDEP}] dev-python/sqlparse[${PYTHON_USEDEP}] - dev-python/sshtunnel[${PYTHON_USEDEP}]" + dev-python/sshtunnel[${PYTHON_USEDEP}] +" BDEPEND=" test? ( dev-db/postgresql dev-python/mock[${PYTHON_USEDEP}] - )" + ) +" distutils_enable_tests pytest + +PATCHES=( + # https://github.com/dbcli/pgcli/pull/1452 + "${FILESDIR}/${P}-no-pendulum.patch" +) + +python_test() { + local EPYTEST_DESELECT=( + # hang while trying to create a keyring + # https://bugs.gentoo.org/925085 + tests/test_main.py::test_pg_service_file + tests/test_ssh_tunnel.py::test_ssh_tunnel + ) + + local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 + epytest +} |