Changeset - 469b16f3979a
[Not reviewed]
default
0 3 0
Mads Kiilerich - 6 years ago 2019-08-06 21:08:02
mads@kiilerich.com
vcs: drop get_total_seconds - we only support Python 2.7 which has timedelta.total_seconds()
3 files changed with 2 insertions and 31 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/utils/helpers.py
Show inline comments
 
@@ -221,15 +221,3 @@ def get_dict_for_attrs(obj, attrs):
 
    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)
kallithea/lib/vcs/utils/progressbar.py
Show inline comments
 
@@ -4,7 +4,6 @@ import datetime
 
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 @@ class ProgressBar(object):
 
            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 @@ class ProgressBar(object):
 
        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:
kallithea/tests/vcs/test_utils.py
Show inline comments
 
@@ -12,7 +12,6 @@ from kallithea.lib.vcs.utils.paths impor
 
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 TestGetDictForAttrs(object):
 
        }
 

	
 

	
 
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', {})
0 comments (0 inline, 0 general)