| OLD | NEW |
| 1 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) | 1 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions | 4 # modification, are permitted provided that the following conditions |
| 5 # are met: | 5 # are met: |
| 6 # 1. Redistributions of source code must retain the above copyright | 6 # 1. Redistributions of source code must retain the above copyright |
| 7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
| 8 # 2. Redistributions in binary form must reproduce the above copyright | 8 # 2. Redistributions in binary form must reproduce the above copyright |
| 9 # notice, this list of conditions and the following disclaimer in the | 9 # notice, this list of conditions and the following disclaimer in the |
| 10 # documentation and/or other materials provided with the distribution. | 10 # documentation and/or other materials provided with the distribution. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 min_confidence: An integer between 1 and 5 inclusive that is the | 136 min_confidence: An integer between 1 and 5 inclusive that is the |
| 137 minimum confidence level of style errors to report. | 137 minimum confidence level of style errors to report. |
| 138 The default is 1, which reports all errors. | 138 The default is 1, which reports all errors. |
| 139 | 139 |
| 140 output_format: A string that is the output format. The supported | 140 output_format: A string that is the output format. The supported |
| 141 output formats are "emacs" which emacs can parse | 141 output formats are "emacs" which emacs can parse |
| 142 and "vs7" which Microsoft Visual Studio 7 can parse. | 142 and "vs7" which Microsoft Visual Studio 7 can parse. |
| 143 | 143 |
| 144 """ | 144 """ |
| 145 |
| 145 def __init__(self, | 146 def __init__(self, |
| 146 filter_rules=None, | 147 filter_rules=None, |
| 147 git_commit=None, | 148 git_commit=None, |
| 148 diff_files=None, | 149 diff_files=None, |
| 149 is_verbose=False, | 150 is_verbose=False, |
| 150 min_confidence=1, | 151 min_confidence=1, |
| 151 output_format="emacs"): | 152 output_format="emacs"): |
| 152 if filter_rules is None: | 153 if filter_rules is None: |
| 153 filter_rules = [] | 154 filter_rules = [] |
| 154 | 155 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 def __ne__(self, other): | 192 def __ne__(self, other): |
| 192 # Python does not automatically deduce this from __eq__(). | 193 # Python does not automatically deduce this from __eq__(). |
| 193 return not self.__eq__(other) | 194 return not self.__eq__(other) |
| 194 | 195 |
| 195 | 196 |
| 196 class ArgumentPrinter(object): | 197 class ArgumentPrinter(object): |
| 197 | 198 |
| 198 """Supports the printing of check-webkit-style command arguments.""" | 199 """Supports the printing of check-webkit-style command arguments.""" |
| 199 | 200 |
| 200 def _flag_pair_to_string(self, flag_key, flag_value): | 201 def _flag_pair_to_string(self, flag_key, flag_value): |
| 201 return '--%(key)s=%(val)s' % {'key': flag_key, 'val': flag_value } | 202 return '--%(key)s=%(val)s' % {'key': flag_key, 'val': flag_value} |
| 202 | 203 |
| 203 def to_flag_string(self, options): | 204 def to_flag_string(self, options): |
| 204 """Return a flag string of the given CommandOptionValues instance. | 205 """Return a flag string of the given CommandOptionValues instance. |
| 205 | 206 |
| 206 This method orders the flag values alphabetically by the flag key. | 207 This method orders the flag values alphabetically by the flag key. |
| 207 | 208 |
| 208 Args: | 209 Args: |
| 209 options: A CommandOptionValues instance. | 210 options: A CommandOptionValues instance. |
| 210 | 211 |
| 211 """ | 212 """ |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 usage = _USAGE | 282 usage = _USAGE |
| 282 | 283 |
| 283 self._all_categories = all_categories | 284 self._all_categories = all_categories |
| 284 self._base_filter_rules = base_filter_rules | 285 self._base_filter_rules = base_filter_rules |
| 285 | 286 |
| 286 # FIXME: Rename these to reflect that they are internal. | 287 # FIXME: Rename these to reflect that they are internal. |
| 287 self.default_options = default_options | 288 self.default_options = default_options |
| 288 self.stderr_write = stderr.write | 289 self.stderr_write = stderr.write |
| 289 | 290 |
| 290 self._parser = self._create_option_parser(stderr=stderr, | 291 self._parser = self._create_option_parser(stderr=stderr, |
| 291 usage=usage, | 292 usage=usage, |
| 292 default_min_confidence=self.default_options.min_confidence, | 293 default_min_confidence=self.de
fault_options.min_confidence, |
| 293 default_output_format=self.default_options.output_format) | 294 default_output_format=self.def
ault_options.output_format) |
| 294 | 295 |
| 295 def _create_option_parser(self, stderr, usage, | 296 def _create_option_parser(self, stderr, usage, |
| 296 default_min_confidence, default_output_format): | 297 default_min_confidence, default_output_format): |
| 297 # Since the epilog string is short, it is not necessary to replace | 298 # Since the epilog string is short, it is not necessary to replace |
| 298 # the epilog string with a mock epilog string when testing. | 299 # the epilog string with a mock epilog string when testing. |
| 299 # For this reason, we use _EPILOG directly rather than passing it | 300 # For this reason, we use _EPILOG directly rather than passing it |
| 300 # as an argument like we do for the usage string. | 301 # as an argument like we do for the usage string. |
| 301 parser = OptionParser(usage=usage, epilog=_EPILOG) | 302 parser = OptionParser(usage=usage, epilog=_EPILOG) |
| 302 | 303 |
| 303 filter_help = ('set a filter to control what categories of style ' | 304 filter_help = ('set a filter to control what categories of style ' |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 self._parse_error(err) | 448 self._parse_error(err) |
| 448 | 449 |
| 449 options = CommandOptionValues(filter_rules=filter_rules, | 450 options = CommandOptionValues(filter_rules=filter_rules, |
| 450 git_commit=git_commit, | 451 git_commit=git_commit, |
| 451 diff_files=diff_files, | 452 diff_files=diff_files, |
| 452 is_verbose=is_verbose, | 453 is_verbose=is_verbose, |
| 453 min_confidence=min_confidence, | 454 min_confidence=min_confidence, |
| 454 output_format=output_format) | 455 output_format=output_format) |
| 455 | 456 |
| 456 return (paths, options) | 457 return (paths, options) |
| 457 | |
| OLD | NEW |