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

Side by Side Diff: gm/rebaseline_server/results.py

Issue 487853004: rebaseline_server: allow users to generate SKP diff patches on a shared instance (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 4 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 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 """ 3 """
4 Copyright 2013 Google Inc. 4 Copyright 2013 Google Inc.
5 5
6 Use of this source code is governed by a BSD-style license that can be 6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file. 7 found in the LICENSE file.
8 8
9 Repackage expected/actual GM results as needed by our HTML rebaseline viewer. 9 Repackage expected/actual GM results as needed by our HTML rebaseline viewer.
10 """ 10 """
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 pattern: which files to read within root (fnmatch-style pattern) 206 pattern: which files to read within root (fnmatch-style pattern)
207 207
208 Returns: 208 Returns:
209 A meta-dictionary containing all the JSON dictionaries found within 209 A meta-dictionary containing all the JSON dictionaries found within
210 the directory tree, keyed by builder name (the basename of the directory 210 the directory tree, keyed by builder name (the basename of the directory
211 where each JSON dictionary was found). 211 where each JSON dictionary was found).
212 212
213 Raises: 213 Raises:
214 IOError if root does not refer to an existing directory 214 IOError if root does not refer to an existing directory
215 """ 215 """
216 # I considered making this call _read_dicts_from_root(), but I decided 216 # I considered making this call read_dicts_from_root(), but I decided
217 # it was better to prune out the ignored builders within the os.walk(). 217 # it was better to prune out the ignored builders within the os.walk().
218 if not os.path.isdir(root): 218 if not os.path.isdir(root):
219 raise IOError('no directory found at path %s' % root) 219 raise IOError('no directory found at path %s' % root)
220 meta_dict = {} 220 meta_dict = {}
221 for dirpath, _, filenames in os.walk(root): 221 for dirpath, _, filenames in os.walk(root):
222 for matching_filename in fnmatch.filter(filenames, pattern): 222 for matching_filename in fnmatch.filter(filenames, pattern):
223 builder = os.path.basename(dirpath) 223 builder = os.path.basename(dirpath)
224 if self._ignore_builder(builder): 224 if self._ignore_builder(builder):
225 continue 225 continue
226 full_path = os.path.join(dirpath, matching_filename) 226 full_path = os.path.join(dirpath, matching_filename)
227 meta_dict[builder] = gm_json.LoadFromFile(full_path) 227 meta_dict[builder] = gm_json.LoadFromFile(full_path)
228 return meta_dict 228 return meta_dict
229 229
230 def _read_dicts_from_root(self, root, pattern='*.json'): 230 @staticmethod
231 def read_dicts_from_root(root, pattern='*.json'):
stephana 2014/08/20 14:27:28 This is a nit, and not necessary to change, but IM
epoger 2014/08/20 14:33:57 Sounds like a good idea. Added a TODO.
231 """Read all JSON dictionaries within a directory tree. 232 """Read all JSON dictionaries within a directory tree.
232 233
233 Args: 234 Args:
234 root: path to root of directory tree 235 root: path to root of directory tree
235 pattern: which files to read within root (fnmatch-style pattern) 236 pattern: which files to read within root (fnmatch-style pattern)
236 237
237 Returns: 238 Returns:
238 A meta-dictionary containing all the JSON dictionaries found within 239 A meta-dictionary containing all the JSON dictionaries found within
239 the directory tree, keyed by the pathname (relative to root) of each JSON 240 the directory tree, keyed by the pathname (relative to root) of each JSON
240 dictionary. 241 dictionary.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 default_value: value to return if input_dict is None or any key cannot 331 default_value: value to return if input_dict is None or any key cannot
331 be found along the way 332 be found along the way
332 """ 333 """
333 if input_dict == None: 334 if input_dict == None:
334 return default_value 335 return default_value
335 for key in keys: 336 for key in keys:
336 input_dict = input_dict.get(key, None) 337 input_dict = input_dict.get(key, None)
337 if input_dict == None: 338 if input_dict == None:
338 return default_value 339 return default_value
339 return input_dict 340 return input_dict
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698