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

Side by Side 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, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | appengine/findit/crash/component_classifier.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import collections
6 import re
7
8
9 # TODO(wrengr): write the coverage tests the old version was lacking.
10 class Component(collections.namedtuple('Component',
11 ['component_name', 'path_regex', 'function_regex'])): # pragma: no cover
12 """A representation of a "component" in Chromium.
13
14 For example: 'Blink>DOM' or 'Blink>HTML'. Notably, a component knows
15 how to identify itself. Hence, given a stack frame or change list
16 or whatever, we ask the Component whether it matches that frame,
17 CL, etc."""
18 __slots__ = ()
19
20 def __new__(cls, component_name, path_regex, function_regex=None):
21 return super(cls, Component).__new__(cls,
22 component_name,
23 re.compile(path_regex),
24 re.compile(function_regex) if function_regex else None)
25
26
27 def MatchesStackFrame(self, frame):
28 """Return true if this component matches the frame."""
29 if not self.path_regex.match(frame.dep_path + frame.file_path):
30 return False
31
32 # We interpret function_regex=None to mean the regex that matches
33 # everything.
34 if not self.function_regex:
35 return True
36 return self.function_regex.match(frame.function)
37
OLDNEW
« 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