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

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: add TODOs for Stephan 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
« no previous file with comments | « gm/rebaseline_server/imagepair.py ('k') | gm/rebaseline_server/server.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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'):
231 """Read all JSON dictionaries within a directory tree. 232 """Read all JSON dictionaries within a directory tree.
232 233
234 TODO(stephana): Factor this out into a utility module, as a standalone
235 function (not part of a class).
236
233 Args: 237 Args:
234 root: path to root of directory tree 238 root: path to root of directory tree
235 pattern: which files to read within root (fnmatch-style pattern) 239 pattern: which files to read within root (fnmatch-style pattern)
236 240
237 Returns: 241 Returns:
238 A meta-dictionary containing all the JSON dictionaries found within 242 A meta-dictionary containing all the JSON dictionaries found within
239 the directory tree, keyed by the pathname (relative to root) of each JSON 243 the directory tree, keyed by the pathname (relative to root) of each JSON
240 dictionary. 244 dictionary.
241 245
242 Raises: 246 Raises:
(...skipping 87 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 334 default_value: value to return if input_dict is None or any key cannot
331 be found along the way 335 be found along the way
332 """ 336 """
333 if input_dict == None: 337 if input_dict == None:
334 return default_value 338 return default_value
335 for key in keys: 339 for key in keys:
336 input_dict = input_dict.get(key, None) 340 input_dict = input_dict.get(key, None)
337 if input_dict == None: 341 if input_dict == None:
338 return default_value 342 return default_value
339 return input_dict 343 return input_dict
OLDNEW
« no previous file with comments | « gm/rebaseline_server/imagepair.py ('k') | gm/rebaseline_server/server.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698