Mercurial > kallithea
changeset 7790:469b16f3979a
vcs: drop get_total_seconds - we only support Python 2.7 which has timedelta.total_seconds()
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Tue, 06 Aug 2019 21:08:02 +0200 |
parents | 75b128508fa8 |
children | a7d7157eca8e |
files | kallithea/lib/vcs/utils/helpers.py kallithea/lib/vcs/utils/progressbar.py kallithea/tests/vcs/test_utils.py |
diffstat | 3 files changed, 2 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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:
--- 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', {})