| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 #!/usr/bin/env python |  | 
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |  | 
| 3 # Use of this source code is governed by a BSD-style license that can be |  | 
| 4 # found in the LICENSE file. |  | 
| 5 |  | 
| 6 '''Base class and interface for tools. |  | 
| 7 ''' |  | 
| 8 |  | 
| 9 |  | 
| 10 class Tool(object): |  | 
| 11   '''Base class for all tools.  Tools should use their docstring (i.e. the |  | 
| 12   class-level docstring) for the help they want to have printed when they |  | 
| 13   are invoked.''' |  | 
| 14 |  | 
| 15   # |  | 
| 16   # Interface (abstract methods) |  | 
| 17   # |  | 
| 18 |  | 
| 19   def ShortDescription(self): |  | 
| 20     '''Returns a short description of the functionality of the tool.''' |  | 
| 21     raise NotImplementedError() |  | 
| 22 |  | 
| 23   def Run(self, global_options, my_arguments): |  | 
| 24     '''Runs the tool. |  | 
| 25 |  | 
| 26     Args: |  | 
| 27       global_options: object grit_runner.Options |  | 
| 28       my_arguments: [arg1 arg2 ...] |  | 
| 29 |  | 
| 30     Return: |  | 
| 31       0 for success, non-0 for error |  | 
| 32     ''' |  | 
| 33     raise NotImplementedError() |  | 
| 34 |  | 
| 35   # |  | 
| 36   # Base class implementation |  | 
| 37   # |  | 
| 38 |  | 
| 39   def __init__(self): |  | 
| 40     self.o = None |  | 
| 41 |  | 
| 42   def SetOptions(self, opts): |  | 
| 43     self.o = opts |  | 
| 44 |  | 
| 45   def Out(self, text): |  | 
| 46     '''Always writes out 'text'.''' |  | 
| 47     self.o.output_stream.write(text) |  | 
| 48 |  | 
| 49   def VerboseOut(self, text): |  | 
| 50     '''Writes out 'text' if the verbose option is on.''' |  | 
| 51     if self.o.verbose: |  | 
| 52       self.o.output_stream.write(text) |  | 
| 53 |  | 
| 54   def ExtraVerboseOut(self, text): |  | 
| 55     '''Writes out 'text' if the extra-verbose option is on. |  | 
| 56     ''' |  | 
| 57     if self.o.extra_verbose: |  | 
| 58       self.o.output_stream.write(text) |  | 
| OLD | NEW | 
|---|