OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Access the commit queue from the command line. | 6 """Access the commit queue from the command line. |
7 """ | 7 """ |
8 | 8 |
9 __version__ = '0.1' | 9 __version__ = '0.1' |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 ## Boilerplate code | 103 ## Boilerplate code |
104 | 104 |
105 | 105 |
106 def gen_parser(): | 106 def gen_parser(): |
107 """Returns an OptionParser instance with default options. | 107 """Returns an OptionParser instance with default options. |
108 | 108 |
109 It should be then processed with gen_usage() before being used. | 109 It should be then processed with gen_usage() before being used. |
110 """ | 110 """ |
111 parser = optparse.OptionParser(version=__version__) | 111 parser = optparse.OptionParser(version=__version__) |
112 # Remove description formatting | 112 # Remove description formatting |
113 parser.format_description = lambda x: parser.description | 113 parser.format_description = ( |
| 114 lambda _: parser.description) # pylint: disable=E1101 |
114 # Add common parsing. | 115 # Add common parsing. |
115 old_parser_args = parser.parse_args | 116 old_parser_args = parser.parse_args |
116 | 117 |
117 def Parse(*args, **kwargs): | 118 def Parse(*args, **kwargs): |
118 options, args = old_parser_args(*args, **kwargs) | 119 options, args = old_parser_args(*args, **kwargs) |
119 logging.basicConfig( | 120 logging.basicConfig( |
120 level=[logging.WARNING, logging.INFO, logging.DEBUG][ | 121 level=[logging.WARNING, logging.INFO, logging.DEBUG][ |
121 min(2, options.verbose)], | 122 min(2, options.verbose)], |
122 format='%(levelname)s %(filename)s(%(lineno)d): %(message)s') | 123 format='%(levelname)s %(filename)s(%(lineno)d): %(message)s') |
123 return options, args | 124 return options, args |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 return command(parser, args[1:]) | 179 return command(parser, args[1:]) |
179 | 180 |
180 # Not a known command. Default to help. | 181 # Not a known command. Default to help. |
181 gen_usage(parser, 'help') | 182 gen_usage(parser, 'help') |
182 return CMDhelp(parser, args) | 183 return CMDhelp(parser, args) |
183 | 184 |
184 | 185 |
185 if __name__ == "__main__": | 186 if __name__ == "__main__": |
186 fix_encoding.fix_encoding() | 187 fix_encoding.fix_encoding() |
187 sys.exit(main()) | 188 sys.exit(main()) |
OLD | NEW |