From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id A5256158041 for ; Tue, 20 Feb 2024 12:23:29 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D1AE22BC0D4; Tue, 20 Feb 2024 12:23:28 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B333B2BC0D4 for ; Tue, 20 Feb 2024 12:23:28 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C09863430A1 for ; Tue, 20 Feb 2024 12:23:27 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2543214C6 for ; Tue, 20 Feb 2024 12:23:26 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1708431800.34109a72d19f799791d16bbfac2c643c82c36a0d.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-db/pgcli/files/, dev-db/pgcli/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-db/pgcli/files/pgcli-4.0.1-no-pendulum.patch dev-db/pgcli/pgcli-4.0.1-r1.ebuild X-VCS-Directories: dev-db/pgcli/files/ dev-db/pgcli/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 34109a72d19f799791d16bbfac2c643c82c36a0d X-VCS-Branch: master Date: Tue, 20 Feb 2024 12:23:26 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 30a42c7e-fa9b-48d8-ab38-5c4be661994a X-Archives-Hash: df90391a431ad443b74134776f4f8a89 commit: 34109a72d19f799791d16bbfac2c643c82c36a0d Author: Michał Górny gentoo org> AuthorDate: Tue Feb 20 12:20:42 2024 +0000 Commit: Michał Górny gentoo org> CommitDate: Tue Feb 20 12:23:20 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=34109a72 dev-db/pgcli: Backport dev-python/pendulum removal Bug: https://bugs.gentoo.org/924881 Pull-Request: https://github.com/dbcli/pgcli/pull/1452 Signed-off-by: Michał Górny gentoo.org> dev-db/pgcli/files/pgcli-4.0.1-no-pendulum.patch | 112 +++++++++++++++++++++++ dev-db/pgcli/pgcli-4.0.1-r1.ebuild | 6 +- 2 files changed, 117 insertions(+), 1 deletion(-) 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 +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-r1.ebuild b/dev-db/pgcli/pgcli-4.0.1-r1.ebuild index 510cad08ad1e..d168855385f8 100644 --- a/dev-db/pgcli/pgcli-4.0.1-r1.ebuild +++ b/dev-db/pgcli/pgcli-4.0.1-r1.ebuild @@ -19,7 +19,6 @@ 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}] @@ -37,6 +36,11 @@ BDEPEND=" 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