# HG changeset patch # User Mads Kiilerich # Date 1565118482 -7200 # Node ID 469b16f3979a83029f30af8776e0a34deae68ca1 # Parent 75b128508fa8af5c4cfa7a2212a91b59dd2dd325 vcs: drop get_total_seconds - we only support Python 2.7 which has timedelta.total_seconds() diff -r 75b128508fa8 -r 469b16f3979a kallithea/lib/vcs/utils/helpers.py --- a/kallithea/lib/vcs/utils/helpers.py Sun Jul 21 19:12:20 2019 +0200 +++ b/kallithea/lib/vcs/utils/helpers.py Tue Aug 06 21:08:02 2019 +0200 @@ -221,15 +221,3 @@ for attr in attrs: data[attr] = getattr(obj, attr) return data - - -def get_total_seconds(timedelta): - """ - Backported for Python 2.5. - - See http://docs.python.org/library/datetime.html. - """ - return ((timedelta.microseconds + ( - timedelta.seconds + - timedelta.days * 24 * 60 * 60 - ) * 10**6) / 10**6) diff -r 75b128508fa8 -r 469b16f3979a kallithea/lib/vcs/utils/progressbar.py --- a/kallithea/lib/vcs/utils/progressbar.py Sun Jul 21 19:12:20 2019 +0200 +++ b/kallithea/lib/vcs/utils/progressbar.py Tue Aug 06 21:08:02 2019 +0200 @@ -4,7 +4,6 @@ import string from kallithea.lib.vcs.utils.filesize import filesizeformat -from kallithea.lib.vcs.utils.helpers import get_total_seconds class ProgressBarError(Exception): @@ -87,7 +86,7 @@ current_time = datetime.datetime.now() if self.step == 0: return datetime.timedelta() - total_seconds = get_total_seconds(self.get_total_time()) + total_seconds = self.get_total_time().total_seconds() eta_seconds = total_seconds * self.steps / self.step - total_seconds return datetime.timedelta(seconds=int(eta_seconds)) @@ -113,7 +112,7 @@ if step is None: step = self.step if total_seconds is None: - total_seconds = get_total_seconds(self.get_total_time()) + total_seconds = self.get_total_time().total_seconds() if step <= 0 or total_seconds <= 0: speed = '-' else: diff -r 75b128508fa8 -r 469b16f3979a kallithea/tests/vcs/test_utils.py --- a/kallithea/tests/vcs/test_utils.py Sun Jul 21 19:12:20 2019 +0200 +++ b/kallithea/tests/vcs/test_utils.py Tue Aug 06 21:08:02 2019 +0200 @@ -12,7 +12,6 @@ from kallithea.lib.vcs.utils.helpers import get_dict_for_attrs from kallithea.lib.vcs.utils.helpers import get_scm from kallithea.lib.vcs.utils.helpers import get_scms_for_path -from kallithea.lib.vcs.utils.helpers import get_total_seconds from kallithea.lib.vcs.utils.helpers import parse_changesets from kallithea.lib.vcs.utils.helpers import parse_datetime from kallithea.lib.vcs.utils import author_email, author_name @@ -231,21 +230,6 @@ } -class TestGetTotalSeconds(object): - - def assertTotalSecondsEqual(self, timedelta, expected_seconds): - result = get_total_seconds(timedelta) - assert result == expected_seconds, \ - "We computed %s seconds for %s but expected %s" \ - % (result, timedelta, expected_seconds) - - def test_get_total_seconds_returns_proper_value(self): - self.assertTotalSecondsEqual(datetime.timedelta(seconds=1001), 1001) - - def test_get_total_seconds_returns_proper_value_for_partial_seconds(self): - self.assertTotalSecondsEqual(datetime.timedelta(seconds=50.65), 50.65) - - class TestGetUserHome(object): @mock.patch.object(os, 'environ', {})