diff options
author | Luis Lozano <llozano@chromium.org> | 2015-12-15 13:49:30 -0800 |
---|---|---|
committer | Luis Lozano <llozano@chromium.org> | 2015-12-16 17:36:06 +0000 |
commit | f2a3ef46f75d2196a93d3ed27f4d1fcf22b54fbe (patch) | |
tree | 185d243c7eed7c7a0db6f0e640746cadc1479ea9 /update_telemetry_defaults.py | |
parent | 2a66f70fef907c1cb15229cb58e5129cb620ac98 (diff) | |
download | toolchain-utils-f2a3ef46f75d2196a93d3ed27f4d1fcf22b54fbe.tar.gz |
Run pyformat on all the toolchain-utils files.
This gets rid of a lot of lint issues.
Ran by doing this:
for f in *.py; do echo -n "$f " ; if [ -x $f ]; then pyformat -i
--remove_trailing_comma --yapf --force_quote_type=double $f ; else
pyformat -i --remove_shebang --remove_trailing_comma --yapf
--force_quote_type=double $f ; fi ; done
BUG=chromium:567921
TEST=Ran simple crosperf run.
Change-Id: I59778835fdaa5f706d2e1765924389f9e97433d1
Reviewed-on: https://chrome-internal-review.googlesource.com/242031
Reviewed-by: Luis Lozano <llozano@chromium.org>
Commit-Queue: Luis Lozano <llozano@chromium.org>
Tested-by: Luis Lozano <llozano@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@google.com>
Diffstat (limited to 'update_telemetry_defaults.py')
-rwxr-xr-x | update_telemetry_defaults.py | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/update_telemetry_defaults.py b/update_telemetry_defaults.py index 33b96f6c..6d83e143 100755 --- a/update_telemetry_defaults.py +++ b/update_telemetry_defaults.py @@ -1,7 +1,6 @@ #!/usr/bin/python # # Copyright 2013 Google Inc. All Rights Reserved. - """Script to maintain the Telemetry benchmark default results file. This script allows the user to see and update the set of default @@ -10,7 +9,7 @@ benchmarks. """ -__author__ = "cmtice@google.com (Caroline Tice)" +__author__ = 'cmtice@google.com (Caroline Tice)' import os import sys @@ -33,87 +32,85 @@ class TelemetryDefaults(object): self._filename = fullname self._defaults = {} - def ReadDefaultsFile (self): + def ReadDefaultsFile(self): if os.path.exists(self._filename): - with open(self._filename, "r") as fp: + with open(self._filename, 'r') as fp: self._defaults = json.load(fp) - def WriteDefaultsFile (self): - with open(self._filename, "w") as fp: + def WriteDefaultsFile(self): + with open(self._filename, 'w') as fp: json.dump(self._defaults, fp, indent=2) - def ListCurrentDefaults (self, benchmark=all): + def ListCurrentDefaults(self, benchmark=all): # Show user current defaults. By default, show all. The user # can specify the name of a particular benchmark to see only that # benchmark's default values. if len(self._defaults) == 0: - print ("The benchmark default results are currently empty.") + print('The benchmark default results are currently empty.') if benchmark == all: for b in self._defaults.keys(): results = self._defaults[b] out_str = b + ' : ' for r in results: - out_str += r + ' ' - print (out_str) + out_str += r + ' ' + print(out_str) elif benchmark in self._defaults: results = self._defaults[benchmark] out_str = benchmark + ' : ' for r in results: - out_str += r + ' ' - print (out_str) + out_str += r + ' ' + print(out_str) else: - print ("Error: Unrecognized benchmark '%s'" % benchmark) - + print("Error: Unrecognized benchmark '%s'" % benchmark) - def AddDefault (self, benchmark, result): + def AddDefault(self, benchmark, result): if benchmark in self._defaults: resultList = self._defaults[benchmark] else: resultList = [] resultList.append(result) self._defaults[benchmark] = resultList - print ("Updated results set for '%s': " % benchmark) - print ("%s : %s" % (benchmark, repr(self._defaults[benchmark]))) + print("Updated results set for '%s': " % benchmark) + print('%s : %s' % (benchmark, repr(self._defaults[benchmark]))) - - def RemoveDefault (self, benchmark, result): + def RemoveDefault(self, benchmark, result): if benchmark in self._defaults: resultList = self._defaults[benchmark] if result in resultList: resultList.remove(result) - print ("Updated results set for '%s': " % benchmark) - print ("%s : %s" % (benchmark, repr(self._defaults[benchmark]))) + print("Updated results set for '%s': " % benchmark) + print('%s : %s' % (benchmark, repr(self._defaults[benchmark]))) else: - print ("'%s' is not in '%s's default results list." % - (result, benchmark)) + print("'%s' is not in '%s's default results list." % + (result, benchmark)) else: - print ("Cannot find benchmark named '%s'" % benchmark) + print("Cannot find benchmark named '%s'" % benchmark) - def GetDefault (self): + def GetDefault(self): return self._defaults - def RemoveBenchmark (self, benchmark): + def RemoveBenchmark(self, benchmark): if benchmark in self._defaults: del self._defaults[benchmark] - print ("Deleted benchmark '%s' from list of benchmarks." % benchmark) + print("Deleted benchmark '%s' from list of benchmarks." % benchmark) else: - print ("Cannot find benchmark named '%s'" % benchmark) + print("Cannot find benchmark named '%s'" % benchmark) - def RenameBenchmark (self, old_name, new_name): + def RenameBenchmark(self, old_name, new_name): if old_name in self._defaults: resultsList = self._defaults[old_name] del self._defaults[old_name] self._defaults[new_name] = resultsList - print ("Renamed '%s' to '%s'." % (old_name, new_name)) + print("Renamed '%s' to '%s'." % (old_name, new_name)) else: - print ("Cannot find benchmark named '%s'" % old_name) + print("Cannot find benchmark named '%s'" % old_name) def UsageError(self, user_input): # Print error message, then show options - print ("Error:Invalid user input: '%s'" % user_input) + print("Error:Invalid user input: '%s'" % user_input) self.ShowOptions() - def ShowOptions (self): + def ShowOptions(self): print """ Below are the valid user options and their arguments, and an explanation of what each option does. You may either print out the full name of the @@ -136,14 +133,14 @@ lower) does not matter, for the command (case of the result name DOES matter): """ - def GetUserInput (self): + def GetUserInput(self): # Prompt user - print ("Enter option> ") + print('Enter option> ') # Process user input inp = sys.stdin.readline() inp = inp[:-1] # inp = inp.lower() - words = inp.split(" ") + words = inp.split(' ') option = words[0] option = option.lower() if option == 'h' or option == 'help': @@ -155,7 +152,7 @@ lower) does not matter, for the command (case of the result name DOES matter): self.ListCurrentDefaults(benchmark=words[1]) elif option == 'a' or option == 'add': if len(words) < 3: - self.UsageError (inp) + self.UsageError(inp) else: benchmark = words[1] resultList = words[2:] @@ -163,20 +160,20 @@ lower) does not matter, for the command (case of the result name DOES matter): self.AddDefault(benchmark, r) elif option == 'd' or option == 'delete': if len(words) != 3: - self.UsageError (inp) + self.UsageError(inp) else: benchmark = words[1] result = words[2] self.RemoveDefault(benchmark, result) elif option == 'r' or option == 'remove': if len(words) != 2: - self.UsageError (inp) + self.UsageError(inp) else: benchmark = words[1] self.RemoveBenchmark(benchmark) elif option == 'm' or option == 'move': if len(words) != 3: - self.UsageError (inp) + self.UsageError(inp) else: old_name = words[1] new_name = words[2] @@ -197,6 +194,7 @@ def Main(): done = defaults.GetUserInput() return 0 -if __name__ == "__main__": + +if __name__ == '__main__': retval = Main() sys.exit(retval) |