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

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

Issue 2657913002: [Predator] Add ``Project`` class and ``ClassifySuspect`` method to project and component classifier (Closed)
Patch Set: Fix nits. Created 3 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: appengine/findit/crash/component.py
diff --git a/appengine/findit/crash/component.py b/appengine/findit/crash/component.py
index 5e1c7a66ab75cce7d17c01ed7433157183a78918..4baf1d7cfe031df40a6589f45925ccca6db2056b 100644
--- a/appengine/findit/crash/component.py
+++ b/appengine/findit/crash/component.py
@@ -3,8 +3,11 @@
# found in the LICENSE file.
from collections import namedtuple
+import os
import re
+from libs.gitiles.diff import ChangeType
+
# TODO(http://crbug.com/659346): write the coverage tests.
class Component(namedtuple('Component',
@@ -23,10 +26,9 @@ class Component(namedtuple('Component',
re.compile(path_regex),
re.compile(function_regex) if function_regex else None)
-
def MatchesStackFrame(self, frame):
"""Returns true if this component matches the frame."""
- if not self.path_regex.match(frame.dep_path + frame.file_path):
+ if not self.path_regex.match(os.path.join(frame.dep_path, frame.file_path)):
return False
# We interpret function_regex=None to mean the regex that matches
@@ -35,6 +37,13 @@ class Component(namedtuple('Component',
return True
return self.function_regex.match(frame.function)
- def MatchesFile(self, file_path):
- """Returns true if this component matches file path."""
- return self.path_regex.match(file_path)
+ def MatchesTouchedFile(self, dep_path, touched_file):
+ """Returns true if the touched file belongs to this component."""
+ # TODO(crbug.com/685884): use component of new path as default. RENAME might
+ # need to return two (old path new path may have different components)
+ if touched_file.change_type == ChangeType.DELETE:
+ path = touched_file.old_path
+ else:
+ path = touched_file.new_path
+
+ return self.path_regex.match(os.path.join(dep_path, path))
« no previous file with comments | « no previous file | appengine/findit/crash/component_classifier.py » ('j') | appengine/findit/crash/component_classifier.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698