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

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

Issue 2338273006: [Findit] Factoring out the components, so they can classify themselves (Closed)
Patch Set: Created 4 years, 3 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
new file mode 100644
index 0000000000000000000000000000000000000000..b5571a0701a7078daf496afbb814cfe5be4479f7
--- /dev/null
+++ b/appengine/findit/crash/component.py
@@ -0,0 +1,35 @@
+# 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.
+
+import collections
+import re
+
+
+class Component(collections.namedtuple('Component',
+ ['component_name', 'path_regex', 'function_regex'])):
+ """A representation of a "component" in Chromium.
+
+ For example: 'Blink>DOM' or 'Blink>HTML'. Notably, a component knows
+ how to identify itself. Hence, given a stack frame or change list
+ or whatever, we ask the Component whether it matches that frame,
+ CL, etc."""
+ __slots__ = ()
+
+ def __new__(cls, component_name, path_regex, function_regex=None):
+ return super(cls, Component).__new__(cls,
+ component_name,
+ re.compile(path_regex),
Sharu Jiang 2016/09/20 00:31:29 We don't need to compile the regex here, since the
wrengr 2016/09/27 22:00:39 My aim is to remove the config's compilation, sinc
Sharu Jiang 2016/09/27 22:31:03 The reason we do the compilation in config is that
wrengr 2016/09/27 22:54:32 Conceptually, Component is the right place to do t
+ re.compile(function_regex) if function_regex else None)
+
+
+ def MatchesStackFrame(self, frame):
+ """Does this component match the file path and function of the frame?"""
stgao 2016/09/21 21:57:27 nit: use a statement instead of a question. (I und
wrengr 2016/09/27 22:00:39 Done.
+ if not self.path_regex.match(frame.dep_path + frame.file_path):
+ return False
+
+ # We interpret function_regex=None to mean the regex that matches everything
Martin Barbella 2016/09/19 21:17:18 Nit: end with a period.
wrengr 2016/09/27 22:00:39 Done.
+ if not self.function_regex:
+ return True
+ return self.function_regex.match(frame.function)
+
« 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