| 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)
|
| +
|
|
|