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

Unified Diff: appengine/findit/crash/crash_util.py

Issue 1861373003: [Findit] Initial code of findit for crash. Add scorers to apply heuristic rules. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix nits and doc strings. Created 4 years, 8 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: appengine/findit/crash/crash_util.py
diff --git a/appengine/findit/crash/crash_util.py b/appengine/findit/crash/crash_util.py
new file mode 100644
index 0000000000000000000000000000000000000000..1456ff8e7a0d017a44fc18166f29974187afefb8
--- /dev/null
+++ b/appengine/findit/crash/crash_util.py
@@ -0,0 +1,27 @@
+# Copyright 2016 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.
+
+
+def IsSameFilePath(path1, path2):
+ """Determines if two paths represent same path.
Martin Barbella 2016/04/15 06:05:24 What's the use case for this? Just trying to under
Sharu 2016/04/15 22:59:46 If a file moved directory, like from 'a/b/c/file.c
+
+ Compares the name of the folders in the path (by split('/')), and checks
+ if they match either more than 3 or min of path lengths.
stgao 2016/04/15 18:35:18 How about adding the reason behind this comparison
Sharu 2016/04/15 22:59:46 I just port over this method which is the method w
+
+ Args:
+ path1 (str): First path.
+ path2 (str): Second path to compare.
+
+ Returns:
+ Boolean, True if it they are thought to be a same path, False otherwise.
+ """
+ path_parts1 = path1.split('/')
Martin Barbella 2016/04/15 06:05:24 Nit: _1. Ditto for the other.
Sharu 2016/04/15 22:59:46 Done.
+ path_parts2 = path2.split('/')
+
+ if path_parts1[-1] != path_parts2[-1]:
+ return False
+
+ intersection = set(path_parts1).intersection(set(path_parts2))
+ return len(intersection) >= (min(3, min(len(path_parts1),
stgao 2016/04/15 18:35:18 min(3, 2, 1) == 1
Sharu 2016/04/15 22:59:46 I think this is the intended behavior of this meth
+ len(path_parts2))))

Powered by Google App Engine
This is Rietveld 408576698