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

Side by Side Diff: appengine/findit/crash/component.py

Issue 2414523002: [Findit] Reorganizing findit_for_*.py (Closed)
Patch Set: Finally fixed the mock tests! Created 4 years, 1 month 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 | « appengine/findit/crash/classifier.py ('k') | 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
1 # Copyright 2016 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import collections 5 from collections import namedtuple
6 import re 6 import re
7 7
8 8
9 # TODO(wrengr): write the coverage tests the old version was lacking. 9 # TODO(http://crbug.com/659346): write the coverage tests.
10 class Component(collections.namedtuple('Component', 10 class Component(namedtuple('Component',
11 ['component_name', 'path_regex', 'function_regex'])): # pragma: no cover 11 ['component_name', 'path_regex', 'function_regex'])): # pragma: no cover
12 """A representation of a "component" in Chromium. 12 """A representation of a "component" in Chromium.
13 13
14 For example: 'Blink>DOM' or 'Blink>HTML'. Notably, a component knows 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 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, 16 or whatever, we ask the Component whether it matches that frame,
17 CL, etc.""" 17 CL, etc."""
18 __slots__ = () 18 __slots__ = ()
19 19
20 def __new__(cls, component_name, path_regex, function_regex=None): 20 def __new__(cls, component_name, path_regex, function_regex=None):
21 return super(cls, Component).__new__(cls, 21 return super(cls, Component).__new__(cls,
22 component_name, 22 component_name,
23 re.compile(path_regex), 23 re.compile(path_regex),
24 re.compile(function_regex) if function_regex else None) 24 re.compile(function_regex) if function_regex else None)
25 25
26 26
27 def MatchesStackFrame(self, frame): 27 def MatchesStackFrame(self, frame):
28 """Return true if this component matches the frame.""" 28 """Return true if this component matches the frame."""
29 if not self.path_regex.match(frame.dep_path + frame.file_path): 29 if not self.path_regex.match(frame.dep_path + frame.file_path):
30 return False 30 return False
31 31
32 # We interpret function_regex=None to mean the regex that matches 32 # We interpret function_regex=None to mean the regex that matches
33 # everything. 33 # everything.
34 if not self.function_regex: 34 if not self.function_regex:
35 return True 35 return True
36 return self.function_regex.match(frame.function) 36 return self.function_regex.match(frame.function)
37 37
OLDNEW
« no previous file with comments | « appengine/findit/crash/classifier.py ('k') | appengine/findit/crash/component_classifier.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698