Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: webkit/tools/layout_tests/layout_package/metered_stream.py

Issue 545145: Move the layout test scripts into a 'webkitpy' subdirectory in preparation... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: try to de-confuse svn and the try bots Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/tools/layout_tests/layout_package/metered_stream.py
===================================================================
--- webkit/tools/layout_tests/layout_package/metered_stream.py (revision 36724)
+++ webkit/tools/layout_tests/layout_package/metered_stream.py (working copy)
@@ -1,72 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2009 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""
-Package that implements a stream wrapper that has 'meters' as well as
-regular output. A 'meter' is a single line of text that can be erased
-and rewritten repeatedly, without producing multiple lines of output. It
-can be used to produce effects like progress bars.
-"""
-
-
-class MeteredStream:
- """This class is a wrapper around a stream that allows you to implement
- meters.
-
- It can be used like a stream, but calling update() will print
- the string followed by only a carriage return (instead of a carriage
- return and a line feed). This can be used to implement progress bars and
- other sorts of meters. Note that anything written by update() will be
- erased by a subsequent update(), write(), or flush()."""
-
- def __init__(self, verbose, stream):
- """
- Args:
- verbose: whether update is a no-op
- stream: output stream to write to
- """
- self._dirty = False
- self._verbose = verbose
- self._stream = stream
- self._last_update = ""
-
- def write(self, txt):
- """Write text directly to the stream, overwriting and resetting the
- meter."""
- if self._dirty:
- self.update("")
- self._dirty = False
- self._stream.write(txt)
-
- def flush(self):
- """Flush any buffered output."""
- self._stream.flush()
-
- def update(self, str):
- """Write an update to the stream that will get overwritten by the next
- update() or by a write().
-
- This is used for progress updates that don't need to be preserved in
- the log. Note that verbose disables this routine; we have this in
- case we are logging lots of output and the update()s will get lost
- or won't work properly (typically because verbose streams are
- redirected to files.
-
- TODO(dpranke): figure out if there is a way to detect if we're writing
- to a stream that handles CRs correctly (e.g., terminals). That might
- be a cleaner way of handling this.
- """
- if self._verbose:
- return
-
- # Print the necessary number of backspaces to erase the previous
- # message.
- self._stream.write("\b" * len(self._last_update))
- self._stream.write(str)
- num_remaining = len(self._last_update) - len(str)
- if num_remaining > 0:
- self._stream.write(" " * num_remaining + "\b" * num_remaining)
- self._last_update = str
- self._dirty = True
« no previous file with comments | « webkit/tools/layout_tests/layout_package/lighttpd.conf ('k') | webkit/tools/layout_tests/layout_package/path_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698