Chromium Code Reviews| 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..8cff9bf3e9518530dd6c8a5a4d52c6d4d0caac55 |
| --- /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. |
| + |
| + 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. |
|
Martin Barbella
2016/04/18 21:01:18
I'm not fully convinced that this is right, but it
Sharu Jiang
2016/04/19 20:38:37
Not a reliable way either but an alternative is to
stgao
2016/04/20 17:41:26
Have you explored the different change types Gitil
Sharu Jiang
2016/04/21 02:06:01
Yes, the copy/rename change type can help me detec
stgao
2016/04/21 17:31:53
If we plan to make this change, a bug should be cr
|
| + |
| + 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_parts_1 = path1.lower().split('/') |
| + path_parts_2 = path2.lower().split('/') |
| + |
| + if path_parts_1[-1] != path_parts_2[-1]: |
| + return False |
| + |
| + intersection = set(path_parts_1).intersection(set(path_parts_2)) |
|
Martin Barbella
2016/04/18 21:01:18
Set intersection might not be ideal here. I didn't
Sharu Jiang
2016/04/19 20:38:37
Done.
|
| + return len(intersection) >= (min(3, min(len(path_parts_1), |
| + len(path_parts_2)))) |