Пример #1
0
 def str_eta(self):
     """Returns a formatted ETA value for the progress bar."""
     eta = eta_letters(self._eta.elapsed) if self.done else self._eta_string
     if not eta:
         return ''
     if eta.count(' ') > 1:
         eta = ' '.join(eta.split(' ')[:2])  # Only show up to two units (h and m, no s for example).
     return (' in {0}' if self.done else 'eta {0}').format(eta)
Пример #2
0
def bar(total, done, eta, title, color):
    lside = 'Epochs %s/%s' % (done, total)
    rside = 'ETA:%s' % eta_letters(eta, shortest=False)

    return make_bar_chart(done,
                          total,
                          color=color,
                          title=title,
                          left=lside.ljust(15),
                          right=rside.rjust(16))
Пример #3
0
 def str_eta(self):
     """Returns a formatted ETA value for the progress bar."""
     eta = eta_letters(self._eta.elapsed) if self.done else self._eta_string
     if not eta:
         return ''
     if eta.count(' ') > 1:
         eta = ' '.join(
             eta.split(' ')
             [:2])  # Only show up to two units (h and m, no s for example).
     return (' in {0}' if self.done else 'eta {0}').format(eta)
def test_shortest_and_leading_zero():
    assert '00s' == eta_letters(0, shortest=True, leading_zero=True)
    assert '09s' == eta_letters(9, shortest=True, leading_zero=True)

    assert '59s' == eta_letters(59, shortest=True, leading_zero=True)
    assert '01m' == eta_letters(60, shortest=True, leading_zero=True)
    assert '01m' == eta_letters(61, shortest=True, leading_zero=True)

    assert '59m' == eta_letters(3599, shortest=True, leading_zero=True)
    assert '1h' == eta_letters(3600, shortest=True, leading_zero=True)
    assert '1h' == eta_letters(3601, shortest=True, leading_zero=True)
    assert '1h' == eta_letters(3661, shortest=True, leading_zero=True)

    assert '6d' == eta_letters(604799, shortest=True, leading_zero=True)
    assert '1w' == eta_letters(604800, shortest=True, leading_zero=True)
    assert '1w' == eta_letters(604801, shortest=True, leading_zero=True)
def test_shortest():
    assert '0s' == eta_letters(0, shortest=True)
    assert '9s' == eta_letters(9, shortest=True)

    assert '59s' == eta_letters(59, shortest=True)
    assert '1m' == eta_letters(60, shortest=True)
    assert '1m' == eta_letters(61, shortest=True)

    assert '59m' == eta_letters(3599, shortest=True)
    assert '1h' == eta_letters(3600, shortest=True)
    assert '1h' == eta_letters(3601, shortest=True)
    assert '1h' == eta_letters(3661, shortest=True)

    assert '6d' == eta_letters(604799, shortest=True)
    assert '1w' == eta_letters(604800, shortest=True)
    assert '1w' == eta_letters(604801, shortest=True)
def test():
    assert '0s' == eta_letters(0)
    assert '9s' == eta_letters(9)

    assert '59s' == eta_letters(59)
    assert '1m 0s' == eta_letters(60)
    assert '1m 1s' == eta_letters(61)

    assert '59m 59s' == eta_letters(3599)
    assert '1h 0m 0s' == eta_letters(3600)
    assert '1h 0m 1s' == eta_letters(3601)
    assert '1h 1m 1s' == eta_letters(3661)

    assert '6d 23h 59m 59s' == eta_letters(604799)
    assert '1w 0d 0h 0m 0s' == eta_letters(604800)
    assert '1w 0d 0h 0m 1s' == eta_letters(604801)
def test_leading_zero():
    assert '00s' == eta_letters(0, leading_zero=True)
    assert '09s' == eta_letters(9, leading_zero=True)

    assert '59s' == eta_letters(59, leading_zero=True)
    assert '01m 00s' == eta_letters(60, leading_zero=True)
    assert '01m 01s' == eta_letters(61, leading_zero=True)

    assert '59m 59s' == eta_letters(3599, leading_zero=True)
    assert '1h 00m 00s' == eta_letters(3600, leading_zero=True)
    assert '1h 00m 01s' == eta_letters(3601, leading_zero=True)
    assert '1h 01m 01s' == eta_letters(3661, leading_zero=True)

    assert '6d 23h 59m 59s' == eta_letters(604799, leading_zero=True)
    assert '1w 0d 0h 00m 00s' == eta_letters(604800, leading_zero=True)
    assert '1w 0d 0h 00m 01s' == eta_letters(604801, leading_zero=True)
Пример #8
0
 def _generate_eta(seconds):
     """Returns a human readable ETA string."""
     return '' if seconds is None else eta_letters(seconds)
Пример #9
0
 def _generate_eta(seconds):
     """Returns a human readable ETA string."""
     return '' if seconds is None else eta_letters(seconds)