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

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

Issue 2338273006: [Findit] Factoring out the components, so they can classify themselves (Closed)
Patch Set: rebasing to remove dependency on crrev.com/2344443005 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
« no previous file with comments | « no previous file | appengine/findit/crash/component_classifier.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..37f1f2ce91d258e8b6ead21821fd8fd181860ed6
--- /dev/null
+++ b/appengine/findit/crash/component.py
@@ -0,0 +1,37 @@
+# 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
+
+
+# TODO(wrengr): write the coverage tests the old version was lacking.
+class Component(collections.namedtuple('Component',
+ ['component_name', 'path_regex', 'function_regex'])): # pragma: no cover
+ """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),
+ re.compile(function_regex) if function_regex else None)
+
+
+ def MatchesStackFrame(self, frame):
+ """Return true if this component matches the frame."""
+ 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.
+ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698