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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/models/test_configuration.py

Issue 1806393002: Run yapf on files in webkit/layout_tests/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 29 matching lines...) Expand all
40 """The most common human-readable order in which the configuration prope rties are listed.""" 40 """The most common human-readable order in which the configuration prope rties are listed."""
41 return ['version', 'architecture', 'build_type'] 41 return ['version', 'architecture', 'build_type']
42 42
43 def items(self): 43 def items(self):
44 return self.__dict__.items() 44 return self.__dict__.items()
45 45
46 def keys(self): 46 def keys(self):
47 return self.__dict__.keys() 47 return self.__dict__.keys()
48 48
49 def __str__(self): 49 def __str__(self):
50 return ("<%(version)s, %(architecture)s, %(build_type)s>" % 50 return ("<%(version)s, %(architecture)s, %(build_type)s>" % self.__dict_ _)
51 self.__dict__)
52 51
53 def __repr__(self): 52 def __repr__(self):
54 return "TestConfig(version='%(version)s', architecture='%(architecture)s ', build_type='%(build_type)s')" % self.__dict__ 53 return "TestConfig(version='%(version)s', architecture='%(architecture)s ', build_type='%(build_type)s')" % self.__dict__
55 54
56 def __hash__(self): 55 def __hash__(self):
57 return hash(self.version + self.architecture + self.build_type) 56 return hash(self.version + self.architecture + self.build_type)
58 57
59 def __eq__(self, other): 58 def __eq__(self, other):
60 return self.__hash__() == other.__hash__() 59 return self.__hash__() == other.__hash__()
61 60
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 # FIXME: This seems extra-awful. 125 # FIXME: This seems extra-awful.
127 for cat2, spec2 in configuration.items(): 126 for cat2, spec2 in configuration.items():
128 if category == cat2: 127 if category == cat2:
129 continue 128 continue
130 matching_sets_by_category.setdefault(specifier, {}).setdefau lt(cat2, set()).add(spec2) 129 matching_sets_by_category.setdefault(specifier, {}).setdefau lt(cat2, set()).add(spec2)
131 for collapsing_set in self._collapsing_sets_by_category.values(): 130 for collapsing_set in self._collapsing_sets_by_category.values():
132 self._collapsing_sets_by_size.setdefault(len(collapsing_set), set()) .add(frozenset(collapsing_set)) 131 self._collapsing_sets_by_size.setdefault(len(collapsing_set), set()) .add(frozenset(collapsing_set))
133 132
134 for specifier, sets_by_category in matching_sets_by_category.items(): 133 for specifier, sets_by_category in matching_sets_by_category.items():
135 for category, set_by_category in sets_by_category.items(): 134 for category, set_by_category in sets_by_category.items():
136 if len(set_by_category) == 1 and self._specifier_sorter.category _priority(category) > self._specifier_sorter.specifier_priority(specifier): 135 if len(set_by_category) == 1 and self._specifier_sorter.category _priority(
136 category) > self._specifier_sorter.specifier_priority(sp ecifier):
137 self._junk_specifier_combinations[specifier] = set_by_catego ry 137 self._junk_specifier_combinations[specifier] = set_by_catego ry
138 138
139 self._specifier_sorter.add_macros(configuration_macros) 139 self._specifier_sorter.add_macros(configuration_macros)
140 140
141 def specifier_sorter(self): 141 def specifier_sorter(self):
142 return self._specifier_sorter 142 return self._specifier_sorter
143 143
144 def _expand_macros(self, specifier): 144 def _expand_macros(self, specifier):
145 expanded_specifiers = self._configuration_macros.get(specifier) 145 expanded_specifiers = self._configuration_macros.get(specifier)
146 return expanded_specifiers or [specifier] 146 return expanded_specifiers or [specifier]
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 specifiers_list.remove(item) 275 specifiers_list.remove(item)
276 specifiers_list.append(frozenset(common | diff)) 276 specifiers_list.append(frozenset(common | diff))
277 return True 277 return True
278 return False 278 return False
279 279
280 # 3) Abbreviate specifier sets by combining specifiers across categories . 280 # 3) Abbreviate specifier sets by combining specifiers across categories .
281 # (win7, release), (win10, release) --> (win7, win10, release) 281 # (win7, release), (win10, release) --> (win7, win10, release)
282 while try_abbreviating(self._collapsing_sets_by_size.values()): 282 while try_abbreviating(self._collapsing_sets_by_size.values()):
283 pass 283 pass
284 284
285
286 # 4) Substitute specifier subsets that match macros witin each set: 285 # 4) Substitute specifier subsets that match macros witin each set:
287 # (win7, win10, release) -> (win, release) 286 # (win7, win10, release) -> (win, release)
288 self.collapse_macros(self._configuration_macros, specifiers_list) 287 self.collapse_macros(self._configuration_macros, specifiers_list)
289 288
290 macro_keys = set(self._configuration_macros.keys()) 289 macro_keys = set(self._configuration_macros.keys())
291 290
292 # 5) Collapsing macros may have created combinations the can now be abbr eviated. 291 # 5) Collapsing macros may have created combinations the can now be abbr eviated.
293 # (win7, release), (linux, x86, release), (linux, x86_64, release) --> (win7, release), (linux, release) --> (win7, linux, release) 292 # (win7, release), (linux, x86, release), (linux, x86_64, release) --> (win7, release), (linux, release) --> (win7, linux, release)
294 while try_abbreviating([self._collapsing_sets_by_category['version'] | m acro_keys]): 293 while try_abbreviating([self._collapsing_sets_by_category['version'] | m acro_keys]):
295 pass 294 pass
296 295
297 # 6) Remove cases where we have collapsed but have all macros. 296 # 6) Remove cases where we have collapsed but have all macros.
298 # (android, win, mac, linux, release) --> (release) 297 # (android, win, mac, linux, release) --> (release)
299 specifiers_to_remove = [] 298 specifiers_to_remove = []
300 for specifier_set in specifiers_list: 299 for specifier_set in specifiers_list:
301 if macro_keys <= specifier_set: 300 if macro_keys <= specifier_set:
302 specifiers_to_remove.append(specifier_set) 301 specifiers_to_remove.append(specifier_set)
303 302
304 for specifier_set in specifiers_to_remove: 303 for specifier_set in specifiers_to_remove:
305 specifiers_list.remove(specifier_set) 304 specifiers_list.remove(specifier_set)
306 specifiers_list.append(frozenset(specifier_set - macro_keys)) 305 specifiers_list.append(frozenset(specifier_set - macro_keys))
307 306
308 return specifiers_list 307 return specifiers_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698