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

Side by Side Diff: grit/tool/interface.py

Issue 7994004: Initial source commit to grit-i18n project. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « grit/tool/diff_structures.py ('k') | grit/tool/menu_from_parts.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 #!/usr/bin/python2.4
2 # Copyright (c) 2006-2008 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 import sys
10
11 class Tool(object):
12 '''Base class for all tools. Tools should use their docstring (i.e. the
13 class-level docstring) for the help they want to have printed when they
14 are invoked.'''
15
16 #
17 # Interface (abstract methods)
18 #
19
20 def ShortDescription(self):
21 '''Returns a short description of the functionality of the tool.'''
22 raise NotImplementedError()
23
24 def Run(self, global_options, my_arguments):
25 '''Runs the tool.
26
27 Args:
28 global_options: object grit_runner.Options
29 my_arguments: [arg1 arg2 ...]
30
31 Return:
32 0 for success, non-0 for error
33 '''
34 raise NotImplementedError()
35
36 #
37 # Base class implementation
38 #
39
40 def __init__(self):
41 self.o = None
42
43 def SetOptions(self, opts):
44 self.o = opts
45
46 def Out(self, text):
47 '''Always writes out 'text'.'''
48 self.o.output_stream.write(text)
49
50 def VerboseOut(self, text):
51 '''Writes out 'text' if the verbose option is on.'''
52 if self.o.verbose:
53 self.o.output_stream.write(text)
54
55 def ExtraVerboseOut(self, text):
56 '''Writes out 'text' if the extra-verbose option is on.
57 '''
58 if self.o.extra_verbose:
59 self.o.output_stream.write(text)
OLDNEW
« no previous file with comments | « grit/tool/diff_structures.py ('k') | grit/tool/menu_from_parts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698