On Friday, March 21, 2014 13:55:10 Thomas Wood wrote: > If the new summary line is shorter than the previous one, clear the > remaining characters. > > Signed-off-by: Thomas Wood <[email protected]> > --- > framework/log.py | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > > diff --git a/framework/log.py b/framework/log.py > index cdc3e94..96f757e 100644 > --- a/framework/log.py > +++ b/framework/log.py > @@ -41,6 +41,8 @@ class Log(object): > self.__summary_keys = set(['pass', 'fail', 'warn', 'crash', 'skip', > 'dmesg-warn', 'dmesg-fail', 'dry-run', 'timeout']) self.__summary > > collections.defaultdict(lambda: 0) > + self.__verbose = verbose
Am I missing something or is this unused?
> + self.__lastlength = 0
>
> self.__output = "[{percent}] {summary} {running}\r"
> if verbose:
> @@ -64,11 +66,19 @@ class Log(object):
>
> def __print(self, name, result):
> """ Do the actual printing """
> - sys.stdout.write(self.__output.format(**{'percent':
> self._percent(), -
> 'running': self._running(), -
> 'summary': self._summary(), -
> 'name': name,
> - 'result': result}))
> + output = self.__output.format(**{'percent': self._percent(),
> + 'running': self._running(),
> + 'summary': self._summary(),
> + 'name': name,
> + 'result': result})
> +
> + length = len(output)
> + if self.__lastlength > length:
> + output = output[:-1] + (" " * (self.__lastlength - length)) +
> '\r' +
I think using str.format() would make this more readable:
output = "{0}{1}\n".format(output[:-1], " " * (self.__lastlength - length))
Personally I would use a generator:
" ".join('' for x in xrange(self.__lastlength - length)), but there is nothing
wrong with what you did, consider it nothing more than a suggestion
> + self.__lastlength = length
> +
> + sys.stdout.write(output)
>
> # Need to flush explicitly, otherwise it all gets buffered without
> a # newline.
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
