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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/baselineoptimizer.py

Issue 1839193004: Run auto-formatter (autopep8) on webkitpy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 8 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
OLDNEW
1 # Copyright (C) 2011, Google Inc. All rights reserved. 1 # Copyright (C) 2011, 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 # to the baseline in the platform directory, we need to append jsut foo- expected.png to the directory. 97 # to the baseline in the platform directory, we need to append jsut foo- expected.png to the directory.
98 virtual_suite = self._virtual_suite(baseline_name) 98 virtual_suite = self._virtual_suite(baseline_name)
99 if virtual_suite: 99 if virtual_suite:
100 baseline_name_without_virtual = baseline_name[len(virtual_suite.name ) + 1:] 100 baseline_name_without_virtual = baseline_name[len(virtual_suite.name ) + 1:]
101 else: 101 else:
102 baseline_name_without_virtual = baseline_name 102 baseline_name_without_virtual = baseline_name
103 return self._filesystem.join(self._webkit_base, directory, baseline_name _without_virtual) 103 return self._filesystem.join(self._webkit_base, directory, baseline_name _without_virtual)
104 104
105 def read_results_by_directory(self, baseline_name): 105 def read_results_by_directory(self, baseline_name):
106 results_by_directory = {} 106 results_by_directory = {}
107 directories = reduce(set.union, map(set, [self._relative_baseline_search _paths(port, baseline_name) for port in self._ports.values()])) 107 directories = reduce(set.union, map(set, [self._relative_baseline_search _paths(
108 port, baseline_name) for port in self._ports.values()]))
108 109
109 for directory in directories: 110 for directory in directories:
110 path = self._join_directory(directory, baseline_name) 111 path = self._join_directory(directory, baseline_name)
111 if self._filesystem.exists(path): 112 if self._filesystem.exists(path):
112 results_by_directory[directory] = self._filesystem.sha1(path) 113 results_by_directory[directory] = self._filesystem.sha1(path)
113 return results_by_directory 114 return results_by_directory
114 115
115 def _results_by_port_name(self, results_by_directory, baseline_name): 116 def _results_by_port_name(self, results_by_directory, baseline_name):
116 results_by_port_name = {} 117 results_by_port_name = {}
117 for port_name, port in self._ports.items(): 118 for port_name, port in self._ports.items():
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 164
164 new_results_by_directory[baseline_root] = shared_result 165 new_results_by_directory[baseline_root] = shared_result
165 for directory in directories_immediately_preceding_root: 166 for directory in directories_immediately_preceding_root:
166 del new_results_by_directory[directory] 167 del new_results_by_directory[directory]
167 168
168 def _find_optimal_result_placement(self, baseline_name): 169 def _find_optimal_result_placement(self, baseline_name):
169 results_by_directory = self.read_results_by_directory(baseline_name) 170 results_by_directory = self.read_results_by_directory(baseline_name)
170 results_by_port_name = self._results_by_port_name(results_by_directory, baseline_name) 171 results_by_port_name = self._results_by_port_name(results_by_directory, baseline_name)
171 port_names_by_result = _invert_dictionary(results_by_port_name) 172 port_names_by_result = _invert_dictionary(results_by_port_name)
172 173
173 new_results_by_directory = self._remove_redundant_results(results_by_dir ectory, results_by_port_name, port_names_by_result, baseline_name) 174 new_results_by_directory = self._remove_redundant_results(
175 results_by_directory, results_by_port_name, port_names_by_result, ba seline_name)
174 self._optimize_result_for_root(new_results_by_directory, baseline_name) 176 self._optimize_result_for_root(new_results_by_directory, baseline_name)
175 177
176 return results_by_directory, new_results_by_directory 178 return results_by_directory, new_results_by_directory
177 179
178 def _remove_redundant_results(self, results_by_directory, results_by_port_na me, port_names_by_result, baseline_name): 180 def _remove_redundant_results(self, results_by_directory, results_by_port_na me, port_names_by_result, baseline_name):
179 new_results_by_directory = copy.copy(results_by_directory) 181 new_results_by_directory = copy.copy(results_by_directory)
180 for port_name, port in self._ports.items(): 182 for port_name, port in self._ports.items():
181 current_result = results_by_port_name.get(port_name) 183 current_result = results_by_port_name.get(port_name)
182 184
183 # This happens if we're missing baselines for a port. 185 # This happens if we're missing baselines for a port.
184 if not current_result: 186 if not current_result:
185 continue; 187 continue
186 188
187 fallback_path = self._relative_baseline_search_paths(port, baseline_ name) 189 fallback_path = self._relative_baseline_search_paths(port, baseline_ name)
188 current_index, current_directory = self._find_in_fallbackpath(fallba ck_path, current_result, new_results_by_directory) 190 current_index, current_directory = self._find_in_fallbackpath(fallba ck_path, current_result, new_results_by_directory)
189 for index in range(current_index + 1, len(fallback_path)): 191 for index in range(current_index + 1, len(fallback_path)):
190 new_directory = fallback_path[index] 192 new_directory = fallback_path[index]
191 if not new_directory in new_results_by_directory: 193 if not new_directory in new_results_by_directory:
192 # No result for this baseline in this directory. 194 # No result for this baseline in this directory.
193 continue 195 continue
194 elif new_results_by_directory[new_directory] == current_result: 196 elif new_results_by_directory[new_directory] == current_result:
195 # Result for new_directory are redundant with the result ear lier in the fallback order. 197 # Result for new_directory are redundant with the result ear lier in the fallback order.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 result = self._optimize_subtree(baseline_name) 351 result = self._optimize_subtree(baseline_name)
350 non_virtual_baseline_name = self._virtual_base(baseline_name) 352 non_virtual_baseline_name = self._virtual_base(baseline_name)
351 if not non_virtual_baseline_name: 353 if not non_virtual_baseline_name:
352 return result, self._files_to_delete, self._files_to_add 354 return result, self._files_to_delete, self._files_to_add
353 355
354 self._optimize_virtual_root(baseline_name, non_virtual_baseline_name) 356 self._optimize_virtual_root(baseline_name, non_virtual_baseline_name)
355 357
356 _log.debug("Optimizing non-virtual fallback path.") 358 _log.debug("Optimizing non-virtual fallback path.")
357 result |= self._optimize_subtree(non_virtual_baseline_name) 359 result |= self._optimize_subtree(non_virtual_baseline_name)
358 return result, self._files_to_delete, self._files_to_add 360 return result, self._files_to_delete, self._files_to_add
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698