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

Side by Side 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 unified diff | Download patch
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 class Component(collections.namedtuple('Component',
10 ['component_name', 'path_regex', 'function_regex'])):
11 """A representation of a "component" in Chromium.
12
13 For example: 'Blink>DOM' or 'Blink>HTML'. Notably, a component knows
14 how to identify itself. Hence, given a stack frame or change list
15 or whatever, we ask the Component whether it matches that frame,
16 CL, etc."""
17 __slots__ = ()
18
19 def __new__(cls, component_name, path_regex, function_regex=None):
20 return super(cls, Component).__new__(cls,
21 component_name,
22 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
23 re.compile(function_regex) if function_regex else None)
24
25
26 def MatchesStackFrame(self, frame):
27 """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.
28 if not self.path_regex.match(frame.dep_path + frame.file_path):
29 return False
30
31 # 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.
32 if not self.function_regex:
33 return True
34 return self.function_regex.match(frame.function)
35
OLDNEW
« 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