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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/catapult_base/dependency_manager/local_path_info.py
diff --git a/tools/telemetry/catapult_base/dependency_manager/local_path_info.py b/tools/telemetry/catapult_base/dependency_manager/local_path_info.py
new file mode 100644
index 0000000000000000000000000000000000000000..0103e8f7590c313491a3f3d8ef1d276134e91d39
--- /dev/null
+++ b/tools/telemetry/catapult_base/dependency_manager/local_path_info.py
@@ -0,0 +1,40 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+
+
+class LocalPathInfo(object):
+
+ def __init__(self, path_priority_groups):
+ self._path_priority_groups = self._ParseLocalPaths(path_priority_groups)
+
+ def GetLocalPath(self):
+ for priority_group in self._path_priority_groups:
+ priority_group = filter(os.path.exists, priority_group)
+ if not priority_group:
+ continue
+ return max(priority_group, key=lambda path: os.stat(path).st_mtime)
+ return None
+
+ def IsPathInLocalPaths(self, path):
+ return any(
+ path in priority_group for priority_group in self._path_priority_groups)
+
+ def Update(self, local_path_info):
+ if not local_path_info:
+ return
+ for priority_group in local_path_info._path_priority_groups:
+ group_list = []
+ for path in priority_group:
+ if not self.IsPathInLocalPaths(path):
+ group_list.append(path)
+ if group_list:
+ self._path_priority_groups.append(group_list)
+
+ @staticmethod
+ def _ParseLocalPaths(local_paths):
+ if not local_paths:
+ return []
+ return [[e] if isinstance(e, basestring) else e for e in local_paths]

Powered by Google App Engine
This is Rietveld 408576698