Chromium Code Reviews| 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) |
| + |