Commit 3641553d authored by Hanno Schlichting's avatar Hanno Schlichting

PEP8

parent b62b846e
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
# #
############################################################################## ##############################################################################
import time, sys import sys
import time
from logging import getLogger from logging import getLogger
from DateTime.DateTime import DateTime from DateTime.DateTime import DateTime
...@@ -20,8 +21,9 @@ from zope.interface import implements ...@@ -20,8 +21,9 @@ from zope.interface import implements
LOG = getLogger('ProgressHandler') LOG = getLogger('ProgressHandler')
class IProgressHandler(Interface): class IProgressHandler(Interface):
""" A handler to log progress informations for long running """ A handler to log progress informations for long running
operations. operations.
""" """
...@@ -30,7 +32,7 @@ class IProgressHandler(Interface): ...@@ -30,7 +32,7 @@ class IProgressHandler(Interface):
'ident' -- a string identifying the operation 'ident' -- a string identifying the operation
'max' -- maximum number of objects to be processed (int) 'max' -- maximum number of objects to be processed (int)
""" """
def info(text): def info(text):
""" Log some 'text'""" """ Log some 'text'"""
...@@ -41,12 +43,12 @@ class IProgressHandler(Interface): ...@@ -41,12 +43,12 @@ class IProgressHandler(Interface):
def report(current, *args, **kw): def report(current, *args, **kw):
""" Called for every iteration. """ Called for every iteration.
'current' -- an integer representing the number of objects 'current' -- an integer representing the number of objects
processed so far. processed so far.
""" """
def output(text): def output(text):
""" Log 'text' to some output channel """ """ Log 'text' to some output channel """
class StdoutHandler: class StdoutHandler:
...@@ -73,12 +75,14 @@ class StdoutHandler: ...@@ -73,12 +75,14 @@ class StdoutHandler:
def report(self, current, *args, **kw): def report(self, current, *args, **kw):
if current > 0: if current > 0:
if current % self._steps == 0: if current % self._steps == 0:
seconds_so_far = time.time() - self._start seconds_so_far = time.time() - self._start
seconds_to_go = seconds_so_far / current * (self._max - current) seconds_to_go = (seconds_so_far / current *
(self._max - current))
end = DateTime(time.time() + seconds_to_go)
self.output('%d/%d (%.2f%%) Estimated termination: %s' % \ self.output('%d/%d (%.2f%%) Estimated termination: %s' % \
(current, self._max, (100.0 * current / self._max), (current, self._max, (100.0 * current / self._max),
DateTime(time.time() + seconds_to_go).strftime('%Y/%m/%d %H:%M:%Sh'))) end.strftime('%Y/%m/%d %H:%M:%Sh')))
def output(self, text): def output(self, text):
print >>self.fp, '%s: %s' % (self._ident, text) print >>self.fp, '%s: %s' % (self._ident, text)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment