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

Side by Side Diff: tools/telemetry/catapult_base/dependency_manager/local_path_info.py

Issue 1620023002: Revert of Remove catapult_base from telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@perf_cb_move
Patch Set: Created 4 years, 11 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
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import os
6
7
8 class LocalPathInfo(object):
9
10 def __init__(self, path_priority_groups):
11 self._path_priority_groups = self._ParseLocalPaths(path_priority_groups)
12
13 def GetLocalPath(self):
14 for priority_group in self._path_priority_groups:
15 priority_group = filter(os.path.exists, priority_group)
16 if not priority_group:
17 continue
18 return max(priority_group, key=lambda path: os.stat(path).st_mtime)
19 return None
20
21 def IsPathInLocalPaths(self, path):
22 return any(
23 path in priority_group for priority_group in self._path_priority_groups)
24
25 def Update(self, local_path_info):
26 if not local_path_info:
27 return
28 for priority_group in local_path_info._path_priority_groups:
29 group_list = []
30 for path in priority_group:
31 if not self.IsPathInLocalPaths(path):
32 group_list.append(path)
33 if group_list:
34 self._path_priority_groups.append(group_list)
35
36 @staticmethod
37 def _ParseLocalPaths(local_paths):
38 if not local_paths:
39 return []
40 return [[e] if isinstance(e, basestring) else e for e in local_paths]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698