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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/command.py

Issue 2679393004: Fix all "dangerous-default-value" pylint warnings. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/style/optparser_unittest.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2016 Google Inc. All rights reserved. 1 # Copyright (c) 2016 Google Inc. All rights reserved.
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 are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 if self.long_help: 114 if self.long_help:
115 help_text += "%s\n\n" % self.long_help 115 help_text += "%s\n\n" % self.long_help
116 help_text += self.option_parser.format_option_help(optparse.IndentedHelp Formatter()) 116 help_text += self.option_parser.format_option_help(optparse.IndentedHelp Formatter())
117 return help_text 117 return help_text
118 118
119 def execute(self, options, args, tool): 119 def execute(self, options, args, tool):
120 raise NotImplementedError("subclasses must implement") 120 raise NotImplementedError("subclasses must implement")
121 121
122 # main() exists so that Commands can be turned into stand-alone scripts. 122 # main() exists so that Commands can be turned into stand-alone scripts.
123 # Other parts of the code will likely require modification to work stand-alo ne. 123 # Other parts of the code will likely require modification to work stand-alo ne.
124 def main(self, args=sys.argv): 124 def main(self, args=None):
125 (options, args) = self.parse_args(args) 125 options, args = self.parse_args(args)
126 # Some commands might require a dummy tool 126 # Some commands might require a dummy tool
127 return self.check_arguments_and_execute(options, args) 127 return self.check_arguments_and_execute(options, args)
128 128
129 129
130 class HelpPrintingOptionParser(optparse.OptionParser): 130 class HelpPrintingOptionParser(optparse.OptionParser):
131 131
132 def __init__(self, epilog_method=None, *args, **kwargs): 132 def __init__(self, epilog_method=None, *args, **kwargs):
133 self.epilog_method = epilog_method 133 self.epilog_method = epilog_method
134 optparse.OptionParser.__init__(self, *args, **kwargs) 134 optparse.OptionParser.__init__(self, *args, **kwargs)
135 135
136 def error(self, msg): 136 def error(self, msg):
137 self.print_usage(sys.stderr) 137 self.print_usage(sys.stderr)
138 error_message = "%s: error: %s\n" % (self.get_prog_name(), msg) 138 error_message = "%s: error: %s\n" % (self.get_prog_name(), msg)
139 # This method is overridden to add this one line to the output: 139 # This method is overridden to add this one line to the output:
140 error_message += "\nType \"%s --help\" to see usage.\n" % self.get_prog_ name() 140 error_message += "\nType \"%s --help\" to see usage.\n" % self.get_prog_ name()
141 self.exit(1, error_message) 141 self.exit(1, error_message)
142 142
143 # We override format_epilog to avoid the default formatting which would para graph-wrap the epilog 143 # We override format_epilog to avoid the default formatting which would para graph-wrap the epilog
144 # and also to allow us to compute the epilog lazily instead of in the constr uctor (allowing it to be context sensitive). 144 # and also to allow us to compute the epilog lazily instead of in the constr uctor (allowing it to be context sensitive).
145 def format_epilog(self, epilog): # pylint: disable=unused-argument 145 def format_epilog(self, epilog): # pylint: disable=unused-argument
146 if self.epilog_method: 146 if self.epilog_method:
147 return "\n%s\n" % self.epilog_method() 147 return "\n%s\n" % self.epilog_method()
148 return "" 148 return ""
OLDNEW
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/style/optparser_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698