Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Python utils.""" | 5 """Python utils.""" |
| 6 | 6 |
| 7 import os | |
| 8 import sys | |
| 9 | |
| 7 | 10 |
| 8 def overrides(parent_class): | 11 def overrides(parent_class): |
| 9 """Inherits the docstring from the method of the same name in the indicated | 12 """Inherits the docstring from the method of the same name in the indicated |
| 10 parent class. | 13 parent class. |
| 11 """ | 14 """ |
| 12 def overriding(method): | 15 def overriding(method): |
| 13 assert(method.__name__ in dir(parent_class)) | 16 assert(method.__name__ in dir(parent_class)) |
| 14 method.__doc__ = getattr(parent_class, method.__name__).__doc__ | 17 method.__doc__ = getattr(parent_class, method.__name__).__doc__ |
| 15 return method | 18 return method |
| 16 return overriding | 19 return overriding |
| 20 | |
| 21 | |
| 22 def disable_output_buffering(): | |
| 23 """Disables the buffering of the stdout. Devtools command line scripts should | |
| 24 do so, so that their stdout is consistent when not directly attached to a | |
| 25 terminal (e.g. because another script runs devtools in a subprocess). | |
| 26 """ | |
| 27 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) | |
|
qsr
2016/05/10 16:15:21
How portable is this? Does this work on every plat
ppi
2016/05/10 16:17:08
Good question - I will check that it works on Mac
ppi
2016/05/11 11:21:29
Mac seems to be happy w/ this.
| |
| OLD | NEW |